Skip to content

Commit

Permalink
Added cache clearing code on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
chalkers committed Nov 23, 2016
1 parent b2fe61f commit 6f55d17
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 26 deletions.
6 changes: 3 additions & 3 deletions front-end/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ const CONSTANTS = {
pollTime: 1000
};

var isFlashing = false;
let isFlashing = false;

var last_notification = "";
let last_notification = "";

/************************
* Backend dependencies.
Expand Down Expand Up @@ -257,7 +257,7 @@ function updateProgressBar(percent, svg){
finishDot.style.opacity = 0;
}

for(var i = 0; i < percent * (bgLine.points.numberOfItems / 100); i ++) {
for(let i = 0; i < percent * (bgLine.points.numberOfItems / 100); i ++) {
if(i < bgLine.points.numberOfItems) {
const point = bgLine.points.getItem(i);
const newPoint = svg.createSVGPoint();
Expand Down
48 changes: 25 additions & 23 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,24 @@ const BrowserWindow = electron.BrowserWindow; // Module to create native browse
const checkDialout = require("./back-end/checkDialout");
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
var mainWindow = null;
let mainWindow = null;


// Quit when all windows are closed.
app.on('window-all-closed', function() {
app.on('window-all-closed', () => {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform != 'darwin') {
if (process.platform !== 'darwin') {
app.quit();
}
});

var launchApp = function() {
// load the index.html of the app.
mainWindow.loadURL('file://' + __dirname + '/front-end/index.html');

function launchApp() {
//Clears any crusty downloads/API calls
mainWindow.webContents.session.clearCache(() => {
// load the index.html of the app.
mainWindow.loadURL('file://' + __dirname + '/front-end/index.html');
});
}

function launchLinuxHelper() {
Expand All @@ -38,7 +40,7 @@ function launchLinuxHelper() {

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
app.on('ready', function() {
app.on('ready', function () {
// Create the browser window.
mainWindow = new BrowserWindow({
width: 520,
Expand All @@ -48,23 +50,23 @@ app.on('ready', function() {
'accept-first-mouse': true
});

if(process.platform === "linux") {
checkDialout(launchApp, (err) => {
if(err.message === checkDialout.ERROR_MESSAGES.USER_NOT_IN_DIALOUT) {
launchLinuxHelper();
} else {
//TODO: When another error occurs propogate the error somehow.
launchApp();
}
});
if (process.platform === "linux") {
checkDialout(launchApp, (err) => {
if (err.message === checkDialout.ERROR_MESSAGES.USER_NOT_IN_DIALOUT) {
launchLinuxHelper();
} else {
//TODO: When another error occurs propogate the error somehow.
launchApp();
}
});
} else {
launchApp();
launchApp();
}
// Open the DevTools.
// mainWindow.webContents.openDevTools();

// Emitted when the window is closed.
mainWindow.on('closed', function() {
mainWindow.on('closed', () => {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
Expand All @@ -86,17 +88,17 @@ function handleSquirrelEvent() {
const updateDotExe = path.resolve(path.join(rootAtomFolder, 'Update.exe'));
const exeName = path.basename(process.execPath);

const spawn = function(command, args) {
const spawn = function (command, args) {
let spawnedProcess, error;

try {
spawnedProcess = ChildProcess.spawn(command, args, {detached: true});
} catch (error) {}
spawnedProcess = ChildProcess.spawn(command, args, { detached: true });
} catch (error) { }

return spawnedProcess;
};

const spawnUpdate = function(args) {
const spawnUpdate = function (args) {
return spawn(updateDotExe, args);
};

Expand Down

0 comments on commit 6f55d17

Please sign in to comment.