mirror of
https://github.com/revoltchat/revite.git
synced 2024-12-25 23:22:06 -05:00
Merge pull request #266 from brecert/fix-265
This commit is contained in:
commit
ae2efcd9c6
1 changed files with 43 additions and 36 deletions
|
@ -104,14 +104,14 @@ type Action =
|
||||||
| { action: "create_channel"; target: Server }
|
| { action: "create_channel"; target: Server }
|
||||||
| { action: "create_category"; target: Server }
|
| { action: "create_category"; target: Server }
|
||||||
| {
|
| {
|
||||||
action: "create_invite";
|
action: "create_invite";
|
||||||
target: Channel;
|
target: Channel;
|
||||||
}
|
}
|
||||||
| { action: "leave_group"; target: Channel }
|
| { action: "leave_group"; target: Channel }
|
||||||
| {
|
| {
|
||||||
action: "delete_channel";
|
action: "delete_channel";
|
||||||
target: Channel;
|
target: Channel;
|
||||||
}
|
}
|
||||||
| { action: "close_dm"; target: Channel }
|
| { action: "close_dm"; target: Channel }
|
||||||
| { action: "leave_server"; target: Server }
|
| { action: "leave_server"; target: Server }
|
||||||
| { action: "delete_server"; target: Server }
|
| { action: "delete_server"; target: Server }
|
||||||
|
@ -122,10 +122,10 @@ type Action =
|
||||||
| { action: "open_server_settings"; id: string }
|
| { action: "open_server_settings"; id: string }
|
||||||
| { action: "open_server_channel_settings"; server: string; id: string }
|
| { action: "open_server_channel_settings"; server: string; id: string }
|
||||||
| {
|
| {
|
||||||
action: "set_notification_state";
|
action: "set_notification_state";
|
||||||
key: string;
|
key: string;
|
||||||
state?: NotificationState;
|
state?: NotificationState;
|
||||||
};
|
};
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
notifications: Notifications;
|
notifications: Notifications;
|
||||||
|
@ -486,9 +486,8 @@ function ContextMenus(props: Props) {
|
||||||
elements.push(
|
elements.push(
|
||||||
<MenuItem data={action} disabled={disabled}>
|
<MenuItem data={action} disabled={disabled}>
|
||||||
<Text
|
<Text
|
||||||
id={`app.context_menu.${
|
id={`app.context_menu.${locale ?? action.action
|
||||||
locale ?? action.action
|
}`}
|
||||||
}`}
|
|
||||||
/>
|
/>
|
||||||
{tip && <div className="tip">{tip}</div>}
|
{tip && <div className="tip">{tip}</div>}
|
||||||
</MenuItem>,
|
</MenuItem>,
|
||||||
|
@ -544,8 +543,8 @@ function ContextMenus(props: Props) {
|
||||||
const user = uid ? client.users.get(uid) : undefined;
|
const user = uid ? client.users.get(uid) : undefined;
|
||||||
const serverChannel =
|
const serverChannel =
|
||||||
targetChannel &&
|
targetChannel &&
|
||||||
(targetChannel.channel_type === "TextChannel" ||
|
(targetChannel.channel_type === "TextChannel" ||
|
||||||
targetChannel.channel_type === "VoiceChannel")
|
targetChannel.channel_type === "VoiceChannel")
|
||||||
? targetChannel
|
? targetChannel
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
|
@ -557,8 +556,8 @@ function ContextMenus(props: Props) {
|
||||||
(server
|
(server
|
||||||
? server.permission
|
? server.permission
|
||||||
: serverChannel
|
: serverChannel
|
||||||
? serverChannel.server?.permission
|
? serverChannel.server?.permission
|
||||||
: 0) || 0;
|
: 0) || 0;
|
||||||
const userPermissions = (user ? user.permission : 0) || 0;
|
const userPermissions = (user ? user.permission : 0) || 0;
|
||||||
|
|
||||||
if (unread) {
|
if (unread) {
|
||||||
|
@ -702,19 +701,27 @@ function ContextMenus(props: Props) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message && !queued) {
|
if (message && !queued) {
|
||||||
generateAction({
|
const sendPermission =
|
||||||
action: "reply_message",
|
message.channel &&
|
||||||
target: message,
|
message.channel.permission & ChannelPermission.SendMessage
|
||||||
});
|
|
||||||
|
if (sendPermission) {
|
||||||
|
generateAction({
|
||||||
|
action: "reply_message",
|
||||||
|
target: message,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
typeof message.content === "string" &&
|
typeof message.content === "string" &&
|
||||||
message.content.length > 0
|
message.content.length > 0
|
||||||
) {
|
) {
|
||||||
generateAction({
|
if (sendPermission) {
|
||||||
action: "quote_message",
|
generateAction({
|
||||||
content: message.content,
|
action: "quote_message",
|
||||||
});
|
content: message.content,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
generateAction({
|
generateAction({
|
||||||
action: "copy_text",
|
action: "copy_text",
|
||||||
|
@ -732,7 +739,7 @@ function ContextMenus(props: Props) {
|
||||||
if (
|
if (
|
||||||
message.author_id === userId ||
|
message.author_id === userId ||
|
||||||
channelPermissions &
|
channelPermissions &
|
||||||
ChannelPermission.ManageMessages
|
ChannelPermission.ManageMessages
|
||||||
) {
|
) {
|
||||||
generateAction({
|
generateAction({
|
||||||
action: "delete_message",
|
action: "delete_message",
|
||||||
|
@ -753,8 +760,8 @@ function ContextMenus(props: Props) {
|
||||||
type === "Image"
|
type === "Image"
|
||||||
? "open_image"
|
? "open_image"
|
||||||
: type === "Video"
|
: type === "Video"
|
||||||
? "open_video"
|
? "open_video"
|
||||||
: "open_file",
|
: "open_file",
|
||||||
);
|
);
|
||||||
|
|
||||||
generateAction(
|
generateAction(
|
||||||
|
@ -765,8 +772,8 @@ function ContextMenus(props: Props) {
|
||||||
type === "Image"
|
type === "Image"
|
||||||
? "save_image"
|
? "save_image"
|
||||||
: type === "Video"
|
: type === "Video"
|
||||||
? "save_video"
|
? "save_video"
|
||||||
: "save_file",
|
: "save_file",
|
||||||
);
|
);
|
||||||
|
|
||||||
generateAction(
|
generateAction(
|
||||||
|
@ -880,9 +887,9 @@ function ContextMenus(props: Props) {
|
||||||
|
|
||||||
if (
|
if (
|
||||||
serverPermissions &
|
serverPermissions &
|
||||||
ServerPermission.ChangeNickname ||
|
ServerPermission.ChangeNickname ||
|
||||||
serverPermissions &
|
serverPermissions &
|
||||||
ServerPermission.ChangeAvatar
|
ServerPermission.ChangeAvatar
|
||||||
)
|
)
|
||||||
generateAction(
|
generateAction(
|
||||||
{ action: "edit_identity", target: server },
|
{ action: "edit_identity", target: server },
|
||||||
|
@ -926,10 +933,10 @@ function ContextMenus(props: Props) {
|
||||||
sid
|
sid
|
||||||
? "copy_sid"
|
? "copy_sid"
|
||||||
: cid
|
: cid
|
||||||
? "copy_cid"
|
? "copy_cid"
|
||||||
: message
|
: message
|
||||||
? "copy_mid"
|
? "copy_mid"
|
||||||
: "copy_uid",
|
: "copy_uid",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue