mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-09 16:53:36 -05:00
feat(context menu): add "mark as unread"
This commit is contained in:
parent
a58372fc42
commit
60cd17d673
2 changed files with 28 additions and 1 deletions
|
@ -169,6 +169,7 @@ export const MessageOverlayBar = observer(({ message, queued }: Props) => {
|
|||
<Tooltip content="Mark as Unread">
|
||||
<Entry
|
||||
onClick={() => {
|
||||
// ! FIXME: deduplicate this code with ctx menu
|
||||
const messages = getRenderer(
|
||||
message.channel!,
|
||||
).messages;
|
||||
|
|
|
@ -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(
|
||||
<MenuItem data={action} disabled={disabled}>
|
||||
<span style={{color}}>
|
||||
<span style={{ color }}>
|
||||
<Text
|
||||
id={`app.context_menu.${
|
||||
locale ?? action.action
|
||||
|
@ -707,6 +728,11 @@ export default function ContextMenus() {
|
|||
});
|
||||
}
|
||||
|
||||
generateAction({
|
||||
action: "mark_unread",
|
||||
message,
|
||||
});
|
||||
|
||||
if (
|
||||
typeof message.content === "string" &&
|
||||
message.content.length > 0
|
||||
|
|
Loading…
Reference in a new issue