feat(learning): replace courses with project catalog
This commit is contained in:
@@ -57,12 +57,6 @@ const UNIFIED_CHANNELS = new Set<string>([
|
||||
'update:cancelAutoInstall',
|
||||
]);
|
||||
|
||||
const ALLOWED_EVENT_CHANNELS = new Set([
|
||||
'learning:runtime-event',
|
||||
] as const);
|
||||
|
||||
export type AllowedIpcEventChannel = 'learning:runtime-event';
|
||||
|
||||
function toUnifiedRequest(channel: string, args: unknown[]): UnifiedRequest {
|
||||
const splitIndex = channel.indexOf(':');
|
||||
return {
|
||||
@@ -118,31 +112,6 @@ export async function invokeIpc<T>(channel: string, ...args: unknown[]): Promise
|
||||
return invokeApi<T>(channel, ...args);
|
||||
}
|
||||
|
||||
export function subscribeIpcEvent(
|
||||
channel: AllowedIpcEventChannel,
|
||||
listener: (payload: unknown) => void,
|
||||
): () => void {
|
||||
if (!ALLOWED_EVENT_CHANNELS.has(channel)) {
|
||||
throw new AppError('PERMISSION', 'IPC event channel is not allowed', {
|
||||
transport: 'ipc',
|
||||
channel,
|
||||
source: 'renderer-event-subscription',
|
||||
});
|
||||
}
|
||||
|
||||
const unsubscribe = window.electron.ipcRenderer.on(channel, listener);
|
||||
let active = true;
|
||||
return () => {
|
||||
if (!active) return;
|
||||
active = false;
|
||||
if (typeof unsubscribe === 'function') {
|
||||
unsubscribe();
|
||||
return;
|
||||
}
|
||||
window.electron.ipcRenderer.off(channel, listener);
|
||||
};
|
||||
}
|
||||
|
||||
export async function invokeIpcWithRetry<T>(
|
||||
channel: string,
|
||||
args: unknown[] = [],
|
||||
|
||||
Reference in New Issue
Block a user