Skip to content

Commit e8e2c16

Browse files
committed
Fix: When reloading, change view or sorting a folder opens reading mode in some cases
1 parent 6714303 commit e8e2c16

File tree

3 files changed

+15
-30
lines changed

3 files changed

+15
-30
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1010

1111
##### 🐛 Bug Fixes
1212

13-
- Error when resizing after exit comic opened from recents
13+
- Error when resizing after exit comic opened from recents [`8291730`](https://github.com/ollm/OpenComic/commit/829173058bb3dde12d35b726070c19ec43a63be3)
14+
- When reloading, change view or sorting a folder opens reading mode in some cases
1415

1516
## [v1.0.0-beta.5](https://github.com/ollm/OpenComic/releases/tag/v1.0.0-beta.5) (24-11-2023)
1617

scripts/dom.js

+12-28
Original file line numberDiff line numberDiff line change
@@ -288,12 +288,13 @@ async function loadFilesIndexPage(file, animation, path, keepScroll, mainPath)
288288

289289
async function reloadIndex()
290290
{
291-
loadIndexPage(true, indexPathA, true, true, indexMainPathA);
291+
loadIndexPage(true, indexPathA, true, true, indexMainPathA, false, true);
292+
if(indexPathA) indexPathControlA.pop();
292293
}
293294

294295
var currentPath = false, currentPathScrollTop = [], fromDeepLoadNow = 0;
295296

296-
async function loadIndexPage(animation = true, path = false, content = false, keepScroll = false, mainPath = false, fromGoBack = false, disableIgnoreSingleFolders = false, fromDeepLoad = false)
297+
async function loadIndexPage(animation = true, path = false, content = false, keepScroll = false, mainPath = false, fromGoBack = false, notAutomaticBrowsing = false, fromDeepLoad = false)
297298
{
298299
onReading = _onReading = false;
299300

@@ -502,7 +503,7 @@ async function loadIndexPage(animation = true, path = false, content = false, ke
502503
let openContinueReading = false;
503504
let openFirstImage = ((!isCompressed && config.whenOpenFolderFirstImageOrContinueReading) || (isCompressed && config.whenOpenFileFirstImageOrContinueReading)) ? true : false;
504505

505-
if((config.whenOpenFolderContinueReading || config.whenOpenFileContinueReading || config.whenOpenFolderFirstImageOrContinueReading || config.whenOpenFileFirstImageOrContinueReading) && !fromGoBack && !disableIgnoreSingleFolders && readingProgress && readingProgress.lastReading > 0)
506+
if((config.whenOpenFolderContinueReading || config.whenOpenFileContinueReading || config.whenOpenFolderFirstImageOrContinueReading || config.whenOpenFileFirstImageOrContinueReading) && !fromGoBack && !notAutomaticBrowsing && readingProgress && readingProgress.lastReading > 0)
506507
{
507508
let isParentPath = fileManager.isParentPath(path, readingProgress.path);
508509

@@ -514,7 +515,7 @@ async function loadIndexPage(animation = true, path = false, content = false, ke
514515

515516
let file = fileManager.file(path);
516517

517-
if(openContinueReading && !fromGoBack && !disableIgnoreSingleFolders)
518+
if(openContinueReading && !fromGoBack && !notAutomaticBrowsing)
518519
{
519520
fromDeepLoadNow = Date.now();
520521
indexPathControlA.pop();
@@ -528,7 +529,7 @@ async function loadIndexPage(animation = true, path = false, content = false, ke
528529

529530
return;
530531
}
531-
else if(openFirstImage && !fromGoBack && !disableIgnoreSingleFolders)
532+
else if(openFirstImage && !fromGoBack && !notAutomaticBrowsing)
532533
{
533534
let first = await file.images(1);
534535

@@ -548,7 +549,7 @@ async function loadIndexPage(animation = true, path = false, content = false, ke
548549
let indexData = await loadFilesIndexPage(file, animation, path, keepScroll, mainPath);
549550
file.destroy();
550551

551-
if(config.ignoreSingleFoldersLibrary && !fromGoBack && !disableIgnoreSingleFolders && indexData.files.length == 1 && (indexData.files[0].folder || indexData.files[0].compressed))
552+
if(config.ignoreSingleFoldersLibrary && !fromGoBack && !notAutomaticBrowsing && indexData.files.length == 1 && (indexData.files[0].folder || indexData.files[0].compressed))
552553
{
553554
fromDeepLoadNow = Date.now();
554555
indexPathControlA.pop();
@@ -674,7 +675,7 @@ async function goNextComic(path, mainPath)
674675

675676
if(_nextComic)
676677
{
677-
dom.loadIndexPage(true, p.dirname(_nextComic), false, false, indexMainPathA);
678+
dom.loadIndexPage(true, p.dirname(_nextComic), false, false, indexMainPathA, false, true);
678679
}
679680
}
680681

@@ -684,7 +685,7 @@ async function goPrevComic(path, mainPath)
684685

685686
if(prevComic)
686687
{
687-
dom.loadIndexPage(true, p.dirname(prevComic), false, false, indexMainPathA);
688+
dom.loadIndexPage(true, p.dirname(prevComic), false, false, indexMainPathA, false, true);
688689
}
689690
}
690691

@@ -1194,18 +1195,9 @@ function changeView(mode, page)
11941195
if(changed)
11951196
{
11961197
if(page == 'recently-opened')
1197-
{
11981198
recentlyOpened.reload();
1199-
}
1200-
else if(page == 'index')
1201-
{
1202-
loadIndexPage(true, false, true, true);
1203-
}
12041199
else
1205-
{
1206-
loadIndexPage(true, indexPathA, true, true, indexMainPathA);
1207-
indexPathControlA.pop();
1208-
}
1200+
reloadIndex();
12091201
}
12101202
}
12111203

@@ -1251,18 +1243,9 @@ function changeSort(type, mode, page)
12511243
if(changed)
12521244
{
12531245
if(page == 'recently-opened')
1254-
{
12551246
recentlyOpened.reload();
1256-
}
1257-
else if(page == 'index')
1258-
{
1259-
loadIndexPage(true, false, true, true);
1260-
}
12611247
else
1262-
{
1263-
loadIndexPage(true, indexPathA, true, true, indexMainPathA);
1264-
indexPathControlA.pop();
1265-
}
1248+
reloadIndex();
12661249
}
12671250
}
12681251

@@ -1637,6 +1620,7 @@ module.exports = {
16371620
addPoster: addPoster,
16381621
deletePoster: deletePoster,
16391622
indexPathControlUpdateLastComic: indexPathControlUpdateLastComic,
1623+
indexPathA: function(){return indexPathA},
16401624
indexMainPathA: function(){return indexMainPathA},
16411625
currentPathScrollTop: function(){return currentPathScrollTop},
16421626
getFolderThumbnails: getFolderThumbnails,

templates/reading.header.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="bar-title title-small" style="max-width: calc(100% - (957px + 68px));">
33
{{#if headerTitlePath}}
44
{{#each headerTitlePath}}
5-
<span class="bar-title-a" onclick="reading.saveReadingProgress(); dom.loadIndexPage(true, '{{chain 'escapeBackSlash' 'escapeQuotesSimples' path}}', false, false, '{{chain 'escapeBackSlash' 'escapeQuotesSimples' mainPath}}', true)">{{name}}</span>
5+
<span class="bar-title-a" onclick="reading.saveReadingProgress(); dom.loadIndexPage(true, '{{chain 'escapeBackSlash' 'escapeQuotesSimples' path}}', false, false, '{{chain 'escapeBackSlash' 'escapeQuotesSimples' mainPath}}', false, true)">{{name}}</span>
66
{{#unless last}} <i class="material-icon navegation">chevron_right</i> {{/unless}}
77
{{/each}}
88
{{else}}

0 commit comments

Comments
 (0)