Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

feat: add method to check item's sync status in case of incomplete sync

thecodrr19ef7e1a2c8f
diff --git a/packages/core/collections/content.js b/packages/core/collections/content.js
index af6fa54e3..f171d1e84 100644
--- a/packages/core/collections/content.js
+++ b/packages/core/collections/content.js
@@ -76,6 +76,10 @@ export default class Content extends Collection {
return this._collection.getItems(ids);
}
+ exists(id) {
+ return this._collection.exists(id);
+ }
+
async all() {
return Object.values(
await this._collection.getItems(this._collection.indexer.indices)
diff --git a/packages/core/collections/notes.js b/packages/core/collections/notes.js
index 2c6d3661f..cd91b2f76 100644
--- a/packages/core/collections/notes.js
+++ b/packages/core/collections/notes.js
@@ -151,6 +151,10 @@ export default class Notes extends Collection {
return this._getTagItems(colorId, "colors");
}
+ exists(id) {
+ return this._collection.exists(id);
+ }
+
/**
* @private
*/
diff --git a/packages/core/models/note.js b/packages/core/models/note.js
index 7ceef9156..a8b158794 100644
--- a/packages/core/models/note.js
+++ b/packages/core/models/note.js
@@ -178,4 +178,9 @@ export default class Note {
readonly() {
return this._toggle("readonly");
}
+
+ synced() {
+ const contentExists = this._db.content.exists(this.data.contentId);
+ return contentExists;
+ }
}
diff --git a/packages/core/models/topic.js b/packages/core/models/topic.js
index f3ab636ba..3318c51fd 100644
--- a/packages/core/models/topic.js
+++ b/packages/core/models/topic.js
@@ -94,11 +94,18 @@ export default class Topic {
}
get all() {
- const notes = this._topic.notes.reduce((arr, noteId) => {
+ return this._topic.notes.reduce((arr, noteId) => {
let note = this._db.notes.note(noteId);
if (note) arr.push(note.data);
return arr;
}, []);
- return sort(notes).desc((note) => note.dateCreated);
+ }
+
+ synced() {
+ const notes = this._topic.notes;
+ for (let id of notes) {
+ if (!this._db.notes.exists(id)) return false;
+ }
+ return true;
}
}