@@ -27,12 +27,12 @@
:text="props.replyMessage?.message"
:reply-id="props.replyMessage.uuid" max-width="reply" />
@@ -70,7 +70,7 @@ import { parse } from 'marked';
import type { MessageProps } from '~/types/props';
import MessageMedia from './MessageMedia.vue';
import MessageReply from './UserInterface/MessageReply.vue';
-import type { ContextMenuInterface, ContextMenuItem, IConfirmationModal } from '~/types/interfaces';
+import type { ContextMenuInterface, ContextMenuItem, ContextMenuSection, IConfirmationModal } from '~/types/interfaces';
const { getDisplayName } = useProfile()
const { getUser } = useAuth()
@@ -81,7 +81,7 @@ const props = defineProps();
const me = await getUser()
-const contextMenu = useState("contextMenu", () => ({ show: false, pointerX: 0, pointerY: 0, items: [] }));
+const contextMenu = useState("contextMenu", () => ({ show: false, pointerX: 0, pointerY: 0, sections: [] }));
const messageElement = ref();
@@ -93,7 +93,7 @@ const currentDate: Date = new Date()
const confirmationModal = ref();
-const memberMenuItems = ref([]);
+const memberMenuSections = ref([]);
console.log("[MSG] message to render:", props.message);
console.log("author:", props.message.member);
@@ -164,28 +164,37 @@ onMounted(async () => {
console.log("media links:", mediaLinks);
console.log("[CONFIRM] modal:", confirmationModal.value);
- memberMenuItems.value = await createMemberContextMenuItems(props.message.member, route.params.serverId as string, confirmationModal);
+ memberMenuSections.value = await createMemberContextMenuItems(props.message.member, route.params.serverId as string, confirmationModal);
});
//function toggleTooltip(e: Event) {
// showHover.value = !showHover.value;
//}
-const messageMenuItems: ContextMenuItem[] = [
- { name: "Reply", icon: "lucide:reply", type: "normal", callback: () => { if (messageElement.value) replyToMessage(messageElement.value, props) } }
-]
+const messageMenuSections: ContextMenuSection[] = [];
+
+const regularSection: ContextMenuSection = {
+ items: [
+ {
+ name: "Reply",
+ icon: "lucide:reply",
+ type: "normal",
+ callback: () => { if (messageElement.value) replyToMessage(messageElement.value, props)}
+ }
+ ]
+};
console.log("me:", me);
if (props.message.member.user.uuid == me!.uuid) {
- // Inserts "edit" option at index 1 (below the "reply" option)
- messageMenuItems.splice(Math.min(1, messageMenuItems.length), 0, { name: "Edit (WIP)", icon: "lucide:square-pen", type: "normal", callback: () => { /* if (messageElement.value) editMessage(messageElement.value, props) */ } });
+ regularSection.items.push({ name: "Edit (WIP)", icon: "lucide:square-pen", type: "normal", callback: () => { /* if (messageElement.value) editMessage(messageElement.value, props) */ } });
}
-if (props.message.member.user.uuid == me!.uuid /* || check message delete permission*/) {
- // Inserts "edit" option at index 2 (below the "edit" option)
- messageMenuItems.splice(Math.min(2, messageMenuItems.length), 0, { name: "Delete (WIP)", icon: "lucide:trash", type: "danger", callback: () => {} });
+if (props.message.member.user.uuid == me!.uuid) {
+ regularSection.items.push({ name: "Delete (WIP)", icon: "lucide:trash", type: "danger", callback: () => {} });
}
+messageMenuSections.push(regularSection);
+
function getDayDifference(date1: Date, date2: Date) {
const midnight1 = new Date(date1.getFullYear(), date1.getMonth(), date1.getDate());
const midnight2 = new Date(date2.getFullYear(), date2.getMonth(), date2.getDate());
diff --git a/components/UserInterface/ContextMenu.vue b/components/UserInterface/ContextMenu.vue
index 5d3a4be..2392097 100644
--- a/components/UserInterface/ContextMenu.vue
+++ b/components/UserInterface/ContextMenu.vue
@@ -1,17 +1,23 @@