mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-07 01:15:28 +00:00
fix: add context menu to individual attachments if > 1 attached (#348)
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user