Skip to content

Commit

Permalink
Dapps updater should resolve dapps faster on initial load (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
noisekit authored Aug 25, 2023
1 parent 24d163a commit fc189c8
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,21 @@ async function updateConfig() {
}
}

const dappsUpdater = setInterval(updateConfig, 600_000); // 10 minutes
app.on('will-quit', () => clearInterval(dappsUpdater));
waitForIpfs().then(updateConfig).catch(logger.error);
let dappsUpdaterTimer: any = null;
async function debouncedDappsUpdater() {
if (dappsUpdaterTimer) {
clearTimeout(dappsUpdaterTimer);
dappsUpdaterTimer = null;
}
try {
await updateConfig();
} catch (error) {
logger.error(error);
}
// On initial load keep updater interval short and extend to 10m when dapps are already resolved
dappsUpdaterTimer = setTimeout(debouncedDappsUpdater, DAPPS.length > 0 ? 600_000 : 10_000);
}
waitForIpfs().then(debouncedDappsUpdater).catch(logger.error);

ipcMain.handle('peers', async () => fetchPeers());

Expand Down

0 comments on commit fc189c8

Please sign in to comment.