Skip to content

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

mobile: default tag

Ammar Ahmedfa43f97bb4f2
diff --git a/apps/mobile/app/components/properties/items.tsx b/apps/mobile/app/components/properties/items.tsx
index 5e4b398dd..e06e97e87 100644
--- a/apps/mobile/app/components/properties/items.tsx
+++ b/apps/mobile/app/components/properties/items.tsx
@@ -67,6 +67,7 @@ const COLUMN_BAR_ITEMS: ActionId[] = [
"move-notebook",
"pin",
"default-notebook",
+ "default-tag",
"default-homepage",
"add-shortcut",
"reorder",
diff --git a/apps/mobile/app/hooks/use-actions.tsx b/apps/mobile/app/hooks/use-actions.tsx
index 7bda11e0d..58f78bb58 100644
--- a/apps/mobile/app/hooks/use-actions.tsx
+++ b/apps/mobile/app/hooks/use-actions.tsx
@@ -110,7 +110,8 @@ export type ActionId =
| "favorite"
| "remove-from-notebook"
| "trash"
- | "default-homepage";
+ | "default-homepage"
+ | "default-tag";
export type Action = {
id: ActionId;
@@ -158,6 +159,8 @@ export const useActions = ({
const [defaultNotebook, setDefaultNotebook] = useState(
db.settings.getDefaultNotebook()
);
+ const [defaultTag, setDefaultTag] = useState(db.settings.getDefaultTag());
+
const [noteInCurrentNotebook, setNoteInCurrentNotebook] = useState(false);
const [locked, setLocked] = useState(false);
const isHomepage = useSettingStore(
@@ -469,15 +472,39 @@ export const useActions = ({
}
if (item.type === "tag" || item.type === "notebook") {
- actions.push({
- id: "add-shortcut",
- title: isPinnedToMenu ? strings.removeShortcut() : strings.addShortcut(),
- icon: isPinnedToMenu ? "link-variant-remove" : "link-variant",
- onPress: createMenuShortcut,
- isToggle: true,
- checked: isPinnedToMenu,
- activeColor: colors.error.paragraph
- });
+ actions.push(
+ {
+ id: "add-shortcut",
+ title: isPinnedToMenu
+ ? strings.removeShortcut()
+ : strings.addShortcut(),
+ icon: isPinnedToMenu ? "link-variant-remove" : "link-variant",
+ onPress: createMenuShortcut,
+ isToggle: true,
+ checked: isPinnedToMenu,
+ activeColor: colors.error.paragraph
+ },
+ {
+ id: "default-tag",
+ title:
+ defaultTag === item.id
+ ? strings.removeAsDefault()
+ : strings.setAsDefault(),
+ hidden: item.type !== "tag",
+ icon: "pound",
+ onPress: async () => {
+ if (defaultTag === item.id) {
+ await db.settings.setDefaultTag(undefined);
+ setDefaultTag(undefined);
+ } else {
+ await db.settings.setDefaultTag(item.id);
+ setDefaultTag(item.id);
+ }
+ close();
+ },
+ checked: defaultTag === item.id
+ }
+ );
}
if (item.type === "notebook") {
diff --git a/apps/mobile/app/screens/editor/tiptap/use-editor.ts b/apps/mobile/app/screens/editor/tiptap/use-editor.ts
index ad2be7f8e..da28ff64c 100644
--- a/apps/mobile/app/screens/editor/tiptap/use-editor.ts
+++ b/apps/mobile/app/screens/editor/tiptap/use-editor.ts
@@ -365,14 +365,24 @@ export const useEditor = (
}
});
- const defaultNotebook = db.settings.getDefaultNotebook();
- if (!state.current.onNoteCreated && defaultNotebook) {
- onNoteCreated(id, {
- type: "notebook",
- id: defaultNotebook
- });
+ if (!state.current.onNoteCreated) {
+ const defaultNotebook = db.settings.getDefaultNotebook();
+ if (defaultNotebook) {
+ onNoteCreated(id, {
+ type: "notebook",
+ id: defaultNotebook
+ });
+ }
+
+ const defaultTag = db.settings.getDefaultTag();
+ if (defaultTag) {
+ onNoteCreated(id, {
+ type: "tag",
+ id: defaultTag
+ });
+ }
} else {
- state.current?.onNoteCreated && state.current.onNoteCreated(id);
+ state.current.onNoteCreated(id);
}
}