Skip to content

Commit

Permalink
✨ feat: Replace window.location with router navigation for bookmark d…
Browse files Browse the repository at this point in the history
…eletion
  • Loading branch information
vaayne committed Jan 9, 2025
1 parent 4cdcca4 commit 11fa6c3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions web/src/components/bookmarks/bookmark-detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
useShareContentMutations,
} from "@/lib/apis/bookmarks";
import { ROUTES } from "@/lib/router";
import { useRouter } from "@tanstack/react-router";
import { useState } from "react";

// Add this near the top of the file, before the component
Expand All @@ -38,7 +39,7 @@ export default function BookmarkDetailPage({ id }: { id: string }) {
const { deleteBookmark, refreshBookmark } = useBookmarkMutations();
const { shareContent, unshareContent, updateSharedContent } =
useShareContentMutations();

const router = useRouter();
const { data: bookmark, error } = useBookmark(id);
if (error) {
return <div className="container mx-auto p-4">Error loading bookmark</div>;
Expand Down Expand Up @@ -98,7 +99,14 @@ export default function BookmarkDetailPage({ id }: { id: string }) {
title: "Success",
description: "Bookmark deleted successfully",
});
window.location.href = ROUTES.BOOKMARKS;
router.navigate({
to: ROUTES.BOOKMARKS,
search: {
page: 1,
filters: [],
query: "",
},
});
} catch (error) {
toast({
title: "Error",
Expand Down

0 comments on commit 11fa6c3

Please sign in to comment.