diff --git a/apps/desktop/src/components/main/sidebar/timeline/index.tsx b/apps/desktop/src/components/main/sidebar/timeline/index.tsx index c242d1a267..8ca72cc42a 100644 --- a/apps/desktop/src/components/main/sidebar/timeline/index.tsx +++ b/apps/desktop/src/components/main/sidebar/timeline/index.tsx @@ -1,10 +1,11 @@ import { ChevronDownIcon, ChevronUpIcon } from "lucide-react"; -import { type ReactNode, useMemo } from "react"; +import { type ReactNode, useCallback, useMemo, useState } from "react"; import { Button } from "@hypr/ui/components/ui/button"; import { cn, startOfDay } from "@hypr/utils"; import { useConfigValue } from "../../../../config/use-config"; +import { useNativeContextMenu } from "../../../../hooks/useNativeContextMenu"; import * as main from "../../../../store/tinybase/store/main"; import { useTabs } from "../../../../store/zustand/tabs"; import { @@ -24,8 +25,24 @@ import { } from "./realtime"; export function TimelineView() { - const buckets = useTimelineData(); + const allBuckets = useTimelineData(); const timezone = useConfigValue("timezone") || undefined; + const [showIgnored, setShowIgnored] = useState(false); + + const buckets = useMemo(() => { + if (showIgnored) { + return allBuckets; + } + return allBuckets + .map((bucket) => ({ + ...bucket, + items: bucket.items.filter( + (item) => item.type !== "event" || !item.data.ignored, + ), + })) + .filter((bucket) => bucket.items.length > 0); + }, [allBuckets, showIgnored]); + const hasToday = useMemo( () => buckets.some((bucket) => bucket.label === "Today"), [buckets], @@ -85,10 +102,28 @@ export function TimelineView() { ); }, [buckets, hasToday, todayTimestamp]); + const toggleShowIgnored = useCallback(() => { + setShowIgnored((prev) => !prev); + }, []); + + const contextMenuItems = useMemo( + () => [ + { + id: "toggle-ignored", + text: showIgnored ? "Hide Ignored Events" : "Show Ignored Events", + action: toggleShowIgnored, + }, + ], + [showIgnored, toggleShowIgnored], + ); + + const showContextMenu = useNativeContextMenu(contextMenuItems); + return (