mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
fix(electron): deep link handling without running instance (#8661)
fix AF-1586
This commit is contained in:
@@ -57,6 +57,18 @@ export function setupDeepLink(app: App) {
|
||||
})
|
||||
.catch(e => console.error('Failed to restore or create window:', e));
|
||||
});
|
||||
|
||||
app.on('ready', () => {
|
||||
// app may be brought up without having a running instance
|
||||
// need to read the url from the command line
|
||||
const url = process.argv.at(-1);
|
||||
logger.log('url from argv', process.argv, url);
|
||||
if (url?.startsWith(`${protocol}://`)) {
|
||||
handleAffineUrl(url).catch(e => {
|
||||
logger.error('failed to handle affine url', e);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function handleAffineUrl(url: string) {
|
||||
|
||||
@@ -58,10 +58,12 @@ export function registerEvents() {
|
||||
}
|
||||
app.on('before-quit', () => {
|
||||
// subscription on quit sometimes crashes the app
|
||||
try {
|
||||
unsubs.forEach(unsub => unsub());
|
||||
} catch (err) {
|
||||
logger.error('unsubscribe error', err);
|
||||
}
|
||||
unsubs.forEach(unsub => {
|
||||
try {
|
||||
unsub();
|
||||
} catch (err) {
|
||||
logger.warn('unsubscribe error on quit', err);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user