1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-26 22:41:17 +02:00

Desktop: Add synchronization tools to clear local sync state or data

This commit is contained in:
Laurent Cozic
2021-05-03 12:55:38 +02:00
parent da4c61653f
commit a6caa357c8
14 changed files with 229 additions and 65 deletions

View File

@@ -82,6 +82,12 @@ export interface SettingSection {
source?: SettingSectionSource;
}
export enum SyncStartupOperation {
None = 0,
ClearLocalSyncState = 1,
ClearLocalData = 2,
}
interface SettingSections {
[key: string]: SettingSection;
}
@@ -284,6 +290,12 @@ class Setting extends BaseModel {
public: false,
},
'sync.startupOperation': {
value: SyncStartupOperation.None,
type: SettingItemType.Int,
public: false,
},
'sync.2.path': {
value: '',
type: SettingItemType.String,
@@ -925,6 +937,29 @@ class Setting extends BaseModel {
description: () => 'CSS file support is provided for your convenience, but they are advanced settings, and styles you define may break from one version to the next. If you want to use them, please know that it might require regular development work from you to keep them working. The Joplin team cannot make a commitment to keep the application HTML structure stable.',
},
'sync.clearLocalSyncStateButton': {
value: null,
type: SettingItemType.Button,
public: true,
appTypes: ['desktop'],
label: () => _('Re-upload local data to sync target'),
section: 'sync',
advanced: true,
description: () => 'If the data on the sync target is incorrect or empty, you can use this button to force a re-upload of your data to the sync target. Application will have to be restarted',
},
'sync.clearLocalDataButton': {
value: null,
type: SettingItemType.Button,
public: true,
appTypes: ['desktop'],
label: () => _('Delete local data and re-download from sync target'),
section: 'sync',
advanced: true,
description: () => 'If the data on the sync target is correct but your local data is not, you can use this button to clear your local data and force re-downloading everything from the sync target. As your local data will be deleted first, it is recommended to export your data as JEX first. Application will have to be restarted',
},
autoUpdateEnabled: { value: false, type: SettingItemType.Bool, storage: SettingStorage.File, section: 'application', public: platform !== 'linux', appTypes: ['desktop'], label: () => _('Automatically update the application') },
'autoUpdate.includePreReleases': { value: false, type: SettingItemType.Bool, section: 'application', storage: SettingStorage.File, public: true, appTypes: ['desktop'], label: () => _('Get pre-releases when checking for updates'), description: () => _('See the pre-release page for more details: %s', 'https://joplinapp.org/prereleases') },
'clipperServer.autoStart': { value: false, type: SettingItemType.Bool, storage: SettingStorage.File, public: false },
@@ -1194,7 +1229,13 @@ class Setting extends BaseModel {
return output;
}
static keyExists(key: string) {
// Resets the key to its default value.
public static resetKey(key: string) {
const md = this.settingMetadata(key);
this.setValue(key, md.value);
}
public static keyExists(key: string) {
return key in this.metadata();
}
@@ -1343,7 +1384,7 @@ class Setting extends BaseModel {
this.constants_[key] = value;
}
static setValue(key: string, value: any) {
public static setValue(key: string, value: any) {
if (!this.cache_) throw new Error('Settings have not been initialized!');
value = this.formatValue(key, value);
@@ -1585,7 +1626,7 @@ class Setting extends BaseModel {
return output;
}
static async saveAll() {
public static async saveAll() {
if (Setting.autoSaveEnabled && !this.saveTimeoutId_) return Promise.resolve();
this.logger().debug('Saving settings...');