Initialize IPC channels early
This commit is contained in:
parent
8841de17a5
commit
0e19c17160
|
@ -19,7 +19,7 @@ const ERASE_TEMP_KEY = 'erase-temp';
|
|||
const ERASE_DRAFTS_KEY = 'erase-drafts';
|
||||
const CLEANUP_ORPHANED_ATTACHMENTS_KEY = 'cleanup-orphaned-attachments';
|
||||
|
||||
async function initialize({ configDir, cleanupOrphanedAttachments }) {
|
||||
function initialize({ configDir, cleanupOrphanedAttachments }) {
|
||||
if (initialized) {
|
||||
throw new Error('initialze: Already initialized!');
|
||||
}
|
||||
|
|
31
main.js
31
main.js
|
@ -1247,6 +1247,23 @@ app.on('ready', async () => {
|
|||
loadingWindow.loadURL(prepareFileUrl([__dirname, 'loading.html']));
|
||||
});
|
||||
|
||||
try {
|
||||
await attachments.clearTempPath(userDataPath);
|
||||
} catch (err) {
|
||||
logger.error(
|
||||
'main/ready: Error deleting temp dir:',
|
||||
err && err.stack ? err.stack : err
|
||||
);
|
||||
}
|
||||
|
||||
// Initialize IPC channels before creating the window
|
||||
|
||||
attachmentChannel.initialize({
|
||||
configDir: userDataPath,
|
||||
cleanupOrphanedAttachments,
|
||||
});
|
||||
sqlChannels.initialize(sql);
|
||||
|
||||
// Run window preloading in parallel with database initialization.
|
||||
await createWindow();
|
||||
|
||||
|
@ -1282,7 +1299,6 @@ app.on('ready', async () => {
|
|||
|
||||
// eslint-disable-next-line more/no-then
|
||||
appStartInitialSpellcheckSetting = await getSpellCheckSetting();
|
||||
await sqlChannels.initialize(sql);
|
||||
|
||||
try {
|
||||
const IDB_KEY = 'indexeddb-delete-needed';
|
||||
|
@ -1330,19 +1346,6 @@ app.on('ready', async () => {
|
|||
});
|
||||
}
|
||||
|
||||
try {
|
||||
await attachments.clearTempPath(userDataPath);
|
||||
} catch (err) {
|
||||
logger.error(
|
||||
'main/ready: Error deleting temp dir:',
|
||||
err && err.stack ? err.stack : err
|
||||
);
|
||||
}
|
||||
await attachmentChannel.initialize({
|
||||
configDir: userDataPath,
|
||||
cleanupOrphanedAttachments,
|
||||
});
|
||||
|
||||
ready = true;
|
||||
|
||||
if (usingTrayIcon) {
|
||||
|
|
Loading…
Reference in New Issue