mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-09-12 17:16:20 -07:00
fix(anime): harden browser playback and modal lifecycle
- Abort upstream fetches when clients disconnect - Validate embedded modal readiness before opening - Centralize browser IPC and window lifecycle
This commit is contained in:
@@ -104,7 +104,7 @@ export function registerAnimeBrowserIpcHandlers(deps: AnimeBrowserIpcDeps): void
|
||||
runtime.getPreferences(String(sourceId)),
|
||||
);
|
||||
handle(channels.animeBrowserSetPreference, (_event, sourceId, key, value) =>
|
||||
runtime.setPreference(String(sourceId), String(key), value as string | string[] | boolean),
|
||||
runtime.setPreference(String(sourceId), String(key), toPreferenceValue(value)),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -169,6 +169,15 @@ function toOptionalId(value: unknown): string | undefined {
|
||||
return typeof value === 'string' && value.length > 0 ? value : undefined;
|
||||
}
|
||||
|
||||
/** Keep preference values within the bridge schema's supported scalar and list types. */
|
||||
function toPreferenceValue(value: unknown): string | string[] | boolean {
|
||||
if (typeof value === 'string' || typeof value === 'boolean') return value;
|
||||
if (Array.isArray(value)) {
|
||||
return value.filter((entry): entry is string => typeof entry === 'string');
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/** Bridge pages are 1-based; anything unusable falls back to the first page. */
|
||||
function toPage(value: unknown): number {
|
||||
const page = Number(value);
|
||||
|
||||
Reference in New Issue
Block a user