option to auto-save on file change, fix #1364

This commit is contained in:
antelle 2021-05-06 20:13:58 +02:00
parent c96bcad32d
commit 7e030320f5
No known key found for this signature in database
GPG Key ID: 63C9777AAB7C563C
8 changed files with 15 additions and 6 deletions

View File

@ -9,7 +9,7 @@ const DefaultAppSettings = {
autoUpdate: 'install', // auto-update options: "install", "check", ""
clipboardSeconds: 0, // number of seconds after which the clipboard will be cleared
autoSave: true, // auto-save open files
autoSaveInterval: 0, // interval between performing automatic sync, minutes
autoSaveInterval: 0, // interval between performing automatic sync, minutes, -1: on every change
rememberKeyFiles: 'path', // remember keyfiles selected on the Open screen
idleMinutes: 15, // app lock timeout after inactivity, minutes
minimizeOnClose: false, // minimise the app instead of closing

View File

@ -437,6 +437,7 @@
"setGenAutoSyncOnClose": "Automatically save and sync on close",
"setGenAutoSyncTimer": "Automatically save and sync periodically",
"setGenAutoSyncTimerOff": "Disabled",
"setGenAutoSyncTimerOnChange": "On every change",
"setGenAutoSyncTimerInterval": "Every {} minute(s)",
"setGenRememberKeyFiles": "Remember key files",
"setGenNoRememberKeyFiles": "Don't remember",

View File

@ -180,8 +180,15 @@ class AppModel {
this.refresh();
file.on('reload', this.reloadFile.bind(this));
file.on('change', () => Events.emit('file-changed', file));
file.on('change', () => {
Events.emit('file-changed', file);
});
file.on('ejected', () => this.closeFile(file));
file.on('change:dirty', (file, dirty) => {
if (dirty && this.settings.autoSaveInterval === -1) {
this.syncFile(file);
}
});
Events.emit('file-opened');

View File

@ -414,7 +414,6 @@ class FileModel extends Model {
setModified() {
if (!this.demo) {
this.set({ modified: true, dirty: true });
Events.emit('file-modified');
}
}

View File

@ -652,7 +652,7 @@ class AppView extends View {
if (this.autoSaveTimer) {
clearInterval(this.autoSaveTimer);
}
if (this.model.settings.autoSaveInterval) {
if (this.model.settings.autoSaveInterval > 0) {
this.autoSaveTimer = setInterval(
this.saveAll.bind(this),
this.model.settings.autoSaveInterval * 1000 * 60

View File

@ -331,7 +331,7 @@ class SettingsGeneralView extends View {
}
changeAutoSaveInterval(e) {
const autoSaveInterval = Number(e.target.value) || 0;
const autoSaveInterval = e.target.value | 0;
AppSettingsModel.autoSaveInterval = autoSaveInterval;
}

View File

@ -114,10 +114,11 @@
</div>
{{/if}}
<div>
<label for="settings__general-auto-save-interval">{{res 'setGenAutoSyncTimer'}}</label>
<label for="settings__general-auto-save-interval">{{res 'setGenAutoSyncTimer'}}:</label>
<select class="settings__select input-base settings__general-auto-save-interval"
id="settings__general-auto-save-interval">
<option value="0" {{#ifeq autoSaveInterval 0}}selected{{/ifeq}}>{{res 'setGenAutoSyncTimerOff'}}</option>
<option value="-1" {{#ifeq autoSaveInterval -1}}selected{{/ifeq}}>{{res 'setGenAutoSyncTimerOnChange'}}</option>
<option value="1" {{#ifeq autoSaveInterval 1}}selected{{/ifeq}}>{{#res 'setGenAutoSyncTimerInterval'}}
1{{/res}}</option>
<option value="5" {{#ifeq autoSaveInterval 5}}selected{{/ifeq}}>{{#res 'setGenAutoSyncTimerInterval'}}

View File

@ -7,6 +7,7 @@ Release notes
`+` option to use short-lived tokens in cloud storages
`+` opening XML and CSV files using the Open button
`*` password generator now includes all selected character ranges
`*` option to auto-save on file change
`+` better Touch ID error messages
`-` legacy auto-type removed
`+` displaying the reason why unlock is requested