register appID on windows reguardless of shortcut

This commit is contained in:
Araxeus
2021-05-11 00:34:40 +03:00
parent cb5ef1d6e5
commit d615030222

View File

@ -255,11 +255,13 @@ app.on("ready", () => {
}, 20000); }, 20000);
} }
// Register appID on windows
if (is.windows()) {
const appLocation = process.execPath; const appLocation = process.execPath;
// Register shortcut & appID on windows
if (is.windows() && !is.dev() && !appLocation.startsWith(path.join(app.getPath("appData"), "..", "Local", "Temp"))) {
const appID = "com.github.th-ch.youtube-music"; const appID = "com.github.th-ch.youtube-music";
app.setAppUserModelId(appID);
// check shortcut validity if not in dev mode / running portable app
if (!is.dev() && !appLocation.startsWith(path.join(app.getPath("appData"), "..", "Local", "Temp"))) {
const shortcutPath = path.join(app.getPath("appData"), "Microsoft", "Windows", "Start Menu", "Programs", "YouTube Music.lnk"); const shortcutPath = path.join(app.getPath("appData"), "Microsoft", "Windows", "Start Menu", "Programs", "YouTube Music.lnk");
try { // check if shortcut is registered and valid try { // check if shortcut is registered and valid
const shortcutDetails = electron.shell.readShortcutLink(shortcutPath); // throw error if doesn't exist yet const shortcutDetails = electron.shell.readShortcutLink(shortcutPath); // throw error if doesn't exist yet
@ -278,8 +280,7 @@ app.on("ready", () => {
} }
); );
} }
// set appID }
app.setAppUserModelId(appID);
} }
mainWindow = createMainWindow(); mainWindow = createMainWindow();