@@ -255,31 +255,32 @@ app.on("ready", () => {
255255 } , 20000 ) ;
256256 }
257257
258- const appLocation = process . execPath ;
259-
260- // Register shortcut & appID on windows
261- if ( is . windows ( ) && ! is . dev ( ) && ! appLocation . startsWith ( path . join ( app . getPath ( "appData" ) , ".." , "Local" , "Temp" ) ) ) {
258+ // Register appID on windows
259+ if ( is . windows ( ) ) {
260+ const appLocation = process . execPath ;
262261 const appID = "com.github.th-ch.youtube-music" ;
263- const shortcutPath = path . join ( app . getPath ( "appData" ) , "Microsoft" , "Windows" , "Start Menu" , "Programs" , "YouTube Music.lnk" ) ;
264- try { // check if shortcut is registered and valid
265- const shortcutDetails = electron . shell . readShortcutLink ( shortcutPath ) ; // throw error if doesn't exist yet
266- if ( shortcutDetails . target !== appLocation || shortcutDetails . appUserModelId !== appID ) {
267- throw "needUpdate" ;
268- }
269- } catch ( error ) { // if not valid -> Register shortcut
270- electron . shell . writeShortcutLink (
271- shortcutPath ,
272- error === "needUpdate" ? "update" : "create" ,
273- {
274- target : appLocation ,
275- cwd : appLocation . slice ( 0 , appLocation . lastIndexOf ( path . sep ) ) ,
276- description : "YouTube Music Desktop App - including custom plugins" ,
277- appUserModelId : appID
262+ app . setAppUserModelId ( appID ) ;
263+ // check shortcut validity if not in dev mode / running portable app
264+ if ( ! is . dev ( ) && ! appLocation . startsWith ( path . join ( app . getPath ( "appData" ) , ".." , "Local" , "Temp" ) ) ) {
265+ const shortcutPath = path . join ( app . getPath ( "appData" ) , "Microsoft" , "Windows" , "Start Menu" , "Programs" , "YouTube Music.lnk" ) ;
266+ try { // check if shortcut is registered and valid
267+ const shortcutDetails = electron . shell . readShortcutLink ( shortcutPath ) ; // throw error if doesn't exist yet
268+ if ( shortcutDetails . target !== appLocation || shortcutDetails . appUserModelId !== appID ) {
269+ throw "needUpdate" ;
278270 }
279- ) ;
271+ } catch ( error ) { // if not valid -> Register shortcut
272+ electron . shell . writeShortcutLink (
273+ shortcutPath ,
274+ error === "needUpdate" ? "update" : "create" ,
275+ {
276+ target : appLocation ,
277+ cwd : appLocation . slice ( 0 , appLocation . lastIndexOf ( path . sep ) ) ,
278+ description : "YouTube Music Desktop App - including custom plugins" ,
279+ appUserModelId : appID
280+ }
281+ ) ;
282+ }
280283 }
281- // set appID
282- app . setAppUserModelId ( appID ) ;
283284 }
284285
285286 mainWindow = createMainWindow ( ) ;
0 commit comments