mirror of
https://github.com/keeweb/keeweb.git
synced 2024-06-28 07:50:55 +02:00
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) {
|
openFile: function(params, callback) {
|
||||||
var that = this;
|
var that = this;
|
||||||
var fileInfo = params.id ? this.fileInfos.get(params.id) : this.fileInfos.getMatch(params.storage, params.name, params.path);
|
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
|
// modified offline, cannot overwrite: load from cache
|
||||||
this.openFileFromCache(params, callback, fileInfo);
|
this.openFileFromCache(params, callback, fileInfo);
|
||||||
} else if (params.fileData) {
|
} else if (params.fileData) {
|
||||||
// has user content: load it
|
// has user content: load it
|
||||||
this.openFileWithData(params, callback, fileInfo, params.fileData, true);
|
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
|
// already latest in cache: use it
|
||||||
this.openFileFromCache(params, callback, fileInfo);
|
this.openFileFromCache(params, callback, fileInfo);
|
||||||
} else {
|
} else {
|
||||||
|
@ -261,7 +261,7 @@ var AppModel = Backbone.Model.extend({
|
||||||
Storage[params.storage].load(params.path, function(err, data, rev) {
|
Storage[params.storage].load(params.path, function(err, data, rev) {
|
||||||
if (err) {
|
if (err) {
|
||||||
// failed to load from storage: fallback to cache if we can
|
// failed to load from storage: fallback to cache if we can
|
||||||
if (fileInfo && fileInfo.get('availOffline')) {
|
if (fileInfo) {
|
||||||
that.openFileFromCache(params, callback, fileInfo);
|
that.openFileFromCache(params, callback, fileInfo);
|
||||||
} else {
|
} else {
|
||||||
callback(err);
|
callback(err);
|
||||||
|
@ -289,7 +289,6 @@ var AppModel = Backbone.Model.extend({
|
||||||
openFileWithData: function(params, callback, fileInfo, data, updateCacheOnSuccess) {
|
openFileWithData: function(params, callback, fileInfo, data, updateCacheOnSuccess) {
|
||||||
var file = new FileModel({
|
var file = new FileModel({
|
||||||
name: params.name,
|
name: params.name,
|
||||||
availOffline: params.availOffline,
|
|
||||||
storage: params.storage,
|
storage: params.storage,
|
||||||
path: params.path,
|
path: params.path,
|
||||||
keyFileName: params.keyFileName
|
keyFileName: params.keyFileName
|
||||||
|
@ -303,18 +302,14 @@ var AppModel = Backbone.Model.extend({
|
||||||
return callback('Duplicate file id');
|
return callback('Duplicate file id');
|
||||||
}
|
}
|
||||||
var cacheId = fileInfo && fileInfo.id || IdGenerator.uuid();
|
var cacheId = fileInfo && fileInfo.id || IdGenerator.uuid();
|
||||||
if (params.availOffline && updateCacheOnSuccess) {
|
if (updateCacheOnSuccess) {
|
||||||
Storage.cache.save(cacheId, params.fileData, function(err) {
|
Storage.cache.save(cacheId, params.fileData, function(err) {
|
||||||
if (err) {
|
if (err && !params.storage) {
|
||||||
file.set('availOffline', false);
|
return;
|
||||||
if (!params.storage) { return; }
|
|
||||||
}
|
}
|
||||||
that.addToLastOpenFiles(file, cacheId, params.rev);
|
that.addToLastOpenFiles(file, cacheId, params.rev);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!params.availOffline && fileInfo && !fileInfo.get('modified')) {
|
|
||||||
that.removeFileInfo(fileInfo.id);
|
|
||||||
}
|
|
||||||
if (params.storage === 'file') {
|
if (params.storage === 'file') {
|
||||||
that.addToLastOpenFiles(file, cacheId, params.rev);
|
that.addToLastOpenFiles(file, cacheId, params.rev);
|
||||||
}
|
}
|
||||||
|
@ -329,7 +324,6 @@ var AppModel = Backbone.Model.extend({
|
||||||
name: file.get('name'),
|
name: file.get('name'),
|
||||||
storage: file.get('storage'),
|
storage: file.get('storage'),
|
||||||
path: file.get('path'),
|
path: file.get('path'),
|
||||||
availOffline: file.get('availOffline'),
|
|
||||||
modified: file.get('modified'),
|
modified: file.get('modified'),
|
||||||
editState: null,
|
editState: null,
|
||||||
rev: rev,
|
rev: rev,
|
||||||
|
|
|
@ -8,7 +8,6 @@ var FileInfoModel = Backbone.Model.extend({
|
||||||
name: '',
|
name: '',
|
||||||
storage: null,
|
storage: null,
|
||||||
path: null,
|
path: null,
|
||||||
availOffline: false,
|
|
||||||
modified: false,
|
modified: false,
|
||||||
editState: null,
|
editState: null,
|
||||||
rev: null,
|
rev: null,
|
||||||
|
|
|
@ -25,8 +25,7 @@ var FileModel = Backbone.Model.extend({
|
||||||
oldKeyFileName: '',
|
oldKeyFileName: '',
|
||||||
passwordChanged: false,
|
passwordChanged: false,
|
||||||
keyFileChanged: false,
|
keyFileChanged: false,
|
||||||
syncing: false,
|
syncing: false
|
||||||
availOffline: false
|
|
||||||
},
|
},
|
||||||
|
|
||||||
db: null,
|
db: null,
|
||||||
|
|
|
@ -37,7 +37,6 @@ var OpenView = Backbone.View.extend({
|
||||||
name: '',
|
name: '',
|
||||||
storage: null,
|
storage: null,
|
||||||
path: null,
|
path: null,
|
||||||
availOffline: false,
|
|
||||||
keyFileName: null,
|
keyFileName: null,
|
||||||
keyFileData: null,
|
keyFileData: null,
|
||||||
fileData: null,
|
fileData: null,
|
||||||
|
@ -122,9 +121,6 @@ var OpenView = Backbone.View.extend({
|
||||||
displayOpenFile: function() {
|
displayOpenFile: function() {
|
||||||
this.$el.addClass('open--file');
|
this.$el.addClass('open--file');
|
||||||
this.$el.find('.open__settings-key-file').removeClass('hide');
|
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].removeAttribute('readonly');
|
||||||
this.inputEl[0].setAttribute('placeholder', 'Password for ' + this.params.name);
|
this.inputEl[0].setAttribute('placeholder', 'Password for ' + this.params.name);
|
||||||
this.inputEl.focus();
|
this.inputEl.focus();
|
||||||
|
@ -334,13 +330,11 @@ var OpenView = Backbone.View.extend({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.params.id = fileInfo.id;
|
this.params.id = fileInfo.id;
|
||||||
this.params.availOffline = fileInfo.get('availOffline');
|
|
||||||
this.params.storage = fileInfo.get('storage');
|
this.params.storage = fileInfo.get('storage');
|
||||||
this.params.path = fileInfo.get('path');
|
this.params.path = fileInfo.get('path');
|
||||||
this.params.name = fileInfo.get('name');
|
this.params.name = fileInfo.get('name');
|
||||||
this.params.fileData = null;
|
this.params.fileData = null;
|
||||||
this.params.rev = null;
|
this.params.rev = null;
|
||||||
this.$el.find('#open__settings-check-offline').prop('checked', this.params.availOffline);
|
|
||||||
this.displayOpenFile();
|
this.displayOpenFile();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -373,11 +367,8 @@ var OpenView = Backbone.View.extend({
|
||||||
|
|
||||||
openDb: function() {
|
openDb: function() {
|
||||||
if (!this.busy) {
|
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.$el.toggleClass('open--opening', true);
|
||||||
this.inputEl.attr('disabled', 'disabled');
|
this.inputEl.attr('disabled', 'disabled');
|
||||||
this.$el.find('#open__settings-check-offline').attr('disabled', 'disabled');
|
|
||||||
this.busy = true;
|
this.busy = true;
|
||||||
this.params.password = this.passwordInput.value;
|
this.params.password = this.passwordInput.value;
|
||||||
this.afterPaint(this.model.openFile.bind(this.model, this.params, this.openDbComplete.bind(this)));
|
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.busy = false;
|
||||||
this.$el.toggleClass('open--opening', false);
|
this.$el.toggleClass('open--opening', false);
|
||||||
this.inputEl.removeAttr('disabled').toggleClass('input--error', !!err);
|
this.inputEl.removeAttr('disabled').toggleClass('input--error', !!err);
|
||||||
this.$el.find('#open__settings-check-offline').removeAttr('disabled');
|
|
||||||
if (err) {
|
if (err) {
|
||||||
this.inputEl.focus();
|
this.inputEl.focus();
|
||||||
this.inputEl[0].selectionStart = 0;
|
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, &-key-file-dropbox {
|
||||||
&-key-file-dropbox {
|
|
||||||
@include th {
|
@include th {
|
||||||
color: muted-color();
|
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 {
|
&__last {
|
||||||
|
|
|
@ -34,11 +34,6 @@
|
||||||
<span class="open__settings-key-file-name">key file</span>
|
<span class="open__settings-key-file-name">key file</span>
|
||||||
<span class="open__settings-key-file-dropbox"> (from dropbox)</span>
|
<span class="open__settings-key-file-dropbox"> (from dropbox)</span>
|
||||||
</div>
|
</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>
|
||||||
<div class="open__last">
|
<div class="open__last">
|
||||||
<% lastOpenFiles.forEach(function(file) { %>
|
<% lastOpenFiles.forEach(function(file) { %>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user