Skip to content

Commit

Permalink
Fix first launch dictionary load
Browse files Browse the repository at this point in the history
  • Loading branch information
thmsbfft committed Aug 26, 2016
1 parent 6741847 commit 9c1f00e
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions src/js/main/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,10 @@ function User(name, factory) {

// Watch files for changes
fs.watchFile(this.paths.conf + '/' + 'oryoki-preferences.json', this.onPreferencesChange.bind(this));
this.onPreferencesChange();

fs.watchFile(this.paths.conf + '/' + 'search-dictionary.json', function() {
// @if NODE_ENV='development'
c.log('[User] Search dictionary has changed');
// @endif
this.searchDictionary = this.getConfFile('search-dictionary.json', this.createSearchDictionary.bind(this));

// Update accross all windows
for (var i = 0; i < Oryoki.windows.length; i++) {
Oryoki.windows[i].updateConfFiles();
}
this.onSearchDictionaryChange();

if(Oryoki.focusedWindow) {
Oryoki.focusedWindow.browser.webContents.send('log-status', {
Expand All @@ -67,6 +59,26 @@ function User(name, factory) {

}.bind(this));

// Init conf file
this.onPreferencesChange();
this.onSearchDictionaryChange();

}

User.prototype.onSearchDictionaryChange = function() {

// @if NODE_ENV='development'
c.log('[User] Search dictionary has changed');
// @endif
this.searchDictionary = this.getConfFile('search-dictionary.json', this.createSearchDictionary.bind(this));

// Update accross all windows
if(Oryoki.focusedWindow) {
for (var i = 0; i < Oryoki.windows.length; i++) {
Oryoki.windows[i].updateConfFiles();
}
}

}

User.prototype.onPreferencesChange = function() {
Expand Down

0 comments on commit 9c1f00e

Please sign in to comment.