1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

All: Made WebDAV options dynamics so that changing username or password doesn't require restarting the app

This commit is contained in:
Laurent Cozic 2018-03-15 17:57:11 +00:00
parent 9e0bf1acb2
commit 1532b6d159
6 changed files with 22 additions and 12 deletions

View File

@ -366,7 +366,7 @@ class NoteTextComponent extends React.Component {
webviewReady: true,
});
if (Setting.value('env') === 'dev') this.webview_.openDevTools();
// if (Setting.value('env') === 'dev') this.webview_.openDevTools();
}
webview_ref(element) {

View File

@ -73,7 +73,7 @@ app().start(bridge().processArgv()).then(() => {
if (error.fileName) msg.push(error.fileName);
if (error.lineNumber) msg.push(error.lineNumber);
if (error.stack) msg.push(error.stack);
bridge().showErrorMessageBox(msg.join('\n'));
bridge().showErrorMessageBox(msg.join('\n\n'));
}
bridge().electronApp().exit(1);

View File

@ -44,4 +44,13 @@ ObjectUtils.fieldsEqual = function(o1, o2) {
return true;
}
ObjectUtils.convertValuesToFunctions = function(o) {
const output = {};
for (let n in o) {
if (!o.hasOwnProperty(n)) continue;
output[n] = () => { return typeof o[n] === 'function' ? o[n]() : o[n]; }
}
return output;
}
module.exports = ObjectUtils;

View File

@ -38,9 +38,9 @@ class SyncTargetNextcloud extends BaseSyncTarget {
async initFileApi() {
const fileApi = await SyncTargetWebDAV.newFileApi_(SyncTargetNextcloud.id(), {
path: Setting.value('sync.5.path'),
username: Setting.value('sync.5.username'),
password: Setting.value('sync.5.password'),
path: () => Setting.value('sync.5.path'),
username: () => Setting.value('sync.5.username'),
password: () => Setting.value('sync.5.password'),
});
fileApi.setLogger(this.logger());

View File

@ -30,9 +30,9 @@ class SyncTargetWebDAV extends BaseSyncTarget {
static async newFileApi_(syncTargetId, options) {
const apiOptions = {
baseUrl: () => options.path,
username: () => options.username,
password: () => options.password,
baseUrl: () => options.path(),
username: () => options.username(),
password: () => options.password(),
};
const api = new WebDavApi(apiOptions);
@ -65,9 +65,9 @@ class SyncTargetWebDAV extends BaseSyncTarget {
async initFileApi() {
const fileApi = await SyncTargetWebDAV.newFileApi_(SyncTargetWebDAV.id(), {
path: Setting.value('sync.6.path'),
username: Setting.value('sync.6.username'),
password: Setting.value('sync.6.password'),
path: () => Setting.value('sync.6.path'),
username: () => Setting.value('sync.6.username'),
password: () => Setting.value('sync.6.password'),
});
fileApi.setLogger(this.logger());

View File

@ -1,5 +1,6 @@
const Setting = require('lib/models/Setting.js');
const SyncTargetRegistry = require('lib/SyncTargetRegistry');
const ObjectUtils = require('lib/ObjectUtils');
const { _ } = require('lib/locale.js');
const shared = {}
@ -16,7 +17,7 @@ shared.checkSyncConfig = async function(comp, settings) {
const SyncTargetClass = SyncTargetRegistry.classById(syncTargetId);
const options = Setting.subValues('sync.' + syncTargetId, settings);
comp.setState({ checkSyncConfigResult: 'checking' });
const result = await SyncTargetClass.checkConfig(options);
const result = await SyncTargetClass.checkConfig(ObjectUtils.convertValuesToFunctions(options));
comp.setState({ checkSyncConfigResult: result });
}