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

Desktop, Mobile: Automatically start sync after setting the sync parameters

This commit is contained in:
Laurent Cozic
2022-04-13 12:38:09 +01:00
parent e5313a9719
commit ff066baa26
3 changed files with 28 additions and 3 deletions

View File

@@ -7,6 +7,7 @@ import bridge from '../../services/bridge';
import Setting, { AppType, SyncStartupOperation } from '@joplin/lib/models/Setting';
import control_PluginsStates from './controls/plugins/PluginsStates';
import EncryptionConfigScreen from '../EncryptionConfigScreen/EncryptionConfigScreen';
import { reg } from '@joplin/lib/registry';
const { connect } = require('react-redux');
const { themeStyle } = require('@joplin/lib/theme');
const pathUtils = require('@joplin/lib/path-utils');
@@ -26,7 +27,7 @@ class ConfigScreenComponent extends React.Component<any, any> {
constructor(props: any) {
super(props);
shared.init(this);
shared.init(this, reg);
this.state = {
selectedSectionName: 'general',

View File

@@ -41,7 +41,7 @@ class ConfigScreenComponent extends BaseScreenComponent {
this.scrollViewRef_ = React.createRef();
shared.init(this);
shared.init(this, reg);
this.checkSyncConfig_ = async () => {
// to ignore TLS erros we need to chage the global state of the app, if the check fails we need to restore the original state

View File

@@ -3,15 +3,35 @@ const SyncTargetRegistry = require('../../SyncTargetRegistry').default;
const ObjectUtils = require('../../ObjectUtils');
const { _ } = require('../../locale');
const { createSelector } = require('reselect');
const Logger = require('@joplin/lib/Logger').default;
const logger = Logger.create('config/lib');
const shared = {};
shared.init = function(comp) {
shared.onSettingsSaved = () => {};
shared.init = function(comp, reg) {
if (!comp.state) comp.state = {};
comp.state.checkSyncConfigResult = null;
comp.state.settings = {};
comp.state.changedSettingKeys = [];
comp.state.showAdvancedSettings = false;
shared.onSettingsSaved = (event) => {
const savedSettingKeys = event.savedSettingKeys;
// After changing the sync settings we immediately trigger a sync
// operation. This will ensure that the client gets the sync info as
// early as possible, in particular the encryption state (encryption
// keys, whether it's enabled, etc.). This should prevent situations
// where the user tried to setup E2EE on the client even though it's
// already been done on another client.
if (savedSettingKeys.find(s => s.startsWith('sync.'))) {
logger.info('Sync settings have been changed - scheduling a sync');
void reg.scheduleSync();
}
};
};
shared.advancedSettingsButton_click = (comp) => {
@@ -79,6 +99,8 @@ shared.scheduleSaveSettings = function(comp) {
};
shared.saveSettings = function(comp) {
const savedSettingKeys = comp.state.changedSettingKeys.slice();
for (const key in comp.state.settings) {
if (!comp.state.settings.hasOwnProperty(key)) continue;
if (comp.state.changedSettingKeys.indexOf(key) < 0) continue;
@@ -86,6 +108,8 @@ shared.saveSettings = function(comp) {
}
comp.setState({ changedSettingKeys: [] });
shared.onSettingsSaved({ savedSettingKeys });
};
shared.settingsToComponents = function(comp, device, settings) {