Skip to content

Commit 175976e

Browse files
feat(navigation): remove unused navigation utility
The changes remove the `safeNavigate` utility function from the `@hypr/utils/navigation` module, as it is no longer being used in the codebase. This simplifies the codebase and removes unnecessary code. The changes also update the event and note card components to use the `windowsCommands.windowShow` and `windowsCommands.windowEmitNavigate` functions directly, instead of relying on the `safeNavigate` utility.
1 parent 8bfe117 commit 175976e

File tree

6 files changed

+21
-63
lines changed

6 files changed

+21
-63
lines changed

apps/desktop/src/components/left-sidebar/events-list.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { SplashLoader } from "@hypr/ui/components/ui/splash";
1919
import { cn } from "@hypr/ui/lib/utils";
2020
import { useSession } from "@hypr/utils/contexts";
2121
import { formatUpcomingTime } from "@hypr/utils/datetime";
22-
import { safeNavigate } from "@hypr/utils/navigation";
2322

2423
type EventWithSession = Event & { session: Session | null };
2524

@@ -128,14 +127,12 @@ function EventItem({
128127

129128
const handleOpenCalendar = () => {
130129
const date = new Date(event.start_date);
130+
const formattedDate = format(date, "yyyy-MM-dd");
131+
const url = `/app/finder?view=calendar&date=${formattedDate}`;
131132

132-
const params = {
133-
to: "/app/calendar",
134-
search: { date: format(date, "yyyy-MM-dd") },
135-
} as const satisfies LinkProps;
136-
137-
const url = `${params.to}?date=${params.search.date}`;
138-
safeNavigate({ type: "calendar" }, url);
133+
windowsCommands.windowShow({ type: "main" }).then(() => {
134+
windowsCommands.windowEmitNavigate({ type: "main" }, url);
135+
});
139136
};
140137

141138
const isActive = activeSessionId

apps/desktop/src/components/left-sidebar/notes-list.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import { SplashLoader } from "@hypr/ui/components/ui/splash";
2424
import { cn } from "@hypr/ui/lib/utils";
2525
import { useSession, useSessions } from "@hypr/utils/contexts";
2626
import { format, formatDate, formatRelative } from "@hypr/utils/datetime";
27-
import { safeNavigate } from "@hypr/utils/navigation";
2827

2928
interface NotesListProps {
3029
filter: (session: Session) => boolean;
@@ -235,14 +234,12 @@ function NoteItem({
235234
};
236235

237236
const handleOpenCalendar = () => {
238-
const params = {
239-
to: "/app/calendar",
240-
search: { date: format(currentSession.created_at, "yyyy-MM-dd") },
241-
} as const satisfies LinkProps;
237+
const formattedDate = format(currentSession.created_at, "yyyy-MM-dd");
238+
const url = `/app/finder?view=calendar&date=${formattedDate}`;
242239

243-
const url = `${params.to}?date=${params.search.date}`;
244-
245-
safeNavigate({ type: "calendar" }, url);
240+
windowsCommands.windowShow({ type: "main" }).then(() => {
241+
windowsCommands.windowEmitNavigate({ type: "main" }, url);
242+
});
246243
};
247244

248245
const buttonRef = useRef<HTMLButtonElement>(null);

apps/desktop/src/components/workspace-calendar/event-card.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import { useMemo, useState } from "react";
88
import { useHypr } from "@/contexts";
99
import type { Event } from "@hypr/plugin-db";
1010
import { commands as dbCommands } from "@hypr/plugin-db";
11+
import { commands as windowsCommands } from "@hypr/plugin-windows";
1112
import { Button } from "@hypr/ui/components/ui/button";
1213
import { Popover, PopoverContent, PopoverTrigger } from "@hypr/ui/components/ui/popover";
13-
import { safeNavigate } from "@hypr/utils/navigation";
1414

1515
export function EventCard({
1616
event,
@@ -72,7 +72,9 @@ export function EventCard({
7272

7373
const url = props.to.replace("$id", props.params.id);
7474

75-
safeNavigate({ type: "main" }, url);
75+
windowsCommands.windowShow({ type: "main" }).then(() => {
76+
windowsCommands.windowEmitNavigate({ type: "main" }, url);
77+
});
7678
} else {
7779
const props = {
7880
to: "/app/new",
@@ -83,7 +85,9 @@ export function EventCard({
8385
`?calendarEventId=${props.search.calendarEventId}`,
8486
);
8587

86-
safeNavigate({ type: "main" }, url);
88+
windowsCommands.windowShow({ type: "main" }).then(() => {
89+
windowsCommands.windowEmitNavigate({ type: "main" }, url);
90+
});
8791
}
8892
};
8993

apps/desktop/src/components/workspace-calendar/note-card.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import { useMemo, useState } from "react";
88
import { useHypr } from "@/contexts";
99
import { type Session } from "@hypr/plugin-db";
1010
import { commands as dbCommands } from "@hypr/plugin-db";
11+
import { commands as windowsCommands } from "@hypr/plugin-windows";
1112
import { Button } from "@hypr/ui/components/ui/button";
1213
import { Popover, PopoverContent, PopoverTrigger } from "@hypr/ui/components/ui/popover";
13-
import { safeNavigate } from "@hypr/utils/navigation";
1414

1515
export function NoteCard({
1616
session,
@@ -62,7 +62,9 @@ export function NoteCard({
6262

6363
const url = props.to.replace("$id", props.params.id);
6464

65-
safeNavigate({ type: "main" }, url);
65+
windowsCommands.windowShow({ type: "main" }).then(() => {
66+
windowsCommands.windowEmitNavigate({ type: "main" }, url);
67+
});
6668
};
6769

6870
const getStartDate = () => {

packages/utils/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export * from "./ai";
22
export * from "./datetime";
33
export * from "./fetch";
4-
export * from "./navigation";
54
export * from "./organization";
65
export * from "./string";

packages/utils/src/navigation.ts

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)