mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-28 18:00:59 -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">
|
<Tooltip content="Mark as Unread">
|
||||||
<Entry
|
<Entry
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
// ! FIXME: deduplicate this code with ctx menu
|
||||||
const messages = getRenderer(
|
const messages = getRenderer(
|
||||||
message.channel!,
|
message.channel!,
|
||||||
).messages;
|
).messages;
|
||||||
|
|
|
@ -52,6 +52,7 @@ import LineDivider from "../components/ui/LineDivider";
|
||||||
|
|
||||||
import { Children } from "../types/Preact";
|
import { Children } from "../types/Preact";
|
||||||
import { internalEmit } from "./eventEmitter";
|
import { internalEmit } from "./eventEmitter";
|
||||||
|
import { getRenderer } from "./renderer/Singleton";
|
||||||
|
|
||||||
interface ContextMenuData {
|
interface ContextMenuData {
|
||||||
user?: string;
|
user?: string;
|
||||||
|
@ -73,6 +74,7 @@ type Action =
|
||||||
| { action: "copy_text"; content: string }
|
| { action: "copy_text"; content: string }
|
||||||
| { action: "mark_as_read"; channel: Channel }
|
| { action: "mark_as_read"; channel: Channel }
|
||||||
| { action: "mark_server_as_read"; server: Server }
|
| { action: "mark_server_as_read"; server: Server }
|
||||||
|
| { action: "mark_unread"; message: Message }
|
||||||
| { action: "retry_message"; message: QueuedMessage }
|
| { action: "retry_message"; message: QueuedMessage }
|
||||||
| { action: "cancel_message"; message: QueuedMessage }
|
| { action: "cancel_message"; message: QueuedMessage }
|
||||||
| { action: "mention"; user: string }
|
| { action: "mention"; user: string }
|
||||||
|
@ -186,6 +188,25 @@ export default function ContextMenus() {
|
||||||
}
|
}
|
||||||
break;
|
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":
|
case "retry_message":
|
||||||
{
|
{
|
||||||
const nonce = data.message.id;
|
const nonce = data.message.id;
|
||||||
|
@ -464,7 +485,7 @@ export default function ContextMenus() {
|
||||||
lastDivider = false;
|
lastDivider = false;
|
||||||
elements.push(
|
elements.push(
|
||||||
<MenuItem data={action} disabled={disabled}>
|
<MenuItem data={action} disabled={disabled}>
|
||||||
<span style={{color}}>
|
<span style={{ color }}>
|
||||||
<Text
|
<Text
|
||||||
id={`app.context_menu.${
|
id={`app.context_menu.${
|
||||||
locale ?? action.action
|
locale ?? action.action
|
||||||
|
@ -707,6 +728,11 @@ export default function ContextMenus() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
generateAction({
|
||||||
|
action: "mark_unread",
|
||||||
|
message,
|
||||||
|
});
|
||||||
|
|
||||||
if (
|
if (
|
||||||
typeof message.content === "string" &&
|
typeof message.content === "string" &&
|
||||||
message.content.length > 0
|
message.content.length > 0
|
||||||
|
|
Loading…
Reference in a new issue