Skip to content

Commit

Permalink
Remove lastMessageId
Browse files Browse the repository at this point in the history
  • Loading branch information
Mati Dastugue committed Mar 6, 2020
1 parent 6548683 commit 3d6e303
Showing 1 changed file with 45 additions and 36 deletions.
81 changes: 45 additions & 36 deletions renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 +4,70 @@
// `nodeIntegration` is turned off. Use `preload.js` to
// selectively enable features needed in the rendering
// process.
const electron = require('electron')
const electron = require('electron');
//const snackbar = require('node-snackbar')
const ipcRenderer = electron.ipcRenderer
let lastMsgId = 0
let toastInstance = undefined
const iFrame = document.getElementById('iframe')
const ipcRenderer = electron.ipcRenderer;
let toastInstance = undefined;
const iFrame = document.getElementById('iframe');

window.quitAndInstall = function () {
electron.remote.autoUpdater.quitAndInstall()
}
window.quitAndInstall = function() {
electron.remote.autoUpdater.quitAndInstall();
};

ipcRenderer.on('console', (event, consoleMsg) => {
console.log(consoleMsg)
})
console.log(consoleMsg);
});

ipcRenderer.on('message', (event, data) => {
showMessage(data.msg, data.hide, data.isLinux, data.action, data.linuxUri)
})
showMessage(data.msg, data.hide, data.isLinux, data.action, data.linuxUri);
});

function showMessage(message, hide = true, isLinux = false, action = undefined, linuxUri = '') {
if(hide){
function showMessage(
message,
hide = true,
isLinux = false,
action = undefined,
linuxUri = '',
) {
if (hide) {
toastInstance = mdtoast(message, {
duration:5000
duration: 5000,
});
}else
toastInstance = mdtoast(message, {
} else
toastInstance = mdtoast(message, {
interaction: true,
interactionTimeout: isLinux ? 10000 : null,
actionText: action && isLinux ? 'DOWNLOAD' : action ? 'RESTART' : 'DISMISS',
action: function(){
action && isLinux ? downloadApp(linuxUri) : action ? window.quitAndInstall() : this.hide();
}
actionText:
action && isLinux ? 'DOWNLOAD' : action ? 'RESTART' : 'DISMISS',
action: function() {
action && isLinux
? downloadApp(linuxUri)
: action
? window.quitAndInstall()
: this.hide();
},
});
}

function downloadApp(url) {
electron.shell.openExternal(url)
toastInstance.hide()
return
electron.shell.openExternal(url);
toastInstance.hide();
return;
}

function resizeIFrameToFitContent( iFrame ) {
iFrame.width = window.innerWidth;
iFrame.height = window.innerHeight;
function resizeIFrameToFitContent(iFrame) {
iFrame.width = window.innerWidth;
iFrame.height = window.innerHeight;
}

window.addEventListener("resize", () => resizeIFrameToFitContent( iFrame ))
window.addEventListener('resize', () => resizeIFrameToFitContent(iFrame));

window.addEventListener('DOMContentLoaded', function(e) {
resizeIFrameToFitContent(iFrame);

resizeIFrameToFitContent( iFrame );

// or, to resize all iframes:
var iframes = document.querySelectorAll("iframe");
for( var i = 0; i < iframes.length; i++) {
resizeIFrameToFitContent( iframes[i] );
}
})
// or, to resize all iframes:
var iframes = document.querySelectorAll('iframe');
for (var i = 0; i < iframes.length; i++) {
resizeIFrameToFitContent(iframes[i]);
}
});

0 comments on commit 3d6e303

Please sign in to comment.