feat(mobx): migrate auth and config

This commit is contained in:
Paul
2021-12-11 21:04:12 +00:00
parent bc799931a8
commit f8b8d96d3d
22 changed files with 342 additions and 279 deletions

View File

@@ -105,14 +105,14 @@ type Action =
| { action: "create_channel"; target: Server }
| { action: "create_category"; target: Server }
| {
action: "create_invite";
target: Channel;
}
action: "create_invite";
target: Channel;
}
| { action: "leave_group"; target: Channel }
| {
action: "delete_channel";
target: Channel;
}
action: "delete_channel";
target: Channel;
}
| { action: "close_dm"; target: Channel }
| { action: "leave_server"; target: Server }
| { action: "delete_server"; target: Server }
@@ -123,10 +123,10 @@ type Action =
| { action: "open_server_settings"; id: string }
| { action: "open_server_channel_settings"; server: string; id: string }
| {
action: "set_notification_state";
key: string;
state?: NotificationState;
};
action: "set_notification_state";
key: string;
state?: NotificationState;
};
type Props = {
notifications: Notifications;
@@ -488,8 +488,9 @@ function ContextMenus(props: Props) {
elements.push(
<MenuItem data={action} disabled={disabled}>
<Text
id={`app.context_menu.${locale ?? action.action
}`}
id={`app.context_menu.${
locale ?? action.action
}`}
/>
{tip && <div className="tip">{tip}</div>}
</MenuItem>,
@@ -545,8 +546,8 @@ function ContextMenus(props: Props) {
const user = uid ? client.users.get(uid) : undefined;
const serverChannel =
targetChannel &&
(targetChannel.channel_type === "TextChannel" ||
targetChannel.channel_type === "VoiceChannel")
(targetChannel.channel_type === "TextChannel" ||
targetChannel.channel_type === "VoiceChannel")
? targetChannel
: undefined;
@@ -558,8 +559,8 @@ function ContextMenus(props: Props) {
(server
? server.permission
: serverChannel
? serverChannel.server?.permission
: 0) || 0;
? serverChannel.server?.permission
: 0) || 0;
const userPermissions = (user ? user.permission : 0) || 0;
if (unread) {
@@ -705,7 +706,8 @@ function ContextMenus(props: Props) {
if (message && !queued) {
const sendPermission =
message.channel &&
message.channel.permission & ChannelPermission.SendMessage
message.channel.permission &
ChannelPermission.SendMessage;
if (sendPermission) {
generateAction({
@@ -741,7 +743,7 @@ function ContextMenus(props: Props) {
if (
message.author_id === userId ||
channelPermissions &
ChannelPermission.ManageMessages
ChannelPermission.ManageMessages
) {
generateAction({
action: "delete_message",
@@ -765,8 +767,8 @@ function ContextMenus(props: Props) {
type === "Image"
? "open_image"
: type === "Video"
? "open_video"
: "open_file",
? "open_video"
: "open_file",
);
generateAction(
@@ -777,8 +779,8 @@ function ContextMenus(props: Props) {
type === "Image"
? "save_image"
: type === "Video"
? "save_video"
: "save_file",
? "save_video"
: "save_file",
);
generateAction(
@@ -930,9 +932,9 @@ function ContextMenus(props: Props) {
if (
serverPermissions &
ServerPermission.ChangeNickname ||
ServerPermission.ChangeNickname ||
serverPermissions &
ServerPermission.ChangeAvatar
ServerPermission.ChangeAvatar
)
generateAction(
{ action: "edit_identity", target: server },
@@ -976,10 +978,10 @@ function ContextMenus(props: Props) {
sid
? "copy_sid"
: cid
? "copy_cid"
: message
? "copy_mid"
: "copy_uid",
? "copy_cid"
: message
? "copy_mid"
: "copy_uid",
);
}