Skip to content

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

feat: add isPinned method in settings

thecodrrfe5eb08079cd
diff --git a/packages/core/api/settings.js b/packages/core/api/settings.js
index e6849dd0a..6a27f503a 100644
--- a/packages/core/api/settings.js
+++ b/packages/core/api/settings.js
@@ -16,6 +16,7 @@ class Settings {
async pin(type, data) {
if (type !== "notebook" && type !== "topic" && type !== "tag")
throw new Error("This item cannot be pinned.");
+ if (this.isPinned(data.id)) return;
this._settings.pins.push({ type, data });
await this._db.context.write("settings", this._settings);
}
@@ -27,6 +28,10 @@ class Settings {
await this._db.context.write("settings", this._settings);
}
+ isPinned(id) {
+ return this.Settings.pins.findIndex((v) => v.data.id === id) > -1;
+ }
+
get pins() {
return this._settings.pins.map((pin) => {
if (pin.type === "notebook") {