mirror of
https://github.com/nimbold/Firelink.git
synced 2026-07-27 20:40:12 +00:00
fix(infra): harden loopback server lifecycle
This commit is contained in:
+19
-1
@@ -238,10 +238,27 @@ function App() {
|
||||
const unlistenExtension = listen('extension-add-download', (event) => {
|
||||
useDownloadStore.getState().handleExtensionDownload(event.payload);
|
||||
});
|
||||
const unlistenExtensionQueued = listen('extension-downloads-queued', (event) => {
|
||||
const store = useDownloadStore.getState();
|
||||
const incoming = event.payload;
|
||||
const existing = new Set(store.downloads.map(download => download.id));
|
||||
const additions = incoming.filter(download => !existing.has(download.id));
|
||||
if (additions.length === 0) return;
|
||||
useDownloadStore.setState(state => ({
|
||||
downloads: [...state.downloads, ...additions],
|
||||
pendingOrder: [
|
||||
...state.pendingOrder,
|
||||
...additions
|
||||
.filter(download => download.status === 'queued')
|
||||
.map(download => download.id)
|
||||
.filter(id => !state.pendingOrder.includes(id)),
|
||||
],
|
||||
}));
|
||||
});
|
||||
const unlistenDeepLink = listen('deep-link-add-download', (event) => {
|
||||
useDownloadStore.getState().openAddModalWithUrls(event.payload);
|
||||
});
|
||||
Promise.all([unlistenExtension, unlistenDeepLink])
|
||||
Promise.all([unlistenExtension, unlistenExtensionQueued, unlistenDeepLink])
|
||||
.then(() => invoke('set_extension_frontend_ready', { ready: true }))
|
||||
.catch(error => console.error('Failed to activate browser extension integration:', error));
|
||||
|
||||
@@ -250,6 +267,7 @@ function App() {
|
||||
unlistenComplete.then(f => f());
|
||||
unlistenFailed.then(f => f());
|
||||
unlistenExtension.then(f => f());
|
||||
unlistenExtensionQueued.then(f => f());
|
||||
unlistenDeepLink.then(f => f());
|
||||
};
|
||||
}, []);
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export type ExtensionDownload = { urls: Array<string>, referer: string | null, silent: boolean, filename: string | null, };
|
||||
export type ExtensionDownload = { urls: Array<string>, referer: string | null, silent: boolean, filename: string | null, headers: string | null, cookies: string | null, };
|
||||
|
||||
@@ -2,6 +2,7 @@ import { invoke as tauriInvoke } from '@tauri-apps/api/core';
|
||||
import { error as logError } from '@tauri-apps/plugin-log';
|
||||
import { listen as tauriListen, type Event, type EventCallback, type UnlistenFn } from '@tauri-apps/api/event';
|
||||
import type { DownloadCategory } from './bindings/DownloadCategory';
|
||||
import type { DownloadItem } from './bindings/DownloadItem';
|
||||
import type { DownloadProgressEvent } from './bindings/DownloadProgressEvent';
|
||||
import type { DownloadStatus } from './bindings/DownloadStatus';
|
||||
import type { ExtensionDownload } from './bindings/ExtensionDownload';
|
||||
@@ -126,6 +127,7 @@ type EventMap = {
|
||||
'download-complete': string;
|
||||
'download-failed': string;
|
||||
'extension-add-download': ExtensionDownload;
|
||||
'extension-downloads-queued': DownloadItem[];
|
||||
'deep-link-add-download': string;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user