aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/quickReply.ts
diff options
context:
space:
mode:
authorVendicated <vendicated@riseup.net>2023-04-02 22:14:58 +0200
committerVendicated <vendicated@riseup.net>2023-04-02 22:14:58 +0200
commit8c47b7080d1b16df319cfadbc442f8a25e5a5a49 (patch)
tree3845708674ed19240b0d07715b59ed7f1ff48740 /src/plugins/quickReply.ts
parent8378638ee4bc1e9159110dacb38e682bc8438f52 (diff)
downloadVencord-8c47b7080d1b16df319cfadbc442f8a25e5a5a49.tar.gz
Vencord-8c47b7080d1b16df319cfadbc442f8a25e5a5a49.tar.bz2
Vencord-8c47b7080d1b16df319cfadbc442f8a25e5a5a49.zip
QuickReply & Up Key: Do not attempt to edit/reply to logged deleted message
Diffstat (limited to 'src/plugins/quickReply.ts')
-rw-r--r--src/plugins/quickReply.ts13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/plugins/quickReply.ts b/src/plugins/quickReply.ts
index a499ea4..984db18 100644
--- a/src/plugins/quickReply.ts
+++ b/src/plugins/quickReply.ts
@@ -111,7 +111,7 @@ function jumpIfOffScreen(channelId: string, messageId: string) {
}
function getNextMessage(isUp: boolean, isReply: boolean) {
- let messages: Message[] = MessageStore.getMessages(SelectedChannelStore.getChannelId())._array;
+ let messages: Array<Message & { deleted?: boolean; }> = MessageStore.getMessages(SelectedChannelStore.getChannelId())._array;
if (!isReply) { // we are editing so only include own
const meId = UserStore.getCurrentUser().id;
messages = messages.filter(m => m.author.id === meId);
@@ -121,11 +121,18 @@ function getNextMessage(isUp: boolean, isReply: boolean) {
? Math.min(messages.length - 1, i + 1)
: Math.max(-1, i - 1);
+ const findNextNonDeleted = (i: number) => {
+ do {
+ i = mutate(i);
+ } while (i !== -1 && messages[messages.length - i - 1]?.deleted === true);
+ return i;
+ };
+
let i: number;
if (isReply)
- replyIdx = i = mutate(replyIdx);
+ replyIdx = i = findNextNonDeleted(replyIdx);
else
- editIdx = i = mutate(editIdx);
+ editIdx = i = findNextNonDeleted(editIdx);
return i === - 1 ? undefined : messages[messages.length - i - 1];
}