Skip to content

Commit

Permalink
Display release notes via electron-builder auto-update
Browse files Browse the repository at this point in the history
  • Loading branch information
minter committed Sep 10, 2021
1 parent 78e60a8 commit 3344a3e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ const store = new Store({
const { autoUpdater } = require("electron-updater")
autoUpdater.logger = require("electron-log")
autoUpdater.logger.transports.file.level = "info"
// import { autoUpdater } from "electron-updater"
autoUpdater.checkForUpdatesAndNotify()

let mainWindow;

Expand Down Expand Up @@ -77,8 +75,14 @@ const createWindow = () => {
store.set('browser_height', newBounds.height);
});

mainWindow.on('ready-to-show', () => {
autoUpdater.checkForUpdatesAndNotify();
});

};



// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
Expand Down Expand Up @@ -425,6 +429,13 @@ if (process.platform == 'darwin') {
menu = Menu.buildFromTemplate(application_menu);
Menu.setApplicationMenu(menu);

autoUpdater.on('update-available', (updateInfo) => {
console.log(`Triggering update-available action with info ${updateInfo.releaseNotes}`);
mainWindow.webContents.send('display_release_notes', updateInfo.releaseName, `<h1>Version ${updateInfo.releaseName}</h1>` + updateInfo.releaseNotes);
console.log(`display_release_notes call done`);
});


function loadHotkeysFile() {
var fkey_mapping = [];
console.log("Loading hotkeys file");
Expand Down
1 change: 1 addition & 0 deletions src/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ ipcRenderer.on("close_all_tabs", function (event) {
});

ipcRenderer.on('display_release_notes', function(event, releaseName, releaseNotes) {
console.log(`Attempting to display #newReleaseModal for ${releaseName}`);
$('#newReleaseModal .modal-title').html(`Downloaded New Version: ${releaseName}`);
$('#newReleaseModal .modal-body').html(releaseNotes);
$('#newReleaseModal').modal();
Expand Down

0 comments on commit 3344a3e

Please sign in to comment.