-
- Shortcuts
- }
- endDecorator={
- filter.search && viewStore.setFilter({ search: "" })} />
- }
- value={filter.search}
- onChange={(e) => viewStore.setFilter({ search: e.target.value })}
- />
-
+
+ Shortcuts
- viewStore.setFilter({ mineOnly: value !== "ALL" })}
- >
-
- All
- My Own
-
-
+ placeholder="Search"
+ startDecorator={}
+ endDecorator={
+ filter.search && viewStore.setFilter({ search: "" })} />
+ }
+ value={filter.search}
+ onChange={(e) => viewStore.setFilter({ search: e.target.value })}
+ />
-
-
{loadingState.isLoading ? (
diff --git a/web/src/stores/v1/view.ts b/web/src/stores/v1/view.ts
index 9a97319..e2ccbca 100644
--- a/web/src/stores/v1/view.ts
+++ b/web/src/stores/v1/view.ts
@@ -2,8 +2,8 @@ import { create } from "zustand";
import { persist } from "zustand/middleware";
export interface Filter {
+ tab?: string;
tag?: string;
- mineOnly?: boolean;
visibility?: Visibility;
search?: string;
}
@@ -49,18 +49,13 @@ const useViewStore = create()(
);
export const getFilteredShortcutList = (shortcutList: Shortcut[], filter: Filter, currentUser: User) => {
- const { tag, mineOnly, visibility, search } = filter;
+ const { tab, tag, visibility, search } = filter;
const filteredShortcutList = shortcutList.filter((shortcut) => {
if (tag) {
if (!shortcut.tags.includes(tag)) {
return false;
}
}
- if (mineOnly) {
- if (shortcut.creatorId !== currentUser.id) {
- return false;
- }
- }
if (visibility) {
if (shortcut.visibility !== visibility) {
return false;
@@ -76,6 +71,14 @@ export const getFilteredShortcutList = (shortcutList: Shortcut[], filter: Filter
return false;
}
}
+ if (tab) {
+ if (tab === "tab:mine") {
+ return shortcut.creatorId === currentUser.id;
+ } else if (tab.startsWith("tag:")) {
+ const tag = tab.split(":")[1];
+ return shortcut.tags.includes(tag);
+ }
+ }
return true;
});
return filteredShortcutList;