File tree Expand file tree Collapse file tree 4 files changed +30
-4
lines changed
Expand file tree Collapse file tree 4 files changed +30
-4
lines changed Original file line number Diff line number Diff line change 2727 const addReaction = useMutation (api .messages .addReaction );
2828
2929 const messagesById = $derived (
30- new Map (messages .data ?.map ((message ) => [message ._id , message ])),
30+ new Map (
31+ messages .data ?.map ((message : Doc <" messages" >) => [message ._id , message ]),
32+ ),
3133 );
3234
3335 let messagesContainer: HTMLDivElement ;
139141 visibleDropdown = message ._id ;
140142 }}
141143 >
142- {#if message .parentId && messages .data .find ((m ) => m ._id === message .parentId )}
144+ {#if message .parentId && messages .data .find ((m : Doc < " messages " > ) => m ._id === message .parentId )}
143145 <div class =" flex items-center gap-2" >
144146 <span class =" text-base-content/60 text-xs" >返信</span >
145147 <span class =" text-primary font-semibold"
Original file line number Diff line number Diff line change 11<script lang =" ts" >
22 import { api , type Id } from " @apps/convex" ;
33 import { useQuery } from " convex-svelte" ;
4+ import { uniqueBy } from " @/lib/utils" ;
45
56 interface Props {
67 organizationId: Id <" organizations" >;
2829 });
2930
3031 const allUserIdsInReactions = $derived (
31- reactions .data ? [... new Set (reactions .data .map ((r ) => r .userId ))] : [],
32+ reactions .data
33+ ? uniqueBy (reactions .data , (r ) => r .userId ).map ((r ) => r .userId )
34+ : [],
3235 );
3336
3437 // const userNamesById = useQuery(api.users.getUserNames, () => ({
Original file line number Diff line number Diff line change 1+ /**
2+ * Returns an array with unique elements based on a key selector function.
3+ *
4+ * @param array - The input array
5+ * @param keySelector - Function to extract the unique key from each element
6+ * @returns Array with unique elements based on the key
7+ */
8+ export function uniqueBy < T , K > ( array : T [ ] , keySelector : ( item : T ) => K ) : T [ ] {
9+ const seen = new Set < K > ( ) ;
10+ const result : T [ ] = [ ] ;
11+
12+ for ( const item of array ) {
13+ const key = keySelector ( item ) ;
14+ if ( ! seen . has ( key ) ) {
15+ seen . add ( key ) ;
16+ result . push ( item ) ;
17+ }
18+ }
19+
20+ return result ;
21+ }
Original file line number Diff line number Diff line change 1919 "check" : " bun run check:lint && bun run --filter=* check && bun run check:format" ,
2020 "fix" : " bun run fix:lint && bun run fix:format" ,
2121 "check:format" : " prettier --check ." ,
22- "fix:format" : " prettier --write ." ,
22+ "fix:format" : " prettier --write . --log-level warn " ,
2323 "check:lint" : " bun biome check" ,
2424 "fix:lint" : " bun biome check --fix --unsafe" ,
2525 "convex" : " cd apps/convex && bun run convex" ,
You can’t perform that action at this time.
0 commit comments