@@ -254,13 +254,16 @@ function runApp() {
254
254
255
255
app . on ( 'second-instance' , ( _ , commandLine , __ ) => {
256
256
// Someone tried to run a second instance, we should focus our window
257
- if ( mainWindow && typeof commandLine !== 'undefined' ) {
258
- if ( mainWindow . isMinimized ( ) ) mainWindow . restore ( )
259
- mainWindow . focus ( )
260
-
257
+ if ( typeof commandLine !== 'undefined' ) {
261
258
const url = getLinkUrl ( commandLine )
262
- if ( url ) {
263
- mainWindow . webContents . send ( IpcChannels . OPEN_URL , url )
259
+ if ( mainWindow && mainWindow . webContents ) {
260
+ if ( mainWindow . isMinimized ( ) ) mainWindow . restore ( )
261
+ mainWindow . focus ( )
262
+
263
+ if ( url ) mainWindow . webContents . send ( IpcChannels . OPEN_URL , url )
264
+ } else {
265
+ if ( url ) startupUrl = url
266
+ createWindow ( )
264
267
}
265
268
}
266
269
} )
@@ -829,10 +832,11 @@ function runApp() {
829
832
} )
830
833
}
831
834
832
- ipcMain . once ( IpcChannels . APP_READY , ( ) => {
835
+ ipcMain . on ( IpcChannels . APP_READY , ( ) => {
833
836
if ( startupUrl ) {
834
837
mainWindow . webContents . send ( IpcChannels . OPEN_URL , startupUrl , { isLaunchLink : true } )
835
838
}
839
+ startupUrl = null
836
840
} )
837
841
838
842
function relaunch ( ) {
@@ -1294,11 +1298,7 @@ function runApp() {
1294
1298
return null
1295
1299
1296
1300
case DBActions . PLAYLISTS . DELETE_VIDEO_ID :
1297
- await baseHandlers . playlists . deleteVideoIdByPlaylistId ( {
1298
- _id : data . _id ,
1299
- videoId : data . videoId ,
1300
- playlistItemId : data . playlistItemId ,
1301
- } )
1301
+ await baseHandlers . playlists . deleteVideoIdByPlaylistId ( data . _id , data . videoId , data . playlistItemId )
1302
1302
syncOtherWindows (
1303
1303
IpcChannels . SYNC_PLAYLISTS ,
1304
1304
event ,
@@ -1340,6 +1340,8 @@ function runApp() {
1340
1340
}
1341
1341
} )
1342
1342
1343
+ // *********** //
1344
+
1343
1345
// ************** //
1344
1346
// Search History
1345
1347
ipcMain . handle ( IpcChannels . DB_SEARCH_HISTORY , async ( event , { action, data } ) => {
@@ -1398,8 +1400,6 @@ function runApp() {
1398
1400
}
1399
1401
} )
1400
1402
1401
- // *********** //
1402
-
1403
1403
// *********** //
1404
1404
// Profiles
1405
1405
ipcMain . handle ( IpcChannels . DB_SUBSCRIPTION_CACHE , async ( event , { action, data } ) => {
@@ -1409,7 +1409,7 @@ function runApp() {
1409
1409
return await baseHandlers . subscriptionCache . find ( )
1410
1410
1411
1411
case DBActions . SUBSCRIPTION_CACHE . UPDATE_VIDEOS_BY_CHANNEL :
1412
- await baseHandlers . subscriptionCache . updateVideosByChannelId ( data )
1412
+ await baseHandlers . subscriptionCache . updateVideosByChannelId ( data . channelId , data . entries , data . timestamp )
1413
1413
syncOtherWindows (
1414
1414
IpcChannels . SYNC_SUBSCRIPTION_CACHE ,
1415
1415
event ,
@@ -1418,7 +1418,7 @@ function runApp() {
1418
1418
return null
1419
1419
1420
1420
case DBActions . SUBSCRIPTION_CACHE . UPDATE_LIVE_STREAMS_BY_CHANNEL :
1421
- await baseHandlers . subscriptionCache . updateLiveStreamsByChannelId ( data )
1421
+ await baseHandlers . subscriptionCache . updateLiveStreamsByChannelId ( data . channelId , data . entries , data . timestamp )
1422
1422
syncOtherWindows (
1423
1423
IpcChannels . SYNC_SUBSCRIPTION_CACHE ,
1424
1424
event ,
@@ -1427,7 +1427,7 @@ function runApp() {
1427
1427
return null
1428
1428
1429
1429
case DBActions . SUBSCRIPTION_CACHE . UPDATE_SHORTS_BY_CHANNEL :
1430
- await baseHandlers . subscriptionCache . updateShortsByChannelId ( data )
1430
+ await baseHandlers . subscriptionCache . updateShortsByChannelId ( data . channelId , data . entries , data . timestamp )
1431
1431
syncOtherWindows (
1432
1432
IpcChannels . SYNC_SUBSCRIPTION_CACHE ,
1433
1433
event ,
@@ -1436,7 +1436,7 @@ function runApp() {
1436
1436
return null
1437
1437
1438
1438
case DBActions . SUBSCRIPTION_CACHE . UPDATE_SHORTS_WITH_CHANNEL_PAGE_SHORTS_BY_CHANNEL :
1439
- await baseHandlers . subscriptionCache . updateShortsWithChannelPageShortsByChannelId ( data )
1439
+ await baseHandlers . subscriptionCache . updateShortsWithChannelPageShortsByChannelId ( data . channelId , data . entries )
1440
1440
syncOtherWindows (
1441
1441
IpcChannels . SYNC_SUBSCRIPTION_CACHE ,
1442
1442
event ,
@@ -1445,7 +1445,7 @@ function runApp() {
1445
1445
return null
1446
1446
1447
1447
case DBActions . SUBSCRIPTION_CACHE . UPDATE_COMMUNITY_POSTS_BY_CHANNEL :
1448
- await baseHandlers . subscriptionCache . updateCommunityPostsByChannelId ( data )
1448
+ await baseHandlers . subscriptionCache . updateCommunityPostsByChannelId ( data . channelId , data . entries , data . timestamp )
1449
1449
syncOtherWindows (
1450
1450
IpcChannels . SYNC_SUBSCRIPTION_CACHE ,
1451
1451
event ,
@@ -1500,6 +1500,7 @@ function runApp() {
1500
1500
app . on ( 'window-all-closed' , ( ) => {
1501
1501
// Clean up resources (datastores' compaction + Electron cache and storage data clearing)
1502
1502
cleanUpResources ( ) . finally ( ( ) => {
1503
+ mainWindow = null
1503
1504
if ( process . platform !== 'darwin' ) {
1504
1505
app . quit ( )
1505
1506
}
@@ -1569,6 +1570,7 @@ function runApp() {
1569
1570
mainWindow . webContents . send ( IpcChannels . OPEN_URL , baseUrl ( url ) )
1570
1571
} else {
1571
1572
startupUrl = baseUrl ( url )
1573
+ if ( app . isReady ( ) ) createWindow ( )
1572
1574
}
1573
1575
} )
1574
1576
0 commit comments