Compare commits
10 commits
1bc7877a8b
...
0540f22f5d
Author | SHA1 | Date | |
---|---|---|---|
0540f22f5d | |||
51f8c28c54 | |||
86af8145b4 | |||
fdfffd78e7 | |||
0dc485ca77 | |||
e5bdf63f2a | |||
46a135de22 | |||
25c5a0e4a8 | |||
0d0dccaf84 | |||
dc4494a1db |
7 changed files with 79 additions and 19 deletions
7
app.vue
7
app.vue
|
@ -23,11 +23,14 @@ onMounted(() => {
|
||||||
contextMenuHandler(e);
|
contextMenuHandler(e);
|
||||||
});
|
});
|
||||||
document.addEventListener("mousedown", (e) => {
|
document.addEventListener("mousedown", (e) => {
|
||||||
if (e.target instanceof HTMLElement && e.target.closest("#context-menu")) return;
|
if (e.target instanceof HTMLElement && e.target.classList.contains("context-menu-item")) return;
|
||||||
console.log("click");
|
console.log("click");
|
||||||
console.log("target:", e.target);
|
console.log("target:", e.target);
|
||||||
console.log(e.target instanceof HTMLDivElement);
|
console.log(e.target instanceof HTMLDivElement);
|
||||||
removeContextMenu(contextMenu);
|
if (contextMenu.value.show) {
|
||||||
|
console.log("context menu is shown, hiding");
|
||||||
|
removeContextMenu(contextMenu);
|
||||||
|
}
|
||||||
if (e.target instanceof HTMLElement && e.target.classList.contains("message-text") && e.target.contentEditable) {
|
if (e.target instanceof HTMLElement && e.target.classList.contains("message-text") && e.target.contentEditable) {
|
||||||
e.target.contentEditable = "false";
|
e.target.contentEditable = "false";
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="member-item" @click.prevent="showModalPopup" tabindex="0">
|
<div class="member-item" @click.prevent="showModalPopup" tabindex="0" @contextmenu="showContextMenu($event, contextMenu, menuItems)">
|
||||||
<Avatar :profile="props.member" class="member-avatar"/>
|
<Avatar :profile="props.member" class="member-avatar"/>
|
||||||
<span class="member-display-name" :style="`color: ${generateIrcColor(props.member.user.uuid)}`">
|
<span class="member-display-name" :style="`color: ${generateIrcColor(props.member.user.uuid)}`">
|
||||||
{{ getDisplayName(props.member) }}
|
{{ getDisplayName(props.member) }}
|
||||||
|
@ -11,14 +11,18 @@
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ModalProfilePopup } from '#components';
|
import { ModalProfilePopup } from '#components';
|
||||||
import type { GuildMemberResponse } from '~/types/interfaces';
|
import type { ContextMenuInterface, GuildMemberResponse } from '~/types/interfaces';
|
||||||
|
|
||||||
const { getDisplayName } = useProfile()
|
const { getDisplayName } = useProfile()
|
||||||
|
|
||||||
|
const contextMenu = useState<ContextMenuInterface>("contextMenu", () => ({ show: false, pointerX: 0, pointerY: 0, items: [] }));
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
member: GuildMemberResponse
|
member: GuildMemberResponse
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
const menuItems = await createMemberContextMenuItems(props.member, props.member.guild_uuid);
|
||||||
|
|
||||||
const modalPopupVisible = ref<boolean>(false);
|
const modalPopupVisible = ref<boolean>(false);
|
||||||
|
|
||||||
function showModalPopup() {
|
function showModalPopup() {
|
||||||
|
@ -31,6 +35,7 @@ function hideModalPopup() {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
||||||
.member-item {
|
.member-item {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
@ -41,4 +46,9 @@ function hideModalPopup() {
|
||||||
min-width: 2.3em;
|
min-width: 2.3em;
|
||||||
max-width: 2.3em;
|
max-width: 2.3em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.member-display-name {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div v-if="props.type == 'normal' || props.replyMessage" ref="messageElement" @contextmenu="showContextMenu($event, contextMenu, menuItems)" :id="props.last ? 'last-message' : undefined"
|
<div v-if="props.type == 'normal' || props.replyMessage" ref="messageElement" @contextmenu="showContextMenu($event, contextMenu, messageMenuItems)" :id="props.last ? 'last-message' : undefined"
|
||||||
class="message normal-message" :class="{ 'mentioned': (props.replyMessage || props.isMentioned) && props.message.member.user.uuid != props.me.uuid && props.replyMessage?.member.user.uuid == props.me.uuid }" :data-message-id="props.messageId"
|
class="message normal-message" :class="{ 'mentioned': (props.replyMessage || props.isMentioned) && props.message.member.user.uuid != props.me.uuid && props.replyMessage?.member.user.uuid == props.me.uuid }" :data-message-id="props.messageId"
|
||||||
:editing.sync="props.editing" :replying-to.sync="props.replyingTo">
|
:editing.sync="props.editing" :replying-to.sync="props.replyingTo">
|
||||||
<div v-if="props.replyMessage" class="message-reply-svg">
|
<div v-if="props.replyMessage" class="message-reply-svg">
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="message-data">
|
<div class="message-data">
|
||||||
<div class="message-metadata">
|
<div class="message-metadata">
|
||||||
<span class="message-author-username" tabindex="0" :style="`color: ${props.authorColor}`">
|
<span class="message-author-username" tabindex="0" :style="`color: ${props.authorColor}`" @contextmenu="showContextMenu($event, contextMenu, memberMenuItems)">
|
||||||
{{ getDisplayName(props.author) }}
|
{{ getDisplayName(props.author) }}
|
||||||
</span>
|
</span>
|
||||||
<span class="message-date" :title="date.toString()">
|
<span class="message-date" :title="date.toString()">
|
||||||
|
@ -47,7 +47,7 @@
|
||||||
</div>
|
</div>
|
||||||
<MessageMedia v-if="mediaLinks.length" :links="mediaLinks" />
|
<MessageMedia v-if="mediaLinks.length" :links="mediaLinks" />
|
||||||
</div>
|
</div>
|
||||||
<div v-else ref="messageElement" @contextmenu="showContextMenu($event, contextMenu, menuItems)" :id="props.last ? 'last-message' : undefined"
|
<div v-else ref="messageElement" @contextmenu="showContextMenu($event, contextMenu, messageMenuItems)" :id="props.last ? 'last-message' : undefined"
|
||||||
class="message grouped-message" :class="{ 'message-margin-bottom': props.marginBottom, 'mentioned': props.replyMessage || props.isMentioned }"
|
class="message grouped-message" :class="{ 'message-margin-bottom': props.marginBottom, 'mentioned': props.replyMessage || props.isMentioned }"
|
||||||
:data-message-id="props.messageId" :editing.sync="props.editing" :replying-to.sync="props.replyingTo">
|
:data-message-id="props.messageId" :editing.sync="props.editing" :replying-to.sync="props.replyingTo">
|
||||||
<div class="left-column">
|
<div class="left-column">
|
||||||
|
@ -72,6 +72,8 @@ import type { ContextMenuInterface, ContextMenuItem } from '~/types/interfaces';
|
||||||
|
|
||||||
const { getDisplayName } = useProfile()
|
const { getDisplayName } = useProfile()
|
||||||
|
|
||||||
|
const route = useRoute();
|
||||||
|
|
||||||
const props = defineProps<MessageProps>();
|
const props = defineProps<MessageProps>();
|
||||||
|
|
||||||
const contextMenu = useState<ContextMenuInterface>("contextMenu", () => ({ show: false, pointerX: 0, pointerY: 0, items: [] }));
|
const contextMenu = useState<ContextMenuInterface>("contextMenu", () => ({ show: false, pointerX: 0, pointerY: 0, items: [] }));
|
||||||
|
@ -144,21 +146,23 @@ console.log("media links:", mediaLinks);
|
||||||
// showHover.value = !showHover.value;
|
// showHover.value = !showHover.value;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
const menuItems: ContextMenuItem[] = [
|
const messageMenuItems: ContextMenuItem[] = [
|
||||||
{ name: "Reply", icon: "lucide:reply", type: "normal", callback: () => { if (messageElement.value) replyToMessage(messageElement.value, props) } }
|
{ name: "Reply", icon: "lucide:reply", type: "normal", callback: () => { if (messageElement.value) replyToMessage(messageElement.value, props) } }
|
||||||
]
|
]
|
||||||
|
|
||||||
console.log("me:", props.me);
|
console.log("me:", props.me);
|
||||||
if (props.author?.user.uuid == props.me.uuid) {
|
if (props.author.user.uuid == props.me.uuid) {
|
||||||
// Inserts "edit" option at index 1 (below the "reply" option)
|
// Inserts "edit" option at index 1 (below the "reply" option)
|
||||||
menuItems.splice(1, 0, { name: "Edit (WIP)", icon: "lucide:square-pen", type: "normal", callback: () => { /* if (messageElement.value) editMessage(messageElement.value, props) */ } });
|
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) */ } });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (props.author?.user.uuid == props.me.uuid /* || check message delete permission*/) {
|
if (props.author.user.uuid == props.me.uuid /* || check message delete permission*/) {
|
||||||
// Inserts "edit" option at index 2 (below the "edit" option)
|
// Inserts "edit" option at index 2 (below the "edit" option)
|
||||||
menuItems.splice(2, 0, { name: "Delete (WIP)", icon: "lucide:trash", type: "danger", callback: () => {} });
|
messageMenuItems.splice(Math.min(2, messageMenuItems.length), 0, { name: "Delete (WIP)", icon: "lucide:trash", type: "danger", callback: () => {} });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const memberMenuItems = await createMemberContextMenuItems(props.author, route.params.serverId as string);
|
||||||
|
|
||||||
function getDayDifference(date1: Date, date2: Date) {
|
function getDayDifference(date1: Date, date2: Date) {
|
||||||
const midnight1 = new Date(date1.getFullYear(), date1.getMonth(), date1.getDate());
|
const midnight1 = new Date(date1.getFullYear(), date1.getMonth(), date1.getDate());
|
||||||
const midnight2 = new Date(date2.getFullYear(), date2.getMonth(), date2.getDate());
|
const midnight2 = new Date(date2.getFullYear(), date2.getMonth(), date2.getDate());
|
||||||
|
@ -234,6 +238,10 @@ function getDayDifference(date1: Date, date2: Date) {
|
||||||
max-width: 2em;
|
max-width: 2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.message-author-username {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
.left-column {
|
.left-column {
|
||||||
min-width: 2rem;
|
min-width: 2rem;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
|
@ -18,6 +18,10 @@ onMounted(() => {
|
||||||
if (contextMenu) {
|
if (contextMenu) {
|
||||||
contextMenu.style.left = props.pointerX.toString() + "px";
|
contextMenu.style.left = props.pointerX.toString() + "px";
|
||||||
contextMenu.style.top = props.pointerY.toString() + "px";
|
contextMenu.style.top = props.pointerY.toString() + "px";
|
||||||
|
const rect = contextMenu.getBoundingClientRect();
|
||||||
|
if (rect.right > (window.innerWidth || document.documentElement.clientWidth)) {
|
||||||
|
contextMenu.style.left = (props.pointerX - contextMenu.clientWidth).toString() + "px";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,17 @@ export const useApi = () => {
|
||||||
return await fetchWithApi("/me")
|
return await fetchWithApi("/me")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function fetchMeMember(guildId: string): Promise<GuildMemberResponse | undefined> {
|
||||||
|
const { getUser } = useAuth();
|
||||||
|
|
||||||
|
const me = await getUser();
|
||||||
|
if (me) {
|
||||||
|
const members = await fetchMembers(guildId);
|
||||||
|
const meMember = members.objects.find(member => member.user.uuid == me.uuid);
|
||||||
|
return meMember;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function fetchChannels(guildId: string): Promise<ChannelResponse[]> {
|
async function fetchChannels(guildId: string): Promise<ChannelResponse[]> {
|
||||||
return ensureIsArray(await fetchWithApi(`/guilds/${guildId}/channels`));
|
return ensureIsArray(await fetchWithApi(`/guilds/${guildId}/channels`));
|
||||||
}
|
}
|
||||||
|
@ -47,6 +58,14 @@ export const useApi = () => {
|
||||||
async function fetchMember(guildId: string, memberId: string): Promise<GuildMemberResponse | undefined> {
|
async function fetchMember(guildId: string, memberId: string): Promise<GuildMemberResponse | undefined> {
|
||||||
return await fetchWithApi(`/guilds/${guildId}/members/${memberId}`);
|
return await fetchWithApi(`/guilds/${guildId}/members/${memberId}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function kickMember(memberId: string) {
|
||||||
|
return await fetchWithApi(`/members/${memberId}`, { method: "DELETE" });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function banMember(guildId: string, memberId: string) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
async function fetchUsers() {
|
async function fetchUsers() {
|
||||||
return await fetchWithApi(`/users`);
|
return await fetchWithApi(`/users`);
|
||||||
|
@ -114,10 +133,13 @@ export const useApi = () => {
|
||||||
fetchGuild,
|
fetchGuild,
|
||||||
fetchMyGuilds,
|
fetchMyGuilds,
|
||||||
fetchMe,
|
fetchMe,
|
||||||
|
fetchMeMember,
|
||||||
fetchChannels,
|
fetchChannels,
|
||||||
fetchChannel,
|
fetchChannel,
|
||||||
fetchMembers,
|
fetchMembers,
|
||||||
fetchMember,
|
fetchMember,
|
||||||
|
kickMember,
|
||||||
|
banMember,
|
||||||
fetchUsers,
|
fetchUsers,
|
||||||
fetchUser,
|
fetchUser,
|
||||||
fetchFriends,
|
fetchFriends,
|
||||||
|
|
|
@ -56,7 +56,7 @@ const showGuildSettings = ref(false);
|
||||||
//const servers = await fetchWithApi("/servers") as { uuid: string, name: string, description: string }[];
|
//const servers = await fetchWithApi("/servers") as { uuid: string, name: string, description: string }[];
|
||||||
//console.log("channelid: servers:", servers);
|
//console.log("channelid: servers:", servers);
|
||||||
|
|
||||||
const { fetchMembers } = useApi();
|
const { fetchMembers, fetchMeMember } = useApi();
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
console.log("mounting");
|
console.log("mounting");
|
||||||
|
@ -84,6 +84,14 @@ async function setArrayVariables() {
|
||||||
console.log("channels:", channels.value);
|
console.log("channels:", channels.value);
|
||||||
channel.value = await fetchWithApi(`/channels/${route.params.channelId}`);
|
channel.value = await fetchWithApi(`/channels/${route.params.channelId}`);
|
||||||
console.log("channel:", channel.value);
|
console.log("channel:", channel.value);
|
||||||
|
const meMember = useState<GuildMemberResponse | undefined>("meMember");
|
||||||
|
console.log("[CHANNEL] meMember:", meMember.value);
|
||||||
|
if (!meMember.value) {
|
||||||
|
console.log("[CHANNEL] meMember is uninitialized, initializing");
|
||||||
|
const fetchedMeMember = await fetchMeMember(route.params.serverId as string);
|
||||||
|
meMember.value = fetchedMeMember;
|
||||||
|
console.log("[CHANNEL] meMember set to:", fetchedMeMember);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleGuildSettings(e: Event) {
|
function toggleGuildSettings(e: Event) {
|
||||||
|
|
|
@ -3,10 +3,15 @@ import ContextMenu from "~/components/UserInterface/ContextMenu.vue";
|
||||||
import type { ContextMenuInterface, ContextMenuItem } from "~/types/interfaces";
|
import type { ContextMenuInterface, ContextMenuItem } from "~/types/interfaces";
|
||||||
|
|
||||||
export default (e: MouseEvent | PointerEvent, contextMenu: ContextMenuInterface, menuItems: ContextMenuItem[]) => {
|
export default (e: MouseEvent | PointerEvent, contextMenu: ContextMenuInterface, menuItems: ContextMenuItem[]) => {
|
||||||
console.log("Showing context menu");
|
e.preventDefault();
|
||||||
contextMenu.show = true;
|
e.stopPropagation();
|
||||||
contextMenu.pointerX = e.clientX;
|
console.log("Menu items:", menuItems);
|
||||||
contextMenu.pointerY = e.clientY;
|
if (menuItems.length) {
|
||||||
contextMenu.items = menuItems;
|
console.log("Showing context menu");
|
||||||
console.log("Showed");
|
contextMenu.show = true;
|
||||||
|
contextMenu.pointerX = e.clientX;
|
||||||
|
contextMenu.pointerY = e.clientY;
|
||||||
|
contextMenu.items = menuItems;
|
||||||
|
console.log("Showed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue