Skip to content

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

web: use getGroupOptionsById & setGroupOptionsById Signed-off-by: 01zulfi <[email protected]>

01zulfibd3edc535aea
diff --git a/apps/web/src/components/group-header/index.tsx b/apps/web/src/components/group-header/index.tsx
index ce854b3ba..6d55aa32b 100644
--- a/apps/web/src/components/group-header/index.tsx
+++ b/apps/web/src/components/group-header/index.tsx
@@ -201,10 +201,10 @@ function getGroupOptions(
): GroupOptions {
return isSearching
? db.settings.getGroupOptions("search")
- : context?.type === "notebook"
- ? db.settings.getNotebookGroupOptions(context.id)
- : context?.type === "tag"
- ? db.settings.getTagGroupOptions(context.id)
+ : context?.type === "notebook" ||
+ context?.type === "tag" ||
+ context?.type === "color"
+ ? db.settings.getGroupOptionsById(context.id, context.type)
: db.settings.getGroupOptions(groupingKey);
}
@@ -212,10 +212,16 @@ async function setGroupOptions(
options: GroupingMenuOptions,
groupOptions: GroupOptions
) {
- if (options.context?.type === "notebook") {
- await db.settings.setNotebookGroupOptions(options.context.id, groupOptions);
- } else if (options.context?.type === "tag") {
- await db.settings.setTagGroupOptions(options.context.id, groupOptions);
+ if (
+ options.context?.type === "notebook" ||
+ options.context?.type === "tag" ||
+ options.context?.type === "color"
+ ) {
+ await db.settings.setGroupOptionsById(
+ options.context.id,
+ options.context.type,
+ groupOptions
+ );
} else {
await db.settings.setGroupOptions(options.groupingKey, groupOptions);
}
diff --git a/apps/web/src/stores/note-store.ts b/apps/web/src/stores/note-store.ts
index 27b6b2d3c..519fd8092 100644
--- a/apps/web/src/stores/note-store.ts
+++ b/apps/web/src/stores/note-store.ts
@@ -58,10 +58,10 @@ class NoteStore extends BaseStore<NoteStore> {
setContext = async (context?: Context) => {
const groupOptions =
- context?.type === "notebook"
- ? db.settings.getNotebookGroupOptions(context.id)
- : context?.type === "tag"
- ? db.settings.getTagGroupOptions(context.id)
+ context?.type === "notebook" ||
+ context?.type === "tag" ||
+ context?.type === "color"
+ ? db.settings.getGroupOptionsById(context.id, context.type)
: db.settings.getGroupOptions(
context?.type === "favorite"
? "favorites"