1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-15 23:00:36 +02:00

Desktop: Improved Nextcloud API error handling

This commit is contained in:
Laurent Cozic
2019-12-18 15:32:19 +00:00
parent ce7671151c
commit 888a9ddaf4
3 changed files with 33 additions and 21 deletions

View File

@ -50,18 +50,22 @@ class SyncTargetNextcloud extends BaseSyncTarget {
return new Synchronizer(this.db(), await this.fileApi(), Setting.value('appType'));
}
async appApi() {
if (!this.appApi_) {
this.appApi_ = new JoplinServerApi({
baseUrl: () => JoplinServerApi.baseUrlFromNextcloudWebDavUrl(Setting.value('sync.5.path')),
username: () => Setting.value('sync.5.username'),
password: () => Setting.value('sync.5.password'),
});
async appApi(settings = null) {
const useCache = !settings;
this.appApi_.setLogger(this.logger());
}
if (this.appApi_ && useCache) return this.appApi_;
return this.appApi_;
const appApi = new JoplinServerApi({
baseUrl: () => JoplinServerApi.baseUrlFromNextcloudWebDavUrl(settings ? settings['sync.5.path'] : Setting.value('sync.5.path')),
username: () => settings ? settings['sync.5.username'] : Setting.value('sync.5.username'),
password: () => settings ? settings['sync.5.password'] : Setting.value('sync.5.password'),
});
appApi.setLogger(this.logger());
if (useCache) this.appApi_ = appApi;
return appApi;
}
}