mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 06:59:31 +01:00
feat: add isPinned method in settings
This commit is contained in:
@@ -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") {
|
||||
|
||||
Reference in New Issue
Block a user