Skip to content

Commit a409d38

Browse files
committed
fix: progress nan%
1 parent 6059540 commit a409d38

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

main.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,11 @@ ipcMain.handle('start-voting', async (event, params) => {
130130
const { id, screenshot } = progress;
131131
if (!id || id.total <= 0) return;
132132

133-
const base = id.current - (screenshot && screenshot.total > 0 ? 1 : 0);
134-
const screenshotProgress = screenshot ? screenshot.current / screenshot.total : 0;
133+
const hasScreenshot = screenshot && screenshot.total > 0;
134+
const base = id.current - (hasScreenshot ? 1 : 0);
135+
const screenshotProgress = hasScreenshot ? (screenshot.current / screenshot.total) : 0;
135136
const percent = Math.floor(((base + screenshotProgress) / id.total) * 100);
136-
const safePercent = Math.min(100, Math.max(0, percent));
137+
const safePercent = Math.min(100, Math.max(0, isNaN(percent) ? 0 : percent));
137138

138139
mainWindow.setTitle(`(${safePercent}%) 股東會投票幫手`);
139140
};

0 commit comments

Comments
 (0)