You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-15 23:00:36 +02:00
All: Better handling of encrypted data on UI side and prevent modification of encrypted notes
This commit is contained in:
@ -200,18 +200,37 @@ class BaseModel {
|
||||
|
||||
static diffObjects(oldModel, newModel) {
|
||||
let output = {};
|
||||
let type = null;
|
||||
const fields = this.diffObjectsFields(oldModel, newModel);
|
||||
for (let i = 0; i < fields.length; i++) {
|
||||
output[fields[i]] = newModel[fields[i]];
|
||||
}
|
||||
if ('type_' in newModel) output.type_ = newModel.type_;
|
||||
return output;
|
||||
// let output = {};
|
||||
// let type = null;
|
||||
// for (let n in newModel) {
|
||||
// if (!newModel.hasOwnProperty(n)) continue;
|
||||
// if (n == 'type_') {
|
||||
// type = newModel[n];
|
||||
// continue;
|
||||
// }
|
||||
// if (!(n in oldModel) || newModel[n] !== oldModel[n]) {
|
||||
// output[n] = newModel[n];
|
||||
// }
|
||||
// }
|
||||
// if (type !== null) output.type_ = type;
|
||||
// return output;
|
||||
}
|
||||
|
||||
static diffObjectsFields(oldModel, newModel) {
|
||||
let output = [];
|
||||
for (let n in newModel) {
|
||||
if (!newModel.hasOwnProperty(n)) continue;
|
||||
if (n == 'type_') {
|
||||
type = newModel[n];
|
||||
continue;
|
||||
}
|
||||
if (n == 'type_') continue;
|
||||
if (!(n in oldModel) || newModel[n] !== oldModel[n]) {
|
||||
output[n] = newModel[n];
|
||||
output.push(n);
|
||||
}
|
||||
}
|
||||
if (type !== null) output.type_ = type;
|
||||
return output;
|
||||
}
|
||||
|
||||
@ -269,6 +288,16 @@ class BaseModel {
|
||||
let where = { id: o.id };
|
||||
let temp = Object.assign({}, o);
|
||||
delete temp.id;
|
||||
|
||||
if (options.fields) {
|
||||
let filtered = {};
|
||||
for (let i = 0; i < options.fields.length; i++) {
|
||||
const f = options.fields[i];
|
||||
filtered[f] = o[f];
|
||||
}
|
||||
temp = filtered;
|
||||
}
|
||||
|
||||
query = Database.updateQuery(this.tableName(), temp, where);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user