diff --git a/src/components/common/messaging/bars/MessageOverlayBar.tsx b/src/components/common/messaging/bars/MessageOverlayBar.tsx index d47ac6d6..27d27412 100644 --- a/src/components/common/messaging/bars/MessageOverlayBar.tsx +++ b/src/components/common/messaging/bars/MessageOverlayBar.tsx @@ -169,6 +169,7 @@ export const MessageOverlayBar = observer(({ message, queued }: Props) => { { + // ! FIXME: deduplicate this code with ctx menu const messages = getRenderer( message.channel!, ).messages; diff --git a/src/lib/ContextMenus.tsx b/src/lib/ContextMenus.tsx index e3bf4a27..851106c6 100644 --- a/src/lib/ContextMenus.tsx +++ b/src/lib/ContextMenus.tsx @@ -52,6 +52,7 @@ import LineDivider from "../components/ui/LineDivider"; import { Children } from "../types/Preact"; import { internalEmit } from "./eventEmitter"; +import { getRenderer } from "./renderer/Singleton"; interface ContextMenuData { user?: string; @@ -73,6 +74,7 @@ type Action = | { action: "copy_text"; content: string } | { action: "mark_as_read"; channel: Channel } | { action: "mark_server_as_read"; server: Server } + | { action: "mark_unread"; message: Message } | { action: "retry_message"; message: QueuedMessage } | { action: "cancel_message"; message: QueuedMessage } | { action: "mention"; user: string } @@ -186,6 +188,25 @@ export default function ContextMenus() { } break; + case "mark_unread": + { + const messages = getRenderer( + data.message.channel!, + ).messages; + const index = messages.findIndex( + (x) => x._id === data.message._id, + ); + + let unread_id = data.message._id; + if (index > 0) { + unread_id = messages[index - 1]._id; + } + + internalEmit("NewMessages", "mark", unread_id); + data.message.channel?.ack(unread_id, true); + } + break; + case "retry_message": { const nonce = data.message.id; @@ -464,7 +485,7 @@ export default function ContextMenus() { lastDivider = false; elements.push( - + 0