#1029: fixed syncing files by timeout when there are no changes

This commit is contained in:
antelle 2020-03-15 18:40:37 +01:00
parent 3d3864d535
commit fb34f8890f
3 changed files with 16 additions and 17 deletions

View File

@ -1,5 +1,4 @@
const Timeouts = {
AutoSync: 30 * 1000 * 60,
CopyTip: 1500,
AutoHideHint: 3000,
FileChangeSync: 3000,

View File

@ -64,6 +64,8 @@ class AppView extends View {
this.listenTo(this.model.settings, 'change:theme', this.setTheme);
this.listenTo(this.model.settings, 'change:locale', this.setLocale);
this.listenTo(this.model.settings, 'change:fontSize', this.setFontSize);
this.listenTo(this.model.settings, 'change:autoSaveInterval', this.setupAutoSave);
this.listenTo(this.model.settings, 'change:autoSave', this.setupAutoSave);
this.listenTo(this.model.files, 'change', this.fileListUpdated);
this.listenTo(Events, 'select-all', this.selectAll);
@ -87,7 +89,6 @@ class AppView extends View {
this.listenTo(Events, 'app-minimized', this.appMinimized);
this.listenTo(Events, 'show-context-menu', this.showContextMenu);
this.listenTo(Events, 'second-instance', this.showSingleInstanceAlert);
this.listenTo(Events, 'file-modified', this.handleAutoSaveTimer);
this.listenTo(Events, 'enter-full-screen', this.enterFullScreen);
this.listenTo(Events, 'leave-full-screen', this.leaveFullScreen);
this.listenTo(Events, 'import-csv-requested', this.showImportCsv);
@ -108,10 +109,9 @@ class AppView extends View {
);
}
setInterval(this.syncAllByTimer.bind(this), Timeouts.AutoSync);
this.setWindowClass();
this.fixClicksInEdge();
this.setupAutoSave();
}
setWindowClass() {
@ -524,19 +524,6 @@ class AppView extends View {
}
}
handleAutoSaveTimer() {
if (this.model.settings.autoSaveInterval !== 0) {
// trigger periodical auto save
if (this.autoSaveTimeoutId) {
clearTimeout(this.autoSaveTimeoutId);
}
this.autoSaveTimeoutId = setTimeout(
this.saveAll.bind(this),
this.model.settings.autoSaveInterval * 1000 * 60
);
}
}
saveAndLock(complete) {
let pendingCallbacks = 0;
const errorFiles = [];
@ -610,6 +597,18 @@ class AppView extends View {
}
}
setupAutoSave() {
if (this.autoSaveTimer) {
clearInterval(this.autoSaveTimer);
}
if (this.model.settings.autoSave && this.model.settings.autoSaveInterval) {
this.autoSaveTimer = setInterval(
this.syncAllByTimer.bind(this),
this.model.settings.autoSaveInterval * 1000 * 60
);
}
}
remoteKeyChanged(e) {
this.showKeyChange(e.file, { remote: true });
}

View File

@ -11,6 +11,7 @@ Release notes
`+` #766: setting for no/unlimited history
`+` #411: option to automatically use group icon for new entries
`+` #615: translated shortcut modifier keys
`*` #1029: fixed syncing files by timeout when there are no changes
`-` fix #1396: fixed hyperlinks in notes
`-` fix #1323: version in the About dialog
`-` fix #734: OTP secrets with spaces