Skip to content

Commit d9b9bf1

Browse files
committed
Loading app with width/height based on view
1 parent f69547c commit d9b9bf1

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

js/classes/Calendar.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const {
1010
sumTime,
1111
validateTime
1212
} = require('../time-math.js');
13-
const { showDay, switchCalendarView } = require('../user-preferences.js');
13+
const { getDefaultWidthHeight, showDay, switchCalendarView } = require('../user-preferences.js');
1414
const { getDateStr, getMonthLength } = require('../date-aux.js');
1515
const {
1616
formatDayId,
@@ -25,9 +25,10 @@ const waivedWorkdays = new Store({name: 'waived-workdays'});
2525
class CalendarFactory {
2626
static getInstance(preferences, calendar = undefined) {
2727
let view = preferences.view;
28+
let widthHeight = getDefaultWidthHeight();
2829
if (view === 'day') {
2930
if (calendar === undefined || calendar.constructor.name !== 'DayCalendar') {
30-
ipcRenderer.send('RESIZE_MAIN_WINDOW', 500, 500);
31+
ipcRenderer.send('RESIZE_MAIN_WINDOW', widthHeight.width, widthHeight.height);
3132
return new DayCalendar(preferences);
3233
} else {
3334
calendar.updatePreferences(preferences);
@@ -37,7 +38,7 @@ class CalendarFactory {
3738
} else if (view === 'month') {
3839
if (calendar === undefined || calendar.constructor.name !== 'Calendar') {
3940
if (calendar !== undefined && calendar.constructor.name !== 'Calendar') {
40-
ipcRenderer.send('RESIZE_MAIN_WINDOW', 1010, 800);
41+
ipcRenderer.send('RESIZE_MAIN_WINDOW', widthHeight.width, widthHeight.height);
4142
}
4243
return new Calendar(preferences);
4344
} else {

js/user-preferences.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,19 @@ function switchCalendarView() {
186186
return preferences;
187187
}
188188

189+
function getDefaultWidthHeight() {
190+
let preferences = getLoadedOrDerivedUserPreferences();
191+
if (preferences['view'] === 'month') {
192+
return { width: 1010, height: 800 };
193+
}
194+
else {
195+
return { width: 500, height: 500 };
196+
}
197+
}
198+
189199
module.exports = {
190200
defaultPreferences,
201+
getDefaultWidthHeight,
191202
getUserPreferences: getLoadedOrDerivedUserPreferences,
192203
savePreferences,
193204
showDay,

main.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const isOnline = require('is-online');
66
const { importDatabaseFromFile, exportDatabaseToFile } = require('./js/import-export.js');
77
const { notify } = require('./js/notification');
88
const { getDateStr } = require('./js/date-aux.js');
9-
const { getUserPreferences, savePreferences } = require('./js/user-preferences.js');
9+
const { getDefaultWidthHeight, getUserPreferences, savePreferences } = require('./js/user-preferences.js');
1010
const os = require('os');
1111

1212
let savedPreferences = null;
@@ -391,9 +391,11 @@ function createWindow() {
391391
}
392392
]);
393393

394+
let widthHeight = getDefaultWidthHeight();
395+
394396
win = new BrowserWindow({
395-
width: 1000,
396-
height: 1000,
397+
width: widthHeight.width,
398+
height: widthHeight.height,
397399
minWidth: 450,
398400
useContentSize: true,
399401
zoomToPageWidth: true, //MacOS only

0 commit comments

Comments
 (0)