diff --git a/web/src/components/AnalyticsDialog.tsx b/web/src/components/AnalyticsDialog.tsx index 98364f3..0fa8dae 100644 --- a/web/src/components/AnalyticsDialog.tsx +++ b/web/src/components/AnalyticsDialog.tsx @@ -85,7 +85,7 @@ const AnalyticsDialog: React.FC = (props: Props) => { - Devices + Operating system Visitors diff --git a/web/src/components/FilterView.tsx b/web/src/components/FilterView.tsx index 914b1c8..7067289 100644 --- a/web/src/components/FilterView.tsx +++ b/web/src/components/FilterView.tsx @@ -1,10 +1,13 @@ -import useViewStore from "../stores/v1/filter"; +import { useTranslation } from "react-i18next"; +import useViewStore from "../stores/v1/view"; import Icon from "./Icon"; +import VisibilityIcon from "./VisibilityIcon"; const FilterView = () => { + const { t } = useTranslation(); const viewStore = useViewStore(); const filter = viewStore.filter; - const shouldShowFilters = filter.tag !== undefined; + const shouldShowFilters = filter.tag !== undefined || filter.visibility !== undefined; if (!shouldShowFilters) { return <>; @@ -15,10 +18,21 @@ const FilterView = () => { Filters: {filter.tag && ( + )} + {filter.visibility && ( + )} diff --git a/web/src/components/ShortcutView.tsx b/web/src/components/ShortcutView.tsx index 910218c..702e526 100644 --- a/web/src/components/ShortcutView.tsx +++ b/web/src/components/ShortcutView.tsx @@ -5,7 +5,7 @@ import { useTranslation } from "react-i18next"; import toast from "react-hot-toast"; import { shortcutService } from "../services"; import useFaviconStore from "../stores/v1/favicon"; -import useViewStore from "../stores/v1/filter"; +import useViewStore from "../stores/v1/view"; import useUserStore from "../stores/v1/user"; import { absolutifyLink } from "../helpers/utils"; import { showCommonDialog } from "./Alert"; @@ -143,14 +143,17 @@ const ShortcutView = (props: Props) => { -
+
viewStore.setFilter({ visibility: shortcut.visibility })} + > {t(`shortcut.visibility.${shortcut.visibility.toLowerCase()}.self`)}
setShowAnalyticsDialog(true)} > diff --git a/web/src/pages/Home.tsx b/web/src/pages/Home.tsx index 386f4ff..c88f777 100644 --- a/web/src/pages/Home.tsx +++ b/web/src/pages/Home.tsx @@ -2,7 +2,7 @@ import { Button, Tab, TabList, Tabs } from "@mui/joy"; import { useEffect, useState } from "react"; import { shortcutService } from "../services"; import { useAppSelector } from "../stores"; -import useViewStore, { Filter } from "../stores/v1/filter"; +import useViewStore, { Filter } from "../stores/v1/view"; import useUserStore from "../stores/v1/user"; import useLoading from "../hooks/useLoading"; import Icon from "../components/Icon"; @@ -15,7 +15,7 @@ interface State { } const getFilteredShortcutList = (shortcutList: Shortcut[], filter: Filter, currentUser: User) => { - const { tag, mineOnly } = filter; + const { tag, mineOnly, visibility } = filter; const filteredShortcutList = shortcutList.filter((shortcut) => { if (tag) { if (!shortcut.tags.includes(tag)) { @@ -27,6 +27,11 @@ const getFilteredShortcutList = (shortcutList: Shortcut[], filter: Filter, curre return false; } } + if (visibility) { + if (shortcut.visibility !== visibility) { + return false; + } + } return true; }); return filteredShortcutList; diff --git a/web/src/stores/v1/filter.ts b/web/src/stores/v1/view.ts similarity index 95% rename from web/src/stores/v1/filter.ts rename to web/src/stores/v1/view.ts index 36dbd86..291be0c 100644 --- a/web/src/stores/v1/filter.ts +++ b/web/src/stores/v1/view.ts @@ -4,6 +4,7 @@ import { persist } from "zustand/middleware"; export interface Filter { tag?: string; mineOnly?: boolean; + visibility?: Visibility; } interface ViewState {