Skip to content

Commit

Permalink
Fix #395: Fixing uncaught exception in main.js on day refresh (#397)
Browse files Browse the repository at this point in the history
  • Loading branch information
araujoarthur0 authored Oct 3, 2020
1 parent 4abaed5 commit 3e786e5
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
## 1.5.6 (in development)

- Fix: [#214] Check that lunch has beginning and end, if there is lunch
- Fix: [#377] Fixed the layout which was broken when width < 768px
- Fix: Fixed behavior of calendar when moving to next/previous month when current day is in the range of 29-31.
- Fix: [#334] Improving performance of overall balance calculation and fixing balance target date after month change
- Fix: [#362] Fixed initial size of preferences window
- Fix: [#214] Check that lunch has beginning and end, if there is lunch
- Fix: [#395] Fixing uncaught exception in main.js on day refresh
- Enhancement: [#328] Swap position for overall and month balance on day view
- Enhancement: [#333] Adding start date for overall balance on preferences
- Enhancement: [#357] Adding flexible table format for month calendar with variable number of entries per day
Expand Down
13 changes: 11 additions & 2 deletions js/main-window.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ const {
getMainMenuTemplate,
getViewMenuTemplate
} = require('./menus');
let { contextMenu, mainWindow, tray } = require('./windows');
let { contextMenu, tray } = require('./windows.js');

// 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.
let mainWindow = null;

function getMainWindow() {
return mainWindow;
}

function createWindow()
{
Expand Down Expand Up @@ -123,5 +131,6 @@ function createWindow()


module.exports = {
createWindow
createWindow,
getMainWindow
};
2 changes: 0 additions & 2 deletions js/windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

// 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.
let mainWindow = null;
let waiverWindow = null;
let prefWindow = null;
let tray = null;
let contextMenu = null;

module.exports = {
mainWindow,
waiverWindow,
prefWindow,
tray,
Expand Down
13 changes: 10 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
'use strict';

const { app, ipcMain } = require('electron');
const { createWindow } = require('./js/main-window');
const { mainWindow } = require('./js/windows');
const { createWindow, getMainWindow } = require('./js/main-window');
const { notify } = require('./js/notification');

ipcMain.on('SET_WAIVER_DAY', (event, waiverDay) => {
Expand Down Expand Up @@ -32,7 +31,13 @@ function checkIdleAndNotify() {
}

function refreshOnDayChange() {
var today = new Date();
const mainWindow = getMainWindow();
if (mainWindow === null)
{
return;
}

let today = new Date();
if (today > launchDate)
{
let oldDate = launchDate.getDate();
Expand All @@ -54,6 +59,7 @@ if (!app.requestSingleInstanceLock()) {
} else {
app.on('second-instance', () => {
// Someone tried to run a second instance, we should focus our window.
const mainWindow = getMainWindow();
if (mainWindow) {
if (mainWindow.isMinimized()) {
mainWindow.restore();
Expand Down Expand Up @@ -84,6 +90,7 @@ app.on('window-all-closed', () => {
app.on('activate', () => {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
const mainWindow = getMainWindow();
if (mainWindow === null) {
createWindow();
} else {
Expand Down

0 comments on commit 3e786e5

Please sign in to comment.