diff --git a/src/routes/inbox/InboxItem.svelte b/src/routes/inbox/InboxItem.svelte index 6a470795..65c1698c 100644 --- a/src/routes/inbox/InboxItem.svelte +++ b/src/routes/inbox/InboxItem.svelte @@ -23,19 +23,17 @@ function isPrivateMessage( item: CommentReplyView | PersonMentionView | PrivateMessageView - ) { + ): item is PrivateMessageView { return 'private_message' in item } - // I hate how you can't type cast in Svelte easily - const replyItem = item as CommentReplyView | PersonMentionView - const messageItem = item as PrivateMessageView - let replying = false let reply = '' let loading = false - async function replyToMessage() { + async function replyToMessage( + message: PrivateMessageView | CommentReplyView | PersonMentionView + ) { if (!$authData) return loading = true @@ -44,7 +42,7 @@ await getClient().createPrivateMessage({ auth: $authData.token, content: reply, - recipient_id: messageItem.creator.id, + recipient_id: message.creator.id, }) addToast( @@ -75,28 +73,26 @@ overflow-hidden {read ? 'opacity-50' : ''}" > - {replyItem.creator.display_name ?? replyItem.creator.name} + {item.creator.display_name ?? item.creator.name} replied to you in - {replyItem.post.name} + {item.post.name}
- - Jump - + Jump
@@ -107,26 +103,26 @@ overflow-hidden flex flex-row items-center gap-1 {read ? 'opacity-80' : ''}" > - {#if messageItem.creator.id == $user?.person.id} + {#if item.creator.id == $user?.person.id} You {:else} - + {/if} messaged - {#if messageItem.recipient.id == $user?.person.id} + {#if item.recipient.id == $user?.person.id} You {:else} - + {/if}

- +

- {#if messageItem.recipient.id == $user?.person.id} + {#if item.recipient.id == $user?.person.id}
{/if} - {#if replying} + {#if isPrivateMessage(item)}