From 4edef577642f9ad560650409f80f14f51b012978 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Mon, 9 Oct 2017 21:29:49 +0100 Subject: [PATCH] Fixed setting initialisation issue --- CliClient/app/app-gui.js | 2 +- CliClient/app/app.js | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CliClient/app/app-gui.js b/CliClient/app/app-gui.js index ed0f0082e..fef246786 100644 --- a/CliClient/app/app-gui.js +++ b/CliClient/app/app-gui.js @@ -344,7 +344,7 @@ class AppGui { if (name === 'CTRL_C' ) { termutils.showCursor(term); term.fullscreen(false); - process.exit(); + await this.app().exit(); return; } diff --git a/CliClient/app/app.js b/CliClient/app/app.js index c3a87f92a..880acc7b9 100644 --- a/CliClient/app/app.js +++ b/CliClient/app/app.js @@ -296,6 +296,11 @@ class Application { return cmd; } + async exit(code = 0) { + await Setting.saveAll(); + process.exit(code); + } + commands() { if (this.allCommandsLoaded_) return this.commands_; @@ -462,7 +467,7 @@ class Application { this.dbLogger_.setLevel(initArgs.logLevel); if (Setting.value('env') === 'dev') { - this.dbLogger_.setLevel(Logger.LEVEL_WARN); + this.dbLogger_.setLevel(Logger.LEVEL_DEBUG); } const packageJson = require('./package.json'); @@ -470,13 +475,17 @@ class Application { this.logger_.info('Profile directory: ' + profileDir); this.database_ = new JoplinDatabase(new DatabaseDriverNode()); + //this.database_.setLogExcludedQueryTypes(['SELECT']); this.database_.setLogger(this.dbLogger_); - this.database_.setLogExcludedQueryTypes(['SELECT']); await this.database_.open({ name: profileDir + '/database.sqlite' }); reg.setDb(this.database_); BaseModel.db_ = this.database_; + this.store_ = createStore(reducer, applyMiddleware(this.generalMiddleware())); + BaseModel.dispatch = this.store().dispatch; + FoldersScreenUtils.dispatch = this.store().dispatch; + await Setting.load(); if (Setting.value('firstStart')) { @@ -497,10 +506,6 @@ class Application { if (!this.currentFolder_) this.currentFolder_ = await Folder.defaultFolder(); Setting.setValue('activeFolderId', this.currentFolder_ ? this.currentFolder_.id : ''); - this.store_ = createStore(reducer, applyMiddleware(this.generalMiddleware())); - BaseModel.dispatch = this.store().dispatch; - FoldersScreenUtils.dispatch = this.store().dispatch; - const AppGui = require('./app-gui.js'); this.gui_ = new AppGui(this, this.store()); this.gui_.setLogger(this.logger_);