summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-05-07 08:51:26 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-05-07 08:51:26 +0300
commit5cfc3d6b0ad60a0b8874f09743f262b790a7fe74 (patch)
tree652f671e4f545c5d1cc5cffd04a74bde891f6ca8 /src/ui
parentbcaa2a3ce76b522679a1db3ca27d3a12a5a6a691 (diff)
Gempub: Restoring pages from cache
Only auto-open the first chapter when navigating normally, and not via cache. Otherwise the previous read position would be lost.
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/documentwidget.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index db7d6eee..a076000c 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -1102,7 +1102,7 @@ static const char *zipPageHeading_(const iRangecc mime) {
1102 return cstrCollect_String(heading); 1102 return cstrCollect_String(heading);
1103} 1103}
1104 1104
1105static void postProcessRequestContent_DocumentWidget_(iDocumentWidget *d) { 1105static void postProcessRequestContent_DocumentWidget_(iDocumentWidget *d, iBool isCached) {
1106 iWidget *w = as_Widget(d); 1106 iWidget *w = as_Widget(d);
1107 delete_Gempub(d->sourceGempub); 1107 delete_Gempub(d->sourceGempub);
1108 d->sourceGempub = NULL; 1108 d->sourceGempub = NULL;
@@ -1150,7 +1150,8 @@ static void postProcessRequestContent_DocumentWidget_(iDocumentWidget *d) {
1150 updateVisible_DocumentWidget_(d); 1150 updateVisible_DocumentWidget_(d);
1151 invalidate_DocumentWidget_(d); 1151 invalidate_DocumentWidget_(d);
1152 } 1152 }
1153 if (prefs_App()->pinSplit && equal_String(d->mod.url, indexPageUrl_Gempub(d->sourceGempub))) { 1153 if (!isCached && prefs_App()->pinSplit &&
1154 equal_String(d->mod.url, indexPageUrl_Gempub(d->sourceGempub))) {
1154 const iString *navStart = navStartLinkUrl_Gempub(d->sourceGempub); 1155 const iString *navStart = navStartLinkUrl_Gempub(d->sourceGempub);
1155 if (navStart) { 1156 if (navStart) {
1156 iWindow *win = get_Window(); 1157 iWindow *win = get_Window();
@@ -1397,7 +1398,7 @@ static iBool updateFromHistory_DocumentWidget_(iDocumentWidget *d) {
1397 format_String(&d->sourceHeader, cstr_Lang("pageinfo.header.cached")); 1398 format_String(&d->sourceHeader, cstr_Lang("pageinfo.header.cached"));
1398 set_Block(&d->sourceContent, &resp->body); 1399 set_Block(&d->sourceContent, &resp->body);
1399 updateDocument_DocumentWidget_(d, resp, iTrue); 1400 updateDocument_DocumentWidget_(d, resp, iTrue);
1400 postProcessRequestContent_DocumentWidget_(d); 1401 postProcessRequestContent_DocumentWidget_(d, iTrue);
1401 } 1402 }
1402 d->state = ready_RequestState; 1403 d->state = ready_RequestState;
1403 init_Anim(&d->altTextOpacity, 0); 1404 init_Anim(&d->altTextOpacity, 0);
@@ -2250,7 +2251,7 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)
2250 checkResponse_DocumentWidget_(d); 2251 checkResponse_DocumentWidget_(d);
2251 init_Anim(&d->scrollY.pos, d->initNormScrollY * size_GmDocument(d->doc).y); /* TODO: unless user already scrolled! */ 2252 init_Anim(&d->scrollY.pos, d->initNormScrollY * size_GmDocument(d->doc).y); /* TODO: unless user already scrolled! */
2252 d->state = ready_RequestState; 2253 d->state = ready_RequestState;
2253 postProcessRequestContent_DocumentWidget_(d); 2254 postProcessRequestContent_DocumentWidget_(d, iFalse);
2254 /* The response may be cached. */ 2255 /* The response may be cached. */
2255 if (d->request) { 2256 if (d->request) {
2256 if (!equal_Rangecc(urlScheme_String(d->mod.url), "about") && 2257 if (!equal_Rangecc(urlScheme_String(d->mod.url), "about") &&