Skip to content

Commit 99e524a

Browse files
committed
Fix: Some errors
1 parent d9f7fa0 commit 99e524a

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

scripts/main.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,14 @@ function createWindow(options = {}) {
167167
{
168168
appClosing = true;
169169

170-
win.webContents.executeJavaScript('var saved = reading.progress.save(); tabs.restore.save(); settings.purgeTemporaryFiles(); cache.purge(); ebook.closeAllRenders(); workers.closeAllWorkers(); storage.purgeOldAtomic(); saved;', false).then(function(value) {
170+
win.webContents.executeJavaScript('const saved = reading.progress.save(); tabs.restore.save(false, true); settings.purgeTemporaryFiles(); cache.purge(); ebook.closeAllRenders(); workers.closeAllWorkers(); storage.purgeOldAtomic(); saved;', false).then(function(value) {
171171

172-
if(!value)
172+
win.hide();
173+
174+
// Wait for it to save
175+
setTimeout(function(win){
173176
win.close();
174-
else // Wait for it to save
175-
setTimeout(function(win){win.close()}, 200, win);
177+
}, 500, win);
176178

177179
});
178180

scripts/reading.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1704,7 +1704,7 @@ function onScroll(event)
17041704

17051705
let contentHeightRes = pageVisibility > 0 ? ((rightSize.height * pageVisibility) - imgHeight) / pageVisibility : 0;
17061706

1707-
scrollPart = ((rightSize.height - contentHeightRes) - rightSize.height / pageVisibility);
1707+
const scrollPart = ((rightSize.height - contentHeightRes) - rightSize.height / pageVisibility);
17081708

17091709
currentPageVisibility = Math.round((scrollTop - (imagesFullPosition[selIndex][0].top - readingMargin().top)) / scrollPart);
17101710
if(currentPageVisibility < 0) currentPageVisibility = 0;

scripts/tabs.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ function update(id: number, tab: Partial<Tab>, retrieveData: boolean = true): vo
244244
if(tab.data !== undefined) _tab.data = tab.data;
245245
}
246246

247-
function _update(): void
247+
function _update(retrieveData: boolean = false): void
248248
{
249249
const activeTab = tabs.find(t => t.active);
250250
if(!activeTab) return;
@@ -259,7 +259,7 @@ function _update(): void
259259

260260
const type = onReading ? 'reading' : 'normal';
261261

262-
update(activeTab.id, {icon, title});
262+
update(activeTab.id, {icon, title}, retrieveData);
263263
restore.save();
264264
}
265265

scripts/tabs/restore.mts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@ interface TabSaved {
1818
data: string;
1919
}
2020

21-
function save(throttle: boolean = true): void {
21+
function save(throttle: boolean = true, updateActive: boolean = false): void {
2222

2323
if(!config.restoreTabsFromLastSession)
2424
return;
2525

26+
if(updateActive)
27+
tabs.update(true);
28+
2629
const _tabs: Tab[] = tabs.tabs;
2730
const idCounter = tabs.idCounter;
2831
const lastUsedTabs = tabs.lastUsedTabs;

0 commit comments

Comments
 (0)