From 5cfc3d6b0ad60a0b8874f09743f262b790a7fe74 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Fri, 7 May 2021 08:51:26 +0300 Subject: 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. --- src/ui/documentwidget.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/ui') 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) { return cstrCollect_String(heading); } -static void postProcessRequestContent_DocumentWidget_(iDocumentWidget *d) { +static void postProcessRequestContent_DocumentWidget_(iDocumentWidget *d, iBool isCached) { iWidget *w = as_Widget(d); delete_Gempub(d->sourceGempub); d->sourceGempub = NULL; @@ -1150,7 +1150,8 @@ static void postProcessRequestContent_DocumentWidget_(iDocumentWidget *d) { updateVisible_DocumentWidget_(d); invalidate_DocumentWidget_(d); } - if (prefs_App()->pinSplit && equal_String(d->mod.url, indexPageUrl_Gempub(d->sourceGempub))) { + if (!isCached && prefs_App()->pinSplit && + equal_String(d->mod.url, indexPageUrl_Gempub(d->sourceGempub))) { const iString *navStart = navStartLinkUrl_Gempub(d->sourceGempub); if (navStart) { iWindow *win = get_Window(); @@ -1397,7 +1398,7 @@ static iBool updateFromHistory_DocumentWidget_(iDocumentWidget *d) { format_String(&d->sourceHeader, cstr_Lang("pageinfo.header.cached")); set_Block(&d->sourceContent, &resp->body); updateDocument_DocumentWidget_(d, resp, iTrue); - postProcessRequestContent_DocumentWidget_(d); + postProcessRequestContent_DocumentWidget_(d, iTrue); } d->state = ready_RequestState; init_Anim(&d->altTextOpacity, 0); @@ -2250,7 +2251,7 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) checkResponse_DocumentWidget_(d); init_Anim(&d->scrollY.pos, d->initNormScrollY * size_GmDocument(d->doc).y); /* TODO: unless user already scrolled! */ d->state = ready_RequestState; - postProcessRequestContent_DocumentWidget_(d); + postProcessRequestContent_DocumentWidget_(d, iFalse); /* The response may be cached. */ if (d->request) { if (!equal_Rangecc(urlScheme_String(d->mod.url), "about") && -- cgit v1.2.3