Skip to content

Commit 63f8d9e

Browse files
committed
Fix crash when preferences are deleted
1 parent 499bece commit 63f8d9e

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

src/js/main/User.js

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -69,29 +69,30 @@ function User(name, factory) {
6969
}.bind(this));
7070

7171
// @if NODE_ENV='development'
72-
c.log('[User] Preference model v. ' + this.preferences['model_version']);
72+
if(this.preferences) { c.log('[User] Preference model v. ' + this.preferences['model_version']); }
7373
// @endif
7474

75-
if(this.preferences['model_version'] !== app.getVersion()) {
76-
// @if NODE_ENV='development'
77-
c.log('[User] Using a different model. Latest is ' + app.getVersion());
78-
// @endif
79-
80-
dialog.showMessageBox(
81-
{
82-
type: 'info',
83-
message: 'Preference model outdated.',
84-
detail: 'Reset the preferences to use new features.',
85-
buttons: ['Reset', 'Continue Anyway'],
86-
defaultId: 0
87-
},
88-
function(buttonId) {
75+
if(this.preferences) {
76+
if(this.preferences['model_version'] !== app.getVersion()) {
77+
// @if NODE_ENV='development'
78+
c.log('[User] Using a different model. Latest is ' + app.getVersion());
79+
// @endif
8980

90-
if(buttonId == 0) UserManager.reset('Preferences', 'oryoki-preferences.json', 'factory.json');
81+
dialog.showMessageBox(
82+
{
83+
type: 'info',
84+
message: 'Preference model outdated.',
85+
detail: 'Reset the preferences to use new features.',
86+
buttons: ['Reset', 'Continue Anyway'],
87+
defaultId: 0
88+
},
89+
function(buttonId) {
9190

92-
}.bind(this)
93-
);
91+
if(buttonId == 0) UserManager.reset('Preferences', 'oryoki-preferences.json', 'factory.json');
9492

93+
}.bind(this)
94+
);
95+
}
9596
}
9697

9798
// Init conf file

0 commit comments

Comments
 (0)