feat: adding deep linking to import sources

This commit is contained in:
Chubby Granny Chaser 2024-06-22 20:15:07 +01:00
parent fbcacd7c39
commit 6d3b04fc3c
No known key found for this signature in database
11 changed files with 194 additions and 110 deletions

View file

@ -73,7 +73,16 @@ app.on("browser-window-created", (_, window) => {
optimizer.watchWindowShortcuts(window);
});
app.on("second-instance", (_event) => {
const handleDeepLinkPath = (uri?: string) => {
if (!uri) return;
const url = new URL(uri);
if (url.host === "install-source") {
WindowManager.redirect(`settings${url.search}`);
}
};
app.on("second-instance", (_event, commandLine) => {
// Someone tried to run a second instance, we should focus our window.
if (WindowManager.mainWindow) {
if (WindowManager.mainWindow.isMinimized())
@ -84,16 +93,12 @@ app.on("second-instance", (_event) => {
WindowManager.createMainWindow();
}
// const [, path] = commandLine.pop()?.split("://") ?? [];
// if (path) {
// WindowManager.redirect(path);
// }
handleDeepLinkPath(commandLine.pop());
});
// app.on("open-url", (_event, url) => {
// const [, path] = url.split("://");
// WindowManager.redirect(path);
// });
app.on("open-url", (_event, url) => {
handleDeepLinkPath(url);
});
// Quit when all windows are closed, except on macOS. There, it's common
// for applications and their menu bar to stay active until the user quits