mobile: fix sidemenu shortcuts

This commit is contained in:
Ammar Ahmed
2024-02-14 17:54:45 +05:00
parent a409eb3a0f
commit 7873251d05
4 changed files with 35 additions and 12 deletions

View File

@@ -56,6 +56,7 @@ const ColorPicker = ({
<BaseDialog
visible={visible}
onRequestClose={() => {
title.current = undefined;
setVisible(false);
useSettingStore.getState().setSheetKeyboardHandler(true);
}}

View File

@@ -84,8 +84,7 @@ export const PinnedSection = React.memo(
data={menuPins}
style={{
flexGrow: 1,
width: "100%",
paddingHorizontal: 12
width: "100%"
}}
contentContainerStyle={{
flexGrow: 1

View File

@@ -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: [] })
}));

View File

@@ -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) {