Skip to content

Commit

Permalink
[Refactor] Move registerIpcHandlers call out of getInstance (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
huchenlei authored Nov 5, 2024
1 parent 4da5a5d commit 4d06e9b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ if (!gotTheLock) {
return;
}
downloadManager = DownloadManager.getInstance(mainWindow!, getModelsDirectory(basePath));
downloadManager.registerIpcHandlers();

port = await findAvailablePort(8000, 9999).catch((err) => {
log.error(`ERROR: Failed to find available port: ${err}`);
throw err;
Expand Down
3 changes: 1 addition & 2 deletions src/models/DownloadManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,11 @@ export class DownloadManager {
public static getInstance(mainWindow: BrowserWindow, modelsDirectory: string): DownloadManager {
if (!DownloadManager.instance) {
DownloadManager.instance = new DownloadManager(mainWindow, modelsDirectory);
DownloadManager.instance.registerIpcHandlers();
}
return DownloadManager.instance;
}

private registerIpcHandlers() {
public registerIpcHandlers() {
ipcMain.handle(IPC_CHANNELS.START_DOWNLOAD, (event, { url, path, filename }) =>
this.startDownload(url, path, filename)
);
Expand Down

0 comments on commit 4d06e9b

Please sign in to comment.