Skip to content

Commit

Permalink
[DDW-691] Add more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
tomislavhoracek committed Oct 14, 2021
1 parent ae8ad8b commit 7321112
Showing 1 changed file with 36 additions and 25 deletions.
61 changes: 36 additions & 25 deletions source/main/index.js
Expand Up @@ -57,6 +57,7 @@ import {
// Global references to windows to prevent them from being garbage collected
let mainWindow: BrowserWindow;
let cardanoNode: ?CardanoNode;
let deeplinkingUrl;

const {
isDev,
Expand Down Expand Up @@ -164,6 +165,8 @@ const onAppReady = async () => {
);
saveWindowBoundsOnSizeAndPositionChange(mainWindow, requestElectronStore);

logger.info('[Custom-Protocol] deeplinkingUrl ON READY: ', { deeplinkingUrl });

const onCheckDiskSpace = ({
isNotEnoughDiskSpace,
}: CheckDiskSpaceResponse) => {
Expand Down Expand Up @@ -368,34 +371,42 @@ if (process.platform === 'win32') {
isDefaultProtocolClientSet,
});
}
app.on('open-url', (event, url) => {
event.preventDefault();
logger.info('[Custom-Protocol] TRY: ', {
url,
});
// Check
const isDefaultProtocolClientSet = app.isDefaultProtocolClient('web+cardano');
logger.info('[Custom-Protocol] ON READY (open-url) isDefaultProtocolClient: ', {
isDefaultProtocolClientSet,
processArgv: process.argv,
});
logger.info('[Custom-Protocol] ON READY (open-url) Open params', {
event,
url,
});
// mainWindow.focus(); // TODO: Window is not initialized - Remove this
/* try {
handleCustomProtocol(url, mainWindow);
} catch (error) {
logger.info('[Custom-Protocol] ON READY (open-url) Open handler error: ', error);
throw error;
} */
});

if (!app.isDefaultProtocolClient('web+cardano')) {
logEverywhere('set default protocol')
// Define custom protocol handler. Deep linking works on packaged versions of the application!
app.setAsDefaultProtocolClient('web+cardano')
}

app.on('will-finish-launching', function() {
// Protocol handler for osx
app.on('open-url', function(event, url) {
event.preventDefault()
deeplinkingUrl = url
logEverywhere('open-url# ' + deeplinkingUrl)
})
})

// Protocol handler for osx
app.on('open-url', function(event, url) {
event.preventDefault()
deeplinkingUrl = url
logEverywhere('open-url-2# ' + deeplinkingUrl)
})

// Log both at dev console and at running node console instance
logEverywhere = (s) => {
logger.info('[Custom-Protocol] logEverywhere: ', { s });
console.log(s)
if (mainWindow && mainWindow.webContents) {
mainWindow.webContents.executeJavaScript(`console.log("${s}")`)
}
}

if (!isSingleInstance) {
app.quit();
} else {
app.on('will-finish-launching' , () => {
/* app.on('will-finish-launching' , () => {
logger.info('[Custom-Protocol] will-finish-launching');
app.on('open-url', (event, url) => {
event.preventDefault();
Expand All @@ -414,7 +425,7 @@ if (!isSingleInstance) {
});
}
});
});
}); */
app.on('second-instance', () => {
if (mainWindow) {
if (mainWindow.isMinimized()) mainWindow.restore();
Expand Down

0 comments on commit 7321112

Please sign in to comment.