Skip to content

Commit 5b81540

Browse files
committed
fix bugs
1 parent 3876d95 commit 5b81540

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

src/chat-api/store/useMessages.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ const sendAndStoreMessage = async (channelId: string, content?: string) => {
180180
if (!user) return;
181181

182182
const localMessage: Message = {
183+
buttons: [],
183184
id: tempMessageId,
184185
tempId: tempMessageId,
185186
silent: isSilent,
@@ -204,6 +205,7 @@ const sendAndStoreMessage = async (channelId: string, content?: string) => {
204205
replyToMessage: { ...m }
205206
})) || [],
206207
createdBy: {
208+
bot: false,
207209
profile: {
208210
font: user.profile?.font
209211
},
@@ -216,10 +218,11 @@ const sendAndStoreMessage = async (channelId: string, content?: string) => {
216218
}
217219
};
218220

219-
!properties?.moreBottomToLoad &&
221+
if (!properties?.moreBottomToLoad) {
220222
setMessages({
221223
[channelId]: sliceBeginning([...messages[channelId]!, localMessage])
222224
});
225+
}
223226

224227
const onUploadProgress = (percent: number, speed?: string) => {
225228
const messageIndex = messages[channelId]!.findIndex(
@@ -232,9 +235,6 @@ const sendAndStoreMessage = async (channelId: string, content?: string) => {
232235
});
233236
};
234237

235-
const isImage = properties?.attachment?.file.type?.startsWith("image/");
236-
const isMoreThan12MB = file && file.size > 12 * 1024 * 1024;
237-
238238
const shouldUploadToGoogleDrive =
239239
properties?.attachment?.uploadTo === "google_drive";
240240
const shouldUploadToNerimityCdn =
@@ -340,33 +340,39 @@ const sendAndStoreMessage = async (channelId: string, content?: string) => {
340340
);
341341

342342
if (!message) {
343-
!properties?.moreBottomToLoad &&
343+
if (!properties?.moreBottomToLoad) {
344344
setMessages(channelId, index!, "sentStatus", MessageSentStatus.FAILED);
345+
}
345346
return;
346347
}
347348
message.tempId = tempMessageId;
348349

349-
!properties?.moreBottomToLoad &&
350+
if (!properties?.moreBottomToLoad) {
350351
setMessages(channelId, index!, reconcile(message, { key: "tempId" }));
352+
}
351353
};
352354

353355
const pushMessage = (channelId: string, message: Message) => {
354356
if (!messages[channelId]) return;
355357
const channelProperties = useChannelProperties();
356358
const properties = channelProperties.get(channelId);
357-
!properties?.moreBottomToLoad &&
359+
if (!properties?.moreBottomToLoad) {
358360
setMessages({
359361
[channelId]: sliceBeginning([...messages[channelId]!, message])
360362
});
363+
}
361364
};
362365

363366
const pushFailedMessage = (channelId: string, content: string) => {
364367
pushMessage(channelId, {
365368
channelId: channelId,
366369
createdAt: Date.now(),
370+
buttons: [],
371+
replyMessages: [],
367372
createdBy: {
368373
username: "Nerimity",
369374
tag: "owo",
375+
bot: true,
370376
badges: 0,
371377
hexColor: "0",
372378
id: "0"

src/components/message-pane/message-item/MessageItem.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,9 @@ const MessageItem = (props: MessageItemProps) => {
620620
<Avatar
621621
animate={hovered()}
622622
user={props.message.createdBy}
623+
rawUrl={
624+
props.message.local ? "/assets/logo.png" : undefined
625+
}
623626
size={40}
624627
resize={96}
625628
/>

src/components/ui/Avatar.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@ interface Props {
3333
size: number;
3434
class?: string;
3535
animate?: boolean;
36+
rawUrl?: string | null;
3637
user?: {
3738
username: string;
3839
avatar?: string;
3940
hexColor: string;
4041
badges?: number;
41-
avatarUrl?: string | (() => string | null | undefined) | null;
42+
avatarUrl?: string | null;
4243
};
4344
server?: {
4445
name: string;
@@ -76,6 +77,7 @@ export default function Avatar(props: Props) {
7677
const serverOrUser = () => (props.server || props.user) as ServerOrUserAvatar;
7778

7879
const url = () => {
80+
if (props.rawUrl) return props.rawUrl;
7981
if (typeof props.user?.avatarUrl === "string") return webhookAvatarUrl();
8082
const rawUrl = props.url || avatarUrl(serverOrUser());
8183
if (!rawUrl) return;

0 commit comments

Comments
 (0)