Skip to content

Commit ca51b12

Browse files
committed
Fix: Asynchronous progress check in the context menu (Mark as read/unread)
1 parent 0612c1a commit ca51b12

2 files changed

Lines changed: 39 additions & 17 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1111
- Add error handling for reading progress in comic context menu
1212
- Error handling for corrupted JSON/ZSTD files in cache and remove them
1313
- Header bar buttons don't register start/end of chapter if scrolled with scrollbar
14+
- Asynchronous progress check in the context menu (Mark as read/unread)
1415

1516
## [v1.6.2](https://github.com/ollm/OpenComic/releases/tag/v1.6.2) (08-09-2025)
1617

‎scripts/dom.js‎

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2325,9 +2325,13 @@ function nightModeConfig(_app = false)
23252325
_app.classList.remove('night-mode-white-blank-page');
23262326
}
23272327

2328+
let comicContextMenuIndex = 0;
2329+
23282330
// Show the comic context menu
23292331
async function comicContextMenu(path, mainPath, fromIndex = true, fromIndexNotMasterFolders = true, folder = false, gamepad = false)
23302332
{
2333+
comicContextMenuIndex++;
2334+
23312335
let isServer = fileManager.isServer(path);
23322336
if(fileManager.isOpds(path)) return;
23332337

@@ -2383,25 +2387,42 @@ async function comicContextMenu(path, mainPath, fromIndex = true, fromIndexNotMa
23832387

23842388
if(fromIndex || folder)
23852389
{
2386-
try
2387-
{
2388-
const progress = await reading.progress.get(path);
2389-
reading.progress.updateProgress(path, progress);
2390+
const currentIndex = comicContextMenuIndex;
23902391

2391-
markRead.style.display = (progress.completed) ? 'none' : 'block';
2392-
markRead.setAttribute('onclick', 'reading.progress.read(\''+escapeQuotes(escapeBackSlash(path), 'simples')+'\');');
2392+
markRead.classList.add('disable-pointer');
2393+
markUnread.classList.add('disable-pointer');
23932394

2394-
markUnread.style.display = (progress.percent === 0) ? 'none' : 'block';
2395-
markUnread.setAttribute('onclick', 'reading.progress.unread(\''+escapeQuotes(escapeBackSlash(path), 'simples')+'\');');
2396-
2397-
separatorMark.style.display = 'block';
2398-
}
2399-
catch(error)
2400-
{
2401-
markRead.style.display = 'none';
2402-
markUnread.style.display = 'none';
2403-
separatorMark.style.display = 'none';
2404-
}
2395+
(async function(){
2396+
2397+
try
2398+
{
2399+
const progress = await reading.progress.get(path);
2400+
reading.progress.updateProgress(path, progress);
2401+
2402+
if(currentIndex !== comicContextMenuIndex)
2403+
return;
2404+
2405+
dom.this(markRead).class(progress.completed, 'disable-pointer');
2406+
markRead.setAttribute('onclick', 'reading.progress.read(\''+escapeQuotes(escapeBackSlash(path), 'simples')+'\');');
2407+
2408+
dom.this(markUnread).class((progress.percent === 0), 'disable-pointer');
2409+
markUnread.setAttribute('onclick', 'reading.progress.unread(\''+escapeQuotes(escapeBackSlash(path), 'simples')+'\');');
2410+
2411+
separatorMark.style.display = 'block';
2412+
}
2413+
catch(error)
2414+
{
2415+
console.error(error);
2416+
2417+
if(currentIndex !== comicContextMenuIndex)
2418+
return;
2419+
2420+
markRead.style.display = 'none';
2421+
markUnread.style.display = 'none';
2422+
separatorMark.style.display = 'none';
2423+
}
2424+
2425+
})()
24052426
}
24062427
else
24072428
{

0 commit comments

Comments
 (0)