mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
All: Added dev sync target and option to select it in mobile
This commit is contained in:
parent
8e5b0eadd9
commit
26bb7dc33b
@ -637,6 +637,9 @@ msgstr ""
|
||||
msgid "OneDrive"
|
||||
msgstr ""
|
||||
|
||||
msgid "OneDrive Dev (For testing only)"
|
||||
msgstr ""
|
||||
|
||||
#, javascript-format
|
||||
msgid "Unknown log level: %s"
|
||||
msgstr ""
|
||||
|
@ -692,6 +692,9 @@ msgstr "Système de fichier"
|
||||
msgid "OneDrive"
|
||||
msgstr "OneDrive"
|
||||
|
||||
msgid "OneDrive Dev (For testing only)"
|
||||
msgstr ""
|
||||
|
||||
#, javascript-format
|
||||
msgid "Unknown log level: %s"
|
||||
msgstr "Paramètre inconnu : %s"
|
||||
|
@ -637,6 +637,9 @@ msgstr ""
|
||||
msgid "OneDrive"
|
||||
msgstr ""
|
||||
|
||||
msgid "OneDrive Dev (For testing only)"
|
||||
msgstr ""
|
||||
|
||||
#, javascript-format
|
||||
msgid "Unknown log level: %s"
|
||||
msgstr ""
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -24,9 +24,11 @@ const EventEmitter = require('events');
|
||||
const SyncTargetRegistry = require('lib/SyncTargetRegistry.js');
|
||||
const SyncTargetFilesystem = require('lib/SyncTargetFilesystem.js');
|
||||
const SyncTargetOneDrive = require('lib/SyncTargetOneDrive.js');
|
||||
const SyncTargetOneDriveDev = require('lib/SyncTargetOneDriveDev.js');
|
||||
|
||||
SyncTargetRegistry.addClass(SyncTargetFilesystem);
|
||||
SyncTargetRegistry.addClass(SyncTargetOneDrive);
|
||||
SyncTargetRegistry.addClass(SyncTargetOneDriveDev);
|
||||
|
||||
class BaseApplication {
|
||||
|
||||
@ -364,6 +366,7 @@ class BaseApplication {
|
||||
if (Setting.value('firstStart')) {
|
||||
const locale = shim.detectAndSetLocale(Setting);
|
||||
reg.logger().info('First start: detected locale as ' + locale);
|
||||
if (Setting.value('env') === 'dev') Setting.setValue('sync.target', SyncTargetRegistry.nameToId('onedrive_dev'));
|
||||
Setting.setValue('firstStart', 0)
|
||||
} else {
|
||||
setLocale(Setting.value('locale'));
|
||||
|
@ -30,20 +30,28 @@ class SyncTargetOneDrive extends BaseSyncTarget {
|
||||
return this.api().auth();
|
||||
}
|
||||
|
||||
syncTargetId() {
|
||||
return SyncTargetOneDrive.id();
|
||||
}
|
||||
|
||||
oneDriveParameters() {
|
||||
return parameters().oneDrive;
|
||||
}
|
||||
|
||||
api() {
|
||||
if (this.api_) return this.api_;
|
||||
|
||||
const isPublic = Setting.value('appType') != 'cli';
|
||||
|
||||
this.api_ = new OneDriveApi(parameters().oneDrive.id, parameters().oneDrive.secret, isPublic);
|
||||
this.api_ = new OneDriveApi(this.oneDriveParameters().id, this.oneDriveParameters().secret, isPublic);
|
||||
this.api_.setLogger(this.logger());
|
||||
|
||||
this.api_.on('authRefreshed', (a) => {
|
||||
this.logger().info('Saving updated OneDrive auth.');
|
||||
Setting.setValue('sync.' + staticSelf.id() + '.auth', a ? JSON.stringify(a) : null);
|
||||
Setting.setValue('sync.' + this.syncTargetId() + '.auth', a ? JSON.stringify(a) : null);
|
||||
});
|
||||
|
||||
let auth = Setting.value('sync.' + staticSelf.id() + '.auth');
|
||||
let auth = Setting.value('sync.' + this.syncTargetId() + '.auth');
|
||||
if (auth) {
|
||||
try {
|
||||
auth = JSON.parse(auth);
|
||||
@ -62,7 +70,7 @@ class SyncTargetOneDrive extends BaseSyncTarget {
|
||||
async initFileApi() {
|
||||
const appDir = await this.api().appDirectory();
|
||||
const fileApi = new FileApi(appDir, new FileApiDriverOneDrive(this.api()));
|
||||
fileApi.setSyncTargetId(staticSelf.id());
|
||||
fileApi.setSyncTargetId(this.syncTargetId());
|
||||
fileApi.setLogger(this.logger());
|
||||
return fileApi;
|
||||
}
|
||||
@ -74,6 +82,4 @@ class SyncTargetOneDrive extends BaseSyncTarget {
|
||||
|
||||
}
|
||||
|
||||
const staticSelf = SyncTargetOneDrive;
|
||||
|
||||
module.exports = SyncTargetOneDrive;
|
37
ReactNativeClient/lib/SyncTargetOneDriveDev.js
Normal file
37
ReactNativeClient/lib/SyncTargetOneDriveDev.js
Normal file
@ -0,0 +1,37 @@
|
||||
const BaseSyncTarget = require('lib/BaseSyncTarget.js');
|
||||
const SyncTargetOneDrive = require('lib/SyncTargetOneDrive.js');
|
||||
const { _ } = require('lib/locale.js');
|
||||
const { OneDriveApi } = require('lib/onedrive-api.js');
|
||||
const { Setting } = require('lib/models/setting.js');
|
||||
const { parameters } = require('lib/parameters.js');
|
||||
const { FileApi } = require('lib/file-api.js');
|
||||
const { Synchronizer } = require('lib/synchronizer.js');
|
||||
const { FileApiDriverOneDrive } = require('lib/file-api-driver-onedrive.js');
|
||||
|
||||
class SyncTargetOneDriveDev extends SyncTargetOneDrive {
|
||||
|
||||
static id() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
static targetName() {
|
||||
return 'onedrive_dev';
|
||||
}
|
||||
|
||||
static label() {
|
||||
return _('OneDrive Dev (For testing only)');
|
||||
}
|
||||
|
||||
syncTargetId() {
|
||||
return SyncTargetOneDriveDev.id();
|
||||
}
|
||||
|
||||
oneDriveParameters() {
|
||||
return parameters('dev').oneDrive;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const staticSelf = SyncTargetOneDriveDev;
|
||||
|
||||
module.exports = SyncTargetOneDriveDev;
|
@ -16,8 +16,6 @@ class SyncTargetRegistry {
|
||||
}
|
||||
|
||||
static nameToId(name) {
|
||||
console.info(this.reg_);
|
||||
|
||||
for (let n in this.reg_) {
|
||||
if (!this.reg_.hasOwnProperty(n)) continue;
|
||||
if (this.reg_[n].name === name) return this.reg_[n].id;
|
||||
|
@ -149,7 +149,7 @@ class ConfigScreenComponent extends BaseScreenComponent {
|
||||
let settingComps = [];
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
if (key == 'sync.target') continue;
|
||||
if (key == 'sync.target' && !settings.showAdvancedOptions) continue;
|
||||
if (!Setting.isPublic(key)) continue;
|
||||
|
||||
const comp = this.settingToComponent(key, settings[key]);
|
||||
|
@ -24,9 +24,6 @@ class Setting extends BaseModel {
|
||||
'sync.2.path': { value: '', type: Setting.TYPE_STRING, public: true, appTypes: ['cli'], label: () => _('File system synchronisation target directory'), description: () => _('The path to synchronise with when file system synchronisation is enabled. See `sync.target`.') },
|
||||
'sync.3.auth': { value: '', type: Setting.TYPE_STRING, public: false },
|
||||
'sync.4.auth': { value: '', type: Setting.TYPE_STRING, public: false },
|
||||
'sync.target': { value: SyncTargetRegistry.nameToId('onedrive'), type: Setting.TYPE_INT, isEnum: true, public: true, label: () => _('Synchronisation target'), description: () => _('The target to synchonise to. If synchronising with the file system, set `sync.2.path` to specify the target directory.'), options: () => {
|
||||
return SyncTargetRegistry.idAndLabelPlainObject();
|
||||
}},
|
||||
'sync.1.context': { value: '', type: Setting.TYPE_STRING, public: false },
|
||||
'sync.2.context': { value: '', type: Setting.TYPE_STRING, public: false },
|
||||
'sync.3.context': { value: '', type: Setting.TYPE_STRING, public: false },
|
||||
@ -68,6 +65,9 @@ class Setting extends BaseModel {
|
||||
'noteVisiblePanes': { value: ['editor', 'viewer'], type: Setting.TYPE_ARRAY, public: false, appTypes: ['desktop'] },
|
||||
'autoUpdateEnabled': { value: true, type: Setting.TYPE_BOOL, public: true, appTypes: ['desktop'], label: () => _('Automatically update the application') },
|
||||
'showAdvancedOptions': { value: false, type: Setting.TYPE_BOOL, public: true, appTypes: ['mobile' ], label: () => _('Show advanced options') },
|
||||
'sync.target': { value: SyncTargetRegistry.nameToId('onedrive'), type: Setting.TYPE_INT, isEnum: true, public: true, label: () => _('Synchronisation target'), description: () => _('The target to synchonise to. If synchronising with the file system, set `sync.2.path` to specify the target directory.'), options: () => {
|
||||
return SyncTargetRegistry.idAndLabelPlainObject();
|
||||
}},
|
||||
};
|
||||
|
||||
return this.metadata_;
|
||||
|
@ -24,8 +24,9 @@ parameters_.prod = {
|
||||
},
|
||||
};
|
||||
|
||||
function parameters() {
|
||||
let output = parameters_[Setting.value('env')];
|
||||
function parameters(env = null) {
|
||||
if (env === null) env = Setting.value('env');
|
||||
let output = parameters_[env];
|
||||
if (Setting.value('isDemo')) {
|
||||
output.oneDrive = output.oneDriveDemo;
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -39,8 +39,10 @@ const { PoorManIntervals } = require('lib/poor-man-intervals.js');
|
||||
const { reducer, defaultState } = require('lib/reducer.js');
|
||||
const SyncTargetRegistry = require('lib/SyncTargetRegistry.js');
|
||||
const SyncTargetOneDrive = require('lib/SyncTargetOneDrive.js');
|
||||
const SyncTargetOneDriveDev = require('lib/SyncTargetOneDriveDev.js');
|
||||
|
||||
SyncTargetRegistry.addClass(SyncTargetOneDrive);
|
||||
SyncTargetRegistry.addClass(SyncTargetOneDriveDev);
|
||||
|
||||
const generalMiddleware = store => next => async (action) => {
|
||||
if (action.type !== 'SIDE_MENU_OPEN_PERCENT') reg.logger().info('Reducer action', action.type);
|
||||
@ -312,9 +314,12 @@ async function initialize(dispatch, backButtonHandler) {
|
||||
const locale = NativeModules.I18nManager.localeIdentifier
|
||||
if (!locale) locale = defaultLocale();
|
||||
Setting.setValue('locale', closestSupportedLocale(locale));
|
||||
if (Setting.value('env') === 'dev') Setting.setValue('sync.target', SyncTargetRegistry.nameToId('onedrive_dev'));
|
||||
Setting.setValue('firstStart', 0)
|
||||
}
|
||||
|
||||
reg.logger().info('Sync target: ' + Setting.value('sync.target'));
|
||||
|
||||
setLocale(Setting.value('locale'));
|
||||
|
||||
reg.logger().info('Loading folders...');
|
||||
|
Loading…
Reference in New Issue
Block a user