From 8da486adf290eb854ab91e6cc76cfd135694a30e Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Wed, 15 Oct 2025 16:01:11 +0200 Subject: [PATCH] Optimistically remove starred profile upon deletion --- web/components/searches/button.tsx | 144 +++++++++++++++++------------ 1 file changed, 83 insertions(+), 61 deletions(-) diff --git a/web/components/searches/button.tsx b/web/components/searches/button.tsx index 3bef94c..5613315 100644 --- a/web/components/searches/button.tsx +++ b/web/components/searches/button.tsx @@ -10,7 +10,8 @@ import {FilterFields} from "common/filters"; import {api} from "web/lib/api"; import {DisplayUser} from "common/api/user-types"; import {Link} from "@react-email/components"; -import {DOMAIN} from "common/envs/constants"; +import {useState} from "react"; +import toast from "react-hot-toast"; export function BookmarkSearchButton(props: { bookmarkedSearches: BookmarkedSearchesType[] @@ -63,33 +64,35 @@ function ButtonModal(props: {

Saved Searches

{bookmarkedSearches?.length ? (<> -

We'll notify you daily when new people match your searches below.

- -
    - {(bookmarkedSearches || []).map((search) => ( -
  1. - {formatFilters(search.search_filters as Partial, search.location as locationType)?.join(" • ")} - -
  2. - ))} -
+

We'll notify you daily when new people match your searches below.

+ +
    + {(bookmarkedSearches || []).map((search) => ( +
  1. + {formatFilters(search.search_filters as Partial, search.location as locationType)?.join(" • ")} + +
  2. + ))} +
- - - ) :

You haven't saved any search. To save one, click on Get Notified and we'll notify you daily when new people match it.

} + + + ) : +

You haven't saved any search. To save one, click on Get Notified and we'll notify you daily when new people + match it.

} {/* void }) { const {open, setOpen, starredUsers, refreshStars} = props + // Track items being optimistically removed so we can hide them immediately + const [removingIds, setRemovingIds] = useState>(new Set()) + + const visibleUsers = (starredUsers || []).filter((u) => !removingIds.has(u.id)) return (

Saved Profiles

- {starredUsers?.length ? (<> -

Here are the profiles you saved:

- -
    - {(starredUsers || []).map((user) => ( -
  1. - {user.name} ( - @{user.username} - ) {' '} - -
  2. - ))} -
+ {visibleUsers?.length ? (<> +

Here are the profiles you saved:

+ +
    + {visibleUsers.map((user) => ( +
  1. + {user.name} ( + @{user.username} + ) {' '} + +
  2. + ))} +
- + - ) :

You haven't saved any profile. To save one, click on the star on their profile page.

} + ) :

You haven't saved any profile. To save one, click on the star on their profile page.

} {/*