mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Mobile: Added button to clear local sync state
This commit is contained in:
parent
349cade946
commit
6ce091f4d8
@ -19,5 +19,5 @@
|
||||
|
||||
# Required for react-native-webview
|
||||
# https://github.com/react-native-community/react-native-webview/blob/master/docs/Getting-Started.md
|
||||
# android.useAndroidX=true
|
||||
# android.enableJetifier=true
|
||||
android.useAndroidX=true
|
||||
android.enableJetifier=true
|
@ -1,5 +1,5 @@
|
||||
const React = require('react'); const Component = React.Component;
|
||||
const { Platform, TouchableOpacity, Linking, View, Switch, StyleSheet, Text, Button, ScrollView, TextInput } = require('react-native');
|
||||
const { Platform, TouchableOpacity, Linking, View, Switch, StyleSheet, Text, Button, ScrollView, TextInput, Alert } = require('react-native');
|
||||
const { connect } = require('react-redux');
|
||||
const { ScreenHeader } = require('lib/components/screen-header.js');
|
||||
const { _, setLocale } = require('lib/locale.js');
|
||||
@ -7,6 +7,7 @@ const { BaseScreenComponent } = require('lib/components/base-screen.js');
|
||||
const { Dropdown } = require('lib/components/Dropdown.js');
|
||||
const { themeStyle } = require('lib/components/global-style.js');
|
||||
const Setting = require('lib/models/Setting.js');
|
||||
const BaseItem = require('lib/models/BaseItem.js');
|
||||
const shared = require('lib/components/shared/config-shared.js');
|
||||
const SyncTargetRegistry = require('lib/SyncTargetRegistry');
|
||||
const { reg } = require('lib/registry.js');
|
||||
@ -33,6 +34,35 @@ class ConfigScreenComponent extends BaseScreenComponent {
|
||||
this.saveButton_press = () => {
|
||||
return shared.saveSettings(this);
|
||||
};
|
||||
|
||||
this.clearSyncStateButton_click = () => {
|
||||
Alert.alert(
|
||||
'',
|
||||
_('WARNING: This will clear the local synchronisation state. It means the entire data will be synced again with the sync target. DO NOT USE if you have not been advised to do so, or if you do not understand the consequences.'),
|
||||
[
|
||||
{
|
||||
text: _('Help'),
|
||||
onPress: () => {
|
||||
Linking.openURL('https://joplinapp.org/faq/#how-to-clear-local-sync-data');
|
||||
},
|
||||
},
|
||||
{
|
||||
text: _('Cancel'),
|
||||
onPress: () => {},
|
||||
style: 'cancel',
|
||||
},
|
||||
{
|
||||
text: _('OK'),
|
||||
onPress: async () => {
|
||||
const syncTarget = this.props.settings['sync.target'];
|
||||
await BaseItem.clearLocalSyncState(syncTarget);
|
||||
alert(_('The local sync data has been cleared.'));
|
||||
},
|
||||
},
|
||||
],
|
||||
{ cancelable: false },
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
UNSAFE_componentWillMount() {
|
||||
@ -273,6 +303,18 @@ class ConfigScreenComponent extends BaseScreenComponent {
|
||||
|
||||
const settingComps = shared.settingsToComponents2(this, 'mobile', settings);
|
||||
|
||||
settingComps.push(this.renderHeader('advanced', _('Advanced')));
|
||||
|
||||
settingComps.push(
|
||||
<View key="advanced_clear_sync_state" style={this.styles().settingContainer}>
|
||||
<View style={{flex:1, flexDirection: 'column'}}>
|
||||
<View style={{flex:1}}>
|
||||
<Button title={_('Clear synchronisation state')} onPress={this.clearSyncStateButton_click}/>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
|
||||
settingComps.push(this.renderHeader('moreInfo', _('More information')));
|
||||
|
||||
if (Platform.OS === 'android' && Platform.Version >= 23) {
|
||||
|
@ -694,6 +694,11 @@ class BaseItem extends BaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
static async clearLocalSyncState(syncTarget) {
|
||||
await this.db().exec('DELETE FROM sync_items WHERE sync_target = ?', [syncTarget]);
|
||||
await this.db().exec('DELETE FROM deleted_items WHERE sync_target = ?', [syncTarget]);
|
||||
}
|
||||
|
||||
static async forceSync(itemId) {
|
||||
await this.db().exec('UPDATE sync_items SET force_sync = 1 WHERE item_id = ?', [itemId]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user