Skip to content

Commit 74b1198

Browse files
authored
Merge pull request #151 from Accedia/feat/magic-button-support-logic
Feat/magic button support logic
2 parents 04b2569 + de24a33 commit 74b1198

File tree

5 files changed

+959
-481
lines changed

5 files changed

+959
-481
lines changed

electron-app/src/main.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ResponseData } from './interfaces/ResponseData';
2-
import { app, globalShortcut, ipcMain } from 'electron';
2+
import { app, globalShortcut, ipcMain, shell } from 'electron';
33
import WindowManager from './utils/window_manager';
44
import importer from './utils/importer';
55
import { MESSAGE } from './constants/messages';
@@ -59,6 +59,11 @@ class Main {
5959
// locally we enter here though
6060
app.on('second-instance', async (e, argv) => {
6161
const url = getCustomProtocolUrl(argv);
62+
if (argv.some((url) => url.includes('openVBS'))) {
63+
shell.openPath('C:\\FIT.vbs');
64+
app.quit();
65+
return;
66+
}
6267
this.finalUrl = url;
6368
if (this.windowManager.mainWindow) {
6469
/**
@@ -74,7 +79,6 @@ class Main {
7479
log.debug('It seems we need this');
7580
await this.windowManager.createMainWindow();
7681
}
77-
7882
if (url) {
7983
// ? Is this snooze necessary, check if it causes problems
8084
// await snooze(1500);
@@ -84,14 +88,13 @@ class Main {
8488
}
8589
};
8690

87-
8891
private stopMitchell = async () => {
8992
log.info('In stop mitchell function');
9093
// In dev we're not getting the finalUrl for some reason
9194
log.info('Final Protocol URL:', this.finalUrl);
92-
log.info('Final automationIdToFinishRPA', this.automationIdToFinishRPA)
93-
await mitchell_importer.abort(this.automationIdToFinishRPA, this.finalUrl)
94-
app.quit()
95+
log.info('Final automationIdToFinishRPA', this.automationIdToFinishRPA);
96+
await mitchell_importer.abort(this.automationIdToFinishRPA, this.finalUrl);
97+
app.quit();
9598
};
9699
private registerMainListeners = () => {
97100
ipcMain.on(MESSAGE.STOP_IMPORTER, this.stopMitchell);

electron-app/src/utils/window_manager.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { isAppDev, isDev } from './is_dev';
2-
import { app, BrowserWindow, screen } from 'electron';
2+
import { app, BrowserWindow, screen, shell } from 'electron';
33
import * as path from 'path';
44
import { getCustomProtocolUrl } from './get_custom_protocol_url';
55
import { fetchDataAndStartImporter, store } from '../main';
@@ -55,15 +55,14 @@ class WindowManager {
5555
if (isDev()) {
5656
this.loadingWindow.loadURL(`${this.devUrl}#${this.paths.loading}`);
5757
} else {
58-
5958
this.loadingWindow.loadFile(this.prodUrl, {
6059
hash: this.paths.loading,
6160
});
6261
}
6362
};
6463

6564
public startLoading = (): void => {
66-
console.log("starting loading");
65+
console.log('starting loading');
6766
this.loadingWindow = new BrowserWindow(WINDOW_CONFIG.loading);
6867
this.loadLoadingWindowContent();
6968
this.loadingWindow.once('show', async () => {
@@ -92,9 +91,13 @@ class WindowManager {
9291
this.loadingWindow.on('ready-to-show', this.loadingWindow.show);
9392
};
9493

95-
9694
public startApp = async (): Promise<void> => {
9795
await this.createMainWindow();
96+
if (process && process.argv.some((url) => url.includes('openVBS'))) {
97+
shell.openPath('C:\\FIT.vbs');
98+
app.quit();
99+
return;
100+
}
98101
log.info('loading has started this is on show');
99102
const storedUrl = store.get('url') as string | null;
100103
log.info('storedUrl at line 70,', storedUrl);
@@ -118,10 +121,10 @@ class WindowManager {
118121
public createMainWindow = (): Promise<void> => {
119122
return new Promise<void>((resolve, reject) => {
120123
this.mainWindow = new BrowserWindow(WINDOW_CONFIG.main);
121-
log.info('In create main window function')
124+
log.info('In create main window function');
122125
this.createBlockOverlayWindow();
123126
this.mainWindow.once('ready-to-show', () => {
124-
log.info('in main window .once ready-to-show')
127+
log.info('in main window .once ready-to-show');
125128
this.mainWindow.show();
126129
importer.setProgressBrowserWindow(this.mainWindow);
127130
//We set also for the mitchell importer a browser window
@@ -132,7 +135,7 @@ class WindowManager {
132135
resolve();
133136
});
134137
this.mainWindow.webContents.on('did-fail-load', (event, errorCode, errorDescription) => {
135-
log.info('Failed to load window')
138+
log.info('Failed to load window');
136139
reject(`Failed to load window: ${errorDescription}`);
137140
});
138141
this.mainWindow.on('close', () => {
@@ -146,7 +149,6 @@ class WindowManager {
146149
} else {
147150
this.mainWindow.loadFile(this.prodUrl);
148151
}
149-
150152
});
151153
};
152154

0 commit comments

Comments
 (0)