fix: add context menu to individual attachments if > 1 attached (#348)

This commit is contained in:
3nt3
2021-10-31 22:25:33 +01:00
committed by GitHub
parent 23a24e1bac
commit 939309f8ed
3 changed files with 71 additions and 19 deletions

View File

@@ -63,6 +63,7 @@ interface ContextMenuData {
server_list?: string;
channel?: string;
message?: Message;
attachment?: Attachment;
unread?: boolean;
queued?: QueuedMessage;
@@ -468,6 +469,7 @@ function ContextMenus(props: Props) {
channel: cid,
server: sid,
message,
attachment,
server_list,
queued,
unread,
@@ -747,7 +749,10 @@ function ContextMenus(props: Props) {
});
}
if (message.attachments) {
if (
message.attachments &&
message.attachments.length == 1 // if there are multiple attachments, the individual ones have to be clicked
) {
pushDivider();
const { metadata } = message.attachments[0];
const { type } = metadata;
@@ -796,6 +801,44 @@ function ContextMenus(props: Props) {
}
}
if (attachment) {
pushDivider();
const { metadata } = attachment;
const { type } = metadata;
generateAction(
{
action: "open_file",
attachment,
},
type === "Image"
? "open_image"
: type === "Video"
? "open_video"
: "open_file",
);
generateAction(
{
action: "save_file",
attachment,
},
type === "Image"
? "save_image"
: type === "Video"
? "save_video"
: "save_file",
);
generateAction(
{
action: "copy_file_link",
attachment,
},
"copy_link",
);
}
const id = sid ?? cid ?? uid ?? message?._id;
if (id) {
pushDivider();