Skip to content

Commit 418cf13

Browse files
Merge branch 'auto-update'
2 parents c2c8233 + 4ebdc72 commit 418cf13

11 files changed

+2347
-571
lines changed

dev-app-update.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
owner: sethjwilliamson
2+
repo: LoRTracker
3+
provider: github
4+
updaterCacheDirName: lor-tracker-updater

graveyardRenderer.js

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ const {ipcRenderer, remote} = require('electron');
22
const createCanvas = require('./createCanvas.js');
33
const Store = require('electron-store');
44
const config = new Store();
5+
const log = require("electron-log");
6+
log.catchErrors();
57

68
ipcRenderer.on('update', (event, test) => {
79
updateGraveyard();

lor-tracker-v1.0.1.tgz

38 MB
Binary file not shown.

main.js

+41-3
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,42 @@ const data = new Store({
3535
"decks": []
3636
}
3737
});
38+
39+
const { autoUpdater } = require("electron-updater");
40+
41+
autoUpdater.on('checking-for-update', () => {
42+
sendStatusToWindow('Checking for update...', false);
43+
});
44+
autoUpdater.on('update-available', info => {
45+
sendStatusToWindow('Update available.', true);
46+
});
47+
autoUpdater.on('update-not-available', info => {
48+
sendStatusToWindow('Update not available.', false);
49+
});
50+
autoUpdater.on('error', err => {
51+
sendStatusToWindow(`Error in auto-updater: ${err.toString()}`, true);
52+
});
53+
autoUpdater.on('download-progress', progressObj => {
54+
sendStatusToWindow(
55+
`Download speed: ${progressObj.bytesPerSecond} - Downloaded ${progressObj.percent}% (${progressObj.transferred} + '/' + ${progressObj.total} + )`, false
56+
);
57+
});
58+
autoUpdater.on('update-downloaded', info => {
59+
sendStatusToWindow('Update downloaded; will install now', false);
60+
app.isQuiting = true;
61+
autoUpdater.quitAndInstall();
62+
});
63+
64+
const log = require("electron-log");
65+
log.catchErrors();
66+
67+
autoUpdater.logger = log
68+
autoUpdater.logger.transports.file.level = "info"
69+
3870
const imgPath = path.join(process.resourcesPath, 'icon.png');
3971
const nativeImage = require('electron').nativeImage
4072
let icon = nativeImage.createFromPath(imgPath)
4173

42-
4374
var trackerWindow, fullCardWindow, graveyardWindow, oppDeckWindow;
4475

4576
const gotTheLock = app.requestSingleInstanceLock()
@@ -57,7 +88,6 @@ if (!gotTheLock) {
5788
})
5889
}
5990

60-
6191
function createWindow () {
6292
const tray = new Tray(icon)
6393

@@ -346,6 +376,7 @@ function createWindow () {
346376
}
347377
});
348378

379+
autoUpdater.checkForUpdates();
349380
}
350381

351382
app.whenReady().then(createWindow)
@@ -359,8 +390,15 @@ app.on('activate', function () {
359390
if (BrowserWindow.getAllWindows().length === 0) createWindow()
360391
})
361392

362-
const axios = require('axios');
363393

394+
const sendStatusToWindow = (text, alert) => {
395+
log.info(text);
396+
if (mainWindow && alert) {
397+
mainWindow.webContents.send('message', text);
398+
}
399+
};
400+
401+
const axios = require('axios');
364402

365403
async function httpGet(theUrl)
366404
{

mainRenderer.js

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ const {ipcRenderer, remote} = require('electron');
22
const createCanvas = require('./createCanvas.js');
33
const Store = require('electron-store');
44
const data = new Store({name:"data"});
5+
const log = require("electron-log");
6+
log.catchErrors();
57

68
var games = data.get("games").sort((a,b) => (a.timePlayed < b.timePlayed) ? 1 : ((b.timePlayed < a.timePlayed) ? -1 : 0));
79
var decks = data.get("decks").sort((a,b) => (a.mostRecentPlay < b.mostRecentPlay) ? 1 : ((b.mostRecentPlay < a.mostRecentPlay) ? -1 : 0));
@@ -20,6 +22,9 @@ $(".font-loader").each(function() {
2022
this.remove();
2123
})
2224

25+
ipcRenderer.on('message', function (event, text) {
26+
alert('Message from updater: ' + text);
27+
});
2328

2429
loadMatches();
2530
loadMatch(games[0])

oppDeckRenderer.js

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ const {ipcRenderer, remote} = require('electron');
22
const createCanvas = require('./createCanvas.js');
33
const Store = require('electron-store');
44
const config = new Store();
5+
const log = require("electron-log");
6+
log.catchErrors();
57

68
ipcRenderer.on('update', (event, test) => {
79
updateOppDeck();

0 commit comments

Comments
 (0)