mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
All: Fixes #536: Allow changing sync target file path
This commit is contained in:
parent
ed70cf571c
commit
429f2d5aab
@ -1,4 +1,5 @@
|
|||||||
const Setting = require('lib/models/Setting');
|
const Setting = require('lib/models/Setting');
|
||||||
|
const { reg } = require('lib/registry.js');
|
||||||
|
|
||||||
const reduxSharedMiddleware = function(store, next, action) {
|
const reduxSharedMiddleware = function(store, next, action) {
|
||||||
const newState = store.getState();
|
const newState = store.getState();
|
||||||
@ -6,6 +7,11 @@ const reduxSharedMiddleware = function(store, next, action) {
|
|||||||
if (action.type == 'FOLDER_SET_COLLAPSED' || action.type == 'FOLDER_TOGGLE') {
|
if (action.type == 'FOLDER_SET_COLLAPSED' || action.type == 'FOLDER_TOGGLE') {
|
||||||
Setting.setValue('collapsedFolderIds', newState.collapsedFolderIds);
|
Setting.setValue('collapsedFolderIds', newState.collapsedFolderIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (action.type === 'SETTING_UPDATE_ONE' && !!action.key.match(/^sync\.\d+\.path$/)) {
|
||||||
|
reg.resetSyncTarget();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = reduxSharedMiddleware;
|
module.exports = reduxSharedMiddleware;
|
@ -51,6 +51,10 @@ class FileApi {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
baseDir() {
|
||||||
|
return this.baseDir_;
|
||||||
|
}
|
||||||
|
|
||||||
tempDirName() {
|
tempDirName() {
|
||||||
if (this.tempDirName_ === null) throw Error('Temp dir not set!');
|
if (this.tempDirName_ === null) throw Error('Temp dir not set!');
|
||||||
return this.tempDirName_;
|
return this.tempDirName_;
|
||||||
@ -88,7 +92,7 @@ class FileApi {
|
|||||||
|
|
||||||
fullPath_(path) {
|
fullPath_(path) {
|
||||||
let output = [];
|
let output = [];
|
||||||
if (this.baseDir_) output.push(this.baseDir_);
|
if (this.baseDir()) output.push(this.baseDir());
|
||||||
if (path) output.push(path);
|
if (path) output.push(path);
|
||||||
return output.join('/');
|
return output.join('/');
|
||||||
}
|
}
|
||||||
@ -99,9 +103,9 @@ class FileApi {
|
|||||||
if (!('includeHidden' in options)) options.includeHidden = false;
|
if (!('includeHidden' in options)) options.includeHidden = false;
|
||||||
if (!('context' in options)) options.context = null;
|
if (!('context' in options)) options.context = null;
|
||||||
|
|
||||||
this.logger().debug('list ' + this.baseDir_);
|
this.logger().debug('list ' + this.baseDir());
|
||||||
|
|
||||||
const result = await tryAndRepeat(() => this.driver_.list(this.baseDir_, options), this.requestRepeatCount());
|
const result = await tryAndRepeat(() => this.driver_.list(this.baseDir(), options), this.requestRepeatCount());
|
||||||
|
|
||||||
if (!options.includeHidden) {
|
if (!options.includeHidden) {
|
||||||
let temp = [];
|
let temp = [];
|
||||||
@ -112,17 +116,6 @@ class FileApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
// return this.driver_.list(this.baseDir_, options).then((result) => {
|
|
||||||
// if (!options.includeHidden) {
|
|
||||||
// let temp = [];
|
|
||||||
// for (let i = 0; i < result.items.length; i++) {
|
|
||||||
// if (!isHidden(result.items[i].path)) temp.push(result.items[i]);
|
|
||||||
// }
|
|
||||||
// result.items = temp;
|
|
||||||
// }
|
|
||||||
// return result;
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprectated
|
// Deprectated
|
||||||
@ -187,7 +180,7 @@ class FileApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
clearRoot() {
|
clearRoot() {
|
||||||
return tryAndRepeat(() => this.driver_.clearRoot(this.baseDir_), this.requestRepeatCount());
|
return tryAndRepeat(() => this.driver_.clearRoot(this.baseDir()), this.requestRepeatCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
delta(path, options = null) {
|
delta(path, options = null) {
|
||||||
|
@ -30,6 +30,11 @@ reg.showErrorMessageBox = (message) => {
|
|||||||
reg.showErrorMessageBoxHandler_(message);
|
reg.showErrorMessageBoxHandler_(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reg.resetSyncTarget = (syncTargetId = null) => {
|
||||||
|
if (syncTargetId === null) syncTargetId = Setting.value('sync.target');
|
||||||
|
delete reg.syncTargets_[syncTargetId];
|
||||||
|
}
|
||||||
|
|
||||||
reg.syncTarget = (syncTargetId = null) => {
|
reg.syncTarget = (syncTargetId = null) => {
|
||||||
if (syncTargetId === null) syncTargetId = Setting.value('sync.target');
|
if (syncTargetId === null) syncTargetId = Setting.value('sync.target');
|
||||||
if (reg.syncTargets_[syncTargetId]) return reg.syncTargets_[syncTargetId];
|
if (reg.syncTargets_[syncTargetId]) return reg.syncTargets_[syncTargetId];
|
||||||
|
Loading…
Reference in New Issue
Block a user