Skip to content

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

mobile: fix sidemenu shortcuts

Ammar Ahmed3172d5a55288
diff --git a/apps/mobile/app/components/dialogs/color-picker/index.tsx b/apps/mobile/app/components/dialogs/color-picker/index.tsx
index 14e1c8af7..ef63cb1e2 100644
--- a/apps/mobile/app/components/dialogs/color-picker/index.tsx
+++ b/apps/mobile/app/components/dialogs/color-picker/index.tsx
@@ -56,6 +56,7 @@ const ColorPicker = ({
<BaseDialog
visible={visible}
onRequestClose={() => {
+ title.current = undefined;
setVisible(false);
useSettingStore.getState().setSheetKeyboardHandler(true);
}}
diff --git a/apps/mobile/app/components/side-menu/pinned-section.tsx b/apps/mobile/app/components/side-menu/pinned-section.tsx
index 9132f6d22..a839357c1 100644
--- a/apps/mobile/app/components/side-menu/pinned-section.tsx
+++ b/apps/mobile/app/components/side-menu/pinned-section.tsx
@@ -84,8 +84,7 @@ export const PinnedSection = React.memo(
data={menuPins}
style={{
flexGrow: 1,
- width: "100%",
- paddingHorizontal: 12
+ width: "100%"
}}
contentContainerStyle={{
flexGrow: 1
diff --git a/apps/mobile/app/stores/use-menu-store.ts b/apps/mobile/app/stores/use-menu-store.ts
index b2b108a3f..865bb031f 100644
--- a/apps/mobile/app/stores/use-menu-store.ts
+++ b/apps/mobile/app/stores/use-menu-store.ts
@@ -42,12 +42,17 @@ export const useMenuStore = create<MenuStore>((set) => ({
});
},
setColorNotes: () => {
- db.colors?.all.items().then((colors) => {
- set({
- colorNotes: colors,
- loadingColors: false
+ db.colors?.all
+ .items(undefined, {
+ sortBy: "dateCreated",
+ sortDirection: "asc"
+ })
+ .then((colors) => {
+ set({
+ colorNotes: colors,
+ loadingColors: false
+ });
});
- });
},
clearAll: () => set({ menuPins: [], colorNotes: [] })
}));
diff --git a/packages/core/src/collections/shortcuts.ts b/packages/core/src/collections/shortcuts.ts
index 750b14d62..84bdef8a2 100644
--- a/packages/core/src/collections/shortcuts.ts
+++ b/packages/core/src/collections/shortcuts.ts
@@ -101,6 +101,7 @@ export class Shortcuts implements ICollection {
): Promise<ResolveTypeToItem<T>> {
const tagIds: string[] = [];
const notebookIds: string[] = [];
+
for (const shortcut of this.all) {
if (
(type === "all" || type === "notebooks") &&
@@ -113,12 +114,29 @@ export class Shortcuts implements ICollection {
)
tagIds.push(shortcut.itemId);
}
- return [
- ...(notebookIds.length > 0
+
+ const notebooks =
+ notebookIds.length > 0
? await this.db.notebooks.all.items(notebookIds)
- : []),
- ...(tagIds.length > 0 ? await this.db.tags.all.items(tagIds) : [])
- ] as ResolveTypeToItem<T>;
+ : [];
+ const tags = tagIds.length > 0 ? await this.db.tags.all.items(tagIds) : [];
+
+ const sortedItems: (Notebook | Tag)[] = [];
+
+ this.all
+ .sort((a, b) => a.dateCreated - b.dateCreated)
+ .forEach((shortcut) => {
+ if (type === "all" || type === "notebooks") {
+ const notebook = notebooks.find((n) => n.id === shortcut.itemId);
+ if (notebook) sortedItems.push(notebook);
+ }
+ if (type === "all" || type === "tags") {
+ const tag = tags.find((t) => t.id === shortcut.itemId);
+ if (tag) sortedItems.push(tag);
+ }
+ });
+
+ return sortedItems as ResolveTypeToItem<T>;
}
exists(id: string) {