Skip to content

armgit / plexo

Public Imported from GitHub
0

Speed up downloads by combining multiple network connections in parallel

fix: address review feedback for notification reveal and tray background lifecycle (#225)

Dhruvil Patel3f1133b1a921
diff --git a/e2e/lifecycle.spec.ts b/e2e/lifecycle.spec.ts
index 2b99ce1..d63fea4 100644
--- a/e2e/lifecycle.spec.ts
+++ b/e2e/lifecycle.spec.ts
@@ -251,16 +251,21 @@ test.describe('window close with active downloads @smoke', () => {
const windowState = await plexo.evaluateMain(({ BrowserWindow }) => {
const win = BrowserWindow.getAllWindows()[0]
win.close()
- return { isDestroyed: win.isDestroyed(), isVisible: win.isVisible() }
+ return { isDestroyed: win.isDestroyed() }
}, null)
expect(windowState.isDestroyed, 'window is not destroyed').toBe(false)
- expect(windowState.isVisible, 'window is hidden').toBe(false)
expect(plexo.alive, 'app is still alive').toBe(true)
const nextReached = origin.hold(10 * BLOCK)
await nextReached
+ const windowCount = await plexo.evaluateMain(
+ ({ BrowserWindow }) => BrowserWindow.getAllWindows().length,
+ null
+ )
+ expect(windowCount, 'window remains open in background').toBe(1)
+
await plexo.relaunch()
const current = await plexo.currentHttp()
expect(current?.status).toBe('paused')
diff --git a/src/main/download/downloadManager.ts b/src/main/download/downloadManager.ts
index 3362f48..3a90672 100644
--- a/src/main/download/downloadManager.ts
+++ b/src/main/download/downloadManager.ts
@@ -2105,9 +2105,7 @@ export class DownloadManager {
try {
const notification = new Notification({ title, body })
notification.on('click', () => {
- if (downloadId) {
- void this.reveal(downloadId)
- } else {
+ const showWindow = (): void => {
const window = this.getWindow()
if (window && !window.isDestroyed()) {
if (window.isMinimized()) window.restore()
@@ -2115,6 +2113,13 @@ export class DownloadManager {
window.focus()
}
}
+ if (downloadId) {
+ void this.reveal(downloadId).then((revealed) => {
+ if (!revealed) showWindow()
+ })
+ } else {
+ showWindow()
+ }
})
notification.show()
} catch {
diff --git a/src/main/index.ts b/src/main/index.ts
index a2955f1..985b4b0 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -156,7 +156,7 @@ function createWindow(): void {
ensureTray()
if (!hasShownTrayNotification && activeCount > 0) {
hasShownTrayNotification = true
- if (Notification.isSupported()) {
+ if (!testKnobs.userDataDir && Notification.isSupported()) {
new Notification({
title: 'Plexo is still downloading',
body: 'Downloads will continue in the background. Open Plexo again, or use its tray icon, to quit.'