Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add downloads from first instance arguments #94

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions src/main/Application.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,15 @@ class Application {
* Because services are designed for communicating with the windows
*/
this.serviceContainer = ServiceContainer.getContainer();

/**
* Handle any argments sent to first instance
* We wait for the page to load to make sure new downloads aren't mistaken
* as cached and cause the restore window to show unintentionally
*/
this.mainWindow.webContents.on('did-finish-load', () => {
this.#handleArguments(process.argv);
});
}

onActivate() {
Expand All @@ -271,12 +280,8 @@ class Application {
}
}

onSecondInstance(event, commandLine, workingDirectory) {
WindowManager.getWindow('app').webContents.send('debug:log', process.argv);
WindowManager.getWindow('app').webContents.send('debug:log', event);
WindowManager.getWindow('app').webContents.send('debug:log', commandLine);
WindowManager.getWindow('app').webContents.send('debug:log', workingDirectory);

// Helper function to parse urls and send them to download service
#handleArguments(commandLine) {
commandLine.forEach(line => {
if (/^pixiv-omina:/.test(line)) {
ServiceContainer.getService('debug').sendStatus(`Get line data: ${line}`);
Expand All @@ -290,6 +295,16 @@ class Application {
});
}
});
}


onSecondInstance(event, commandLine, workingDirectory) {
WindowManager.getWindow('app').webContents.send('debug:log', process.argv);
WindowManager.getWindow('app').webContents.send('debug:log', event);
WindowManager.getWindow('app').webContents.send('debug:log', commandLine);
WindowManager.getWindow('app').webContents.send('debug:log', workingDirectory);

this.#handleArguments(commandLine);

if (this.mainWindow !== null) {
if (this.mainWindow.isMinimized()) {
Expand Down