mirror of https://github.com/keeweb/keeweb.git
completely removed non-offline files
This commit is contained in:
parent
1227698aeb
commit
5f947df27d
|
@ -247,13 +247,13 @@ var AppModel = Backbone.Model.extend({
|
|||
openFile: function(params, callback) {
|
||||
var that = this;
|
||||
var fileInfo = params.id ? this.fileInfos.get(params.id) : this.fileInfos.getMatch(params.storage, params.name, params.path);
|
||||
if (fileInfo && fileInfo.get('availOffline') && fileInfo.get('modified')) {
|
||||
if (fileInfo && fileInfo.get('modified')) {
|
||||
// modified offline, cannot overwrite: load from cache
|
||||
this.openFileFromCache(params, callback, fileInfo);
|
||||
} else if (params.fileData) {
|
||||
// has user content: load it
|
||||
this.openFileWithData(params, callback, fileInfo, params.fileData, true);
|
||||
} else if (fileInfo && fileInfo.get('availOffline') && fileInfo.get('rev') === params.rev) {
|
||||
} else if (fileInfo && fileInfo.get('rev') === params.rev) {
|
||||
// already latest in cache: use it
|
||||
this.openFileFromCache(params, callback, fileInfo);
|
||||
} else {
|
||||
|
@ -261,7 +261,7 @@ var AppModel = Backbone.Model.extend({
|
|||
Storage[params.storage].load(params.path, function(err, data, rev) {
|
||||
if (err) {
|
||||
// failed to load from storage: fallback to cache if we can
|
||||
if (fileInfo && fileInfo.get('availOffline')) {
|
||||
if (fileInfo) {
|
||||
that.openFileFromCache(params, callback, fileInfo);
|
||||
} else {
|
||||
callback(err);
|
||||
|
@ -289,7 +289,6 @@ var AppModel = Backbone.Model.extend({
|
|||
openFileWithData: function(params, callback, fileInfo, data, updateCacheOnSuccess) {
|
||||
var file = new FileModel({
|
||||
name: params.name,
|
||||
availOffline: params.availOffline,
|
||||
storage: params.storage,
|
||||
path: params.path,
|
||||
keyFileName: params.keyFileName
|
||||
|
@ -303,18 +302,14 @@ var AppModel = Backbone.Model.extend({
|
|||
return callback('Duplicate file id');
|
||||
}
|
||||
var cacheId = fileInfo && fileInfo.id || IdGenerator.uuid();
|
||||
if (params.availOffline && updateCacheOnSuccess) {
|
||||
if (updateCacheOnSuccess) {
|
||||
Storage.cache.save(cacheId, params.fileData, function(err) {
|
||||
if (err) {
|
||||
file.set('availOffline', false);
|
||||
if (!params.storage) { return; }
|
||||
if (err && !params.storage) {
|
||||
return;
|
||||
}
|
||||
that.addToLastOpenFiles(file, cacheId, params.rev);
|
||||
});
|
||||
}
|
||||
if (!params.availOffline && fileInfo && !fileInfo.get('modified')) {
|
||||
that.removeFileInfo(fileInfo.id);
|
||||
}
|
||||
if (params.storage === 'file') {
|
||||
that.addToLastOpenFiles(file, cacheId, params.rev);
|
||||
}
|
||||
|
@ -329,7 +324,6 @@ var AppModel = Backbone.Model.extend({
|
|||
name: file.get('name'),
|
||||
storage: file.get('storage'),
|
||||
path: file.get('path'),
|
||||
availOffline: file.get('availOffline'),
|
||||
modified: file.get('modified'),
|
||||
editState: null,
|
||||
rev: rev,
|
||||
|
|
|
@ -8,7 +8,6 @@ var FileInfoModel = Backbone.Model.extend({
|
|||
name: '',
|
||||
storage: null,
|
||||
path: null,
|
||||
availOffline: false,
|
||||
modified: false,
|
||||
editState: null,
|
||||
rev: null,
|
||||
|
|
|
@ -25,8 +25,7 @@ var FileModel = Backbone.Model.extend({
|
|||
oldKeyFileName: '',
|
||||
passwordChanged: false,
|
||||
keyFileChanged: false,
|
||||
syncing: false,
|
||||
availOffline: false
|
||||
syncing: false
|
||||
},
|
||||
|
||||
db: null,
|
||||
|
|
|
@ -37,7 +37,6 @@ var OpenView = Backbone.View.extend({
|
|||
name: '',
|
||||
storage: null,
|
||||
path: null,
|
||||
availOffline: false,
|
||||
keyFileName: null,
|
||||
keyFileData: null,
|
||||
fileData: null,
|
||||
|
@ -122,9 +121,6 @@ var OpenView = Backbone.View.extend({
|
|||
displayOpenFile: function() {
|
||||
this.$el.addClass('open--file');
|
||||
this.$el.find('.open__settings-key-file').removeClass('hide');
|
||||
this.$el.find('#open__settings-check-offline')[0].removeAttribute('disabled');
|
||||
var canSwitchOffline = this.params.storage !== 'file';
|
||||
this.$el.find('.open__settings-offline').toggleClass('hide', !canSwitchOffline);
|
||||
this.inputEl[0].removeAttribute('readonly');
|
||||
this.inputEl[0].setAttribute('placeholder', 'Password for ' + this.params.name);
|
||||
this.inputEl.focus();
|
||||
|
@ -334,13 +330,11 @@ var OpenView = Backbone.View.extend({
|
|||
return;
|
||||
}
|
||||
this.params.id = fileInfo.id;
|
||||
this.params.availOffline = fileInfo.get('availOffline');
|
||||
this.params.storage = fileInfo.get('storage');
|
||||
this.params.path = fileInfo.get('path');
|
||||
this.params.name = fileInfo.get('name');
|
||||
this.params.fileData = null;
|
||||
this.params.rev = null;
|
||||
this.$el.find('#open__settings-check-offline').prop('checked', this.params.availOffline);
|
||||
this.displayOpenFile();
|
||||
},
|
||||
|
||||
|
@ -373,11 +367,8 @@ var OpenView = Backbone.View.extend({
|
|||
|
||||
openDb: function() {
|
||||
if (!this.busy) {
|
||||
var offlineChecked = this.$el.find('#open__settings-check-offline').is(':checked');
|
||||
this.params.availOffline = this.params.storage !== 'file' && offlineChecked;
|
||||
this.$el.toggleClass('open--opening', true);
|
||||
this.inputEl.attr('disabled', 'disabled');
|
||||
this.$el.find('#open__settings-check-offline').attr('disabled', 'disabled');
|
||||
this.busy = true;
|
||||
this.params.password = this.passwordInput.value;
|
||||
this.afterPaint(this.model.openFile.bind(this.model, this.params, this.openDbComplete.bind(this)));
|
||||
|
@ -388,7 +379,6 @@ var OpenView = Backbone.View.extend({
|
|||
this.busy = false;
|
||||
this.$el.toggleClass('open--opening', false);
|
||||
this.inputEl.removeAttr('disabled').toggleClass('input--error', !!err);
|
||||
this.$el.find('#open__settings-check-offline').removeAttr('disabled');
|
||||
if (err) {
|
||||
this.inputEl.focus();
|
||||
this.inputEl[0].selectionStart = 0;
|
||||
|
|
|
@ -103,8 +103,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
&-key-file, &-label-offline, &-label-offline:before, input[type=checkbox] + label.open__settings-label-offline:before,
|
||||
&-key-file-dropbox {
|
||||
&-key-file, &-key-file-dropbox {
|
||||
@include th {
|
||||
color: muted-color();
|
||||
}
|
||||
|
@ -114,11 +113,6 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
&-label-offline { font-weight: normal; }
|
||||
}
|
||||
|
||||
&--file:not(.open--opening) input[type=checkbox] + label.open__settings-label-offline:hover:before {
|
||||
@include th { color: medium-color(); }
|
||||
}
|
||||
|
||||
&__last {
|
||||
|
|
|
@ -34,11 +34,6 @@
|
|||
<span class="open__settings-key-file-name">key file</span>
|
||||
<span class="open__settings-key-file-dropbox"> (from dropbox)</span>
|
||||
</div>
|
||||
<div class="open__settings-offline hide">
|
||||
<input type="checkbox" id="open__settings-check-offline" class="open__settings-check-offline" checked disabled />
|
||||
<label for="open__settings-check-offline" class="open__settings-label-offline">make available offline</label>
|
||||
</div>
|
||||
<div class="open__settings-offline-warning hide muted-color"><i class="fa fa-exclamation-triangle"></i> saved offline version</div>
|
||||
</div>
|
||||
<div class="open__last">
|
||||
<% lastOpenFiles.forEach(function(file) { %>
|
||||
|
|
Loading…
Reference in New Issue