1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-12 22:57:38 +02:00

Adding service to keep track of note resources associations

This commit is contained in:
Laurent Cozic
2018-03-12 23:40:43 +00:00
parent eef106c99b
commit f595be07d4
9 changed files with 174 additions and 109 deletions

View File

@ -2,6 +2,7 @@ const BaseModel = require('lib/BaseModel.js');
const { Log } = require('lib/log.js');
const { sprintf } = require('sprintf-js');
const BaseItem = require('lib/models/BaseItem.js');
const ItemChange = require('lib/models/ItemChange.js');
const Setting = require('lib/models/Setting.js');
const { shim } = require('lib/shim.js');
const { time } = require('lib/time-utils.js');
@ -398,6 +399,8 @@ class Note extends BaseItem {
const note = await super.save(o, options);
ItemChange.add(BaseModel.TYPE_NOTE, note.id, isNew ? ItemChange.TYPE_CREATE : ItemChange.TYPE_UPDATE);
this.dispatch({
type: 'NOTE_UPDATE_ONE',
note: note,
@ -413,18 +416,22 @@ class Note extends BaseItem {
return note;
}
static async delete(id, options = null) {
let r = await super.delete(id, options);
// Not used?
this.dispatch({
type: 'NOTE_DELETE',
id: id,
});
}
// static async delete(id, options = null) {
// let r = await super.delete(id, options);
// this.dispatch({
// type: 'NOTE_DELETE',
// id: id,
// });
// }
static batchDelete(ids, options = null) {
const result = super.batchDelete(ids, options);
for (let i = 0; i < ids.length; i++) {
ItemChange.add(BaseModel.TYPE_NOTE, ids[i], ItemChange.TYPE_DELETE);
this.dispatch({
type: 'NOTE_DELETE',
id: ids[i],