Skip to content

Commit d9171a6

Browse files
committed
fix: fix checks
1 parent bf4e250 commit d9171a6

File tree

4 files changed

+30
-4
lines changed

4 files changed

+30
-4
lines changed

apps/desktop/src/components/chat/MessageList.svelte

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
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;
@@ -139,7 +141,7 @@
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"

apps/desktop/src/components/chat/ReactionList.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
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">;
@@ -28,7 +29,9 @@
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, () => ({

apps/desktop/src/lib/utils.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
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",

0 commit comments

Comments
 (0)