Merge branch 'main' into improved-context-menu
This commit is contained in:
commit
4bbce93729
3 changed files with 16 additions and 24 deletions
|
@ -129,9 +129,6 @@ onMounted(async () => {
|
||||||
}
|
}
|
||||||
if (mediaLinks.length) {
|
if (mediaLinks.length) {
|
||||||
hasEmbed.value = true
|
hasEmbed.value = true
|
||||||
setTimeout(() => {
|
|
||||||
scrollToBottom(document.getElementById("messages") as HTMLDivElement);
|
|
||||||
}, 500);
|
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div id="message-area">
|
<div id="message-area">
|
||||||
<div id="messages" ref="messagesElement">
|
<div id="messages" ref="messagesElement">
|
||||||
<Message v-for="(message, i) of messages" :username="getDisplayName(message.user)"
|
<Message v-for="(message, i) of messages" :username="getDisplayName(message.user)" :key="message.uuid"
|
||||||
:text="message.message" :timestamp="messageTimestamps[message.uuid]" :img="message.user.avatar"
|
:text="message.message" :timestamp="messageTimestamps[message.uuid]" :img="message.user.avatar"
|
||||||
:format="timeFormat" :type="messagesType[message.uuid]"
|
:format="timeFormat" :type="messagesType[message.uuid]"
|
||||||
:margin-bottom="(messages[i + 1] && messagesType[messages[i + 1].uuid] == 'normal') ?? false"
|
:margin-bottom="(messages[i + 1] && messagesType[messages[i + 1].uuid] == 'normal') ?? false"
|
||||||
|
@ -237,12 +237,8 @@ function sendMessage(e: Event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getReplyMessage(id: string) {
|
function getReplyMessage(id: string) {
|
||||||
console.log("[REPLYMSG] id:", id);
|
|
||||||
const messagesValues = Object.values(messages.value);
|
const messagesValues = Object.values(messages.value);
|
||||||
console.log("[REPLYMSG] messages values:", messagesValues);
|
|
||||||
for (const message of messagesValues) {
|
for (const message of messagesValues) {
|
||||||
console.log("[REPLYMSG] message:", message);
|
|
||||||
console.log("[REPLYMSG] IDs match?", message.uuid == id);
|
|
||||||
if (message.uuid == id) return message;
|
if (message.uuid == id) return message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -266,21 +262,14 @@ onMounted(async () => {
|
||||||
if (fetched) return;
|
if (fetched) return;
|
||||||
fetched = true;
|
fetched = true;
|
||||||
console.log("scroll height is at 10% or less");
|
console.log("scroll height is at 10% or less");
|
||||||
//console.log("current oldest:", currentOldestMessage);
|
|
||||||
const olderMessages = await fetchMessages(route.params.channelId as string, { amount, offset });
|
const olderMessages = await fetchMessages(route.params.channelId as string, { amount, offset });
|
||||||
if (olderMessages) {
|
if (olderMessages?.length) {
|
||||||
olderMessages.reverse();
|
olderMessages.reverse();
|
||||||
console.log("older messages:", olderMessages);
|
messages.value = [...olderMessages.map(msg => reactive(msg)), ...messages.value];
|
||||||
if (olderMessages.length == 0) return;
|
|
||||||
olderMessages.reverse();
|
|
||||||
for (const [i, oldMessage] of olderMessages.entries()) {
|
|
||||||
console.log("old message:", oldMessage);
|
|
||||||
messages.value.unshift(oldMessage);
|
|
||||||
for (const message of messages.value) {
|
for (const message of messages.value) {
|
||||||
groupMessage(message);
|
groupMessage(message);
|
||||||
}
|
}
|
||||||
}
|
offset += amount;
|
||||||
offset += offset;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fetched = false;
|
fetched = false;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div ref="resizableSidebar" class="resizable-sidebar"
|
<div ref="resizableSidebar" class="resizable-sidebar"
|
||||||
:style="{
|
:style="{
|
||||||
'width': storedWidth ? `${storedWidth}px` : props.width,
|
'width': storedWidth ? storedWidth : props.width,
|
||||||
'min-width': props.minWidth,
|
'min-width': props.minWidth,
|
||||||
'max-width': props.maxWidth,
|
'max-width': props.maxWidth,
|
||||||
'border': props.borderSides == 'all' ? borderStyling : undefined,
|
'border': props.borderSides == 'all' ? borderStyling : undefined,
|
||||||
|
@ -29,12 +29,18 @@ const borderStyling = ".1rem solid var(--padding-color)";
|
||||||
|
|
||||||
const resizableSidebar = ref<HTMLDivElement>();
|
const resizableSidebar = ref<HTMLDivElement>();
|
||||||
const widthResizer = ref<HTMLDivElement>();
|
const widthResizer = ref<HTMLDivElement>();
|
||||||
const storedWidth = ref<number>();
|
const storedWidth = ref<string>();
|
||||||
|
|
||||||
const contextMenu = useState<ContextMenuInterface>("contextMenu");
|
const contextMenu = useState<ContextMenuInterface>("contextMenu");
|
||||||
|
|
||||||
const menuItems: ContextMenuItem[] = [
|
const menuItems: ContextMenuItem[] = [
|
||||||
{ name: "Reset", callback: () => { resizableSidebar.value!.style.width = props.width ?? props.minWidth } }
|
{ name: "Reset", callback: () => {
|
||||||
|
const defaultWidth = props.width ?? props.minWidth;
|
||||||
|
resizableSidebar.value!.style.width = defaultWidth;
|
||||||
|
if (props.localStorageName) {
|
||||||
|
localStorage.setItem(props.localStorageName, defaultWidth);
|
||||||
|
}
|
||||||
|
} }
|
||||||
]
|
]
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
@ -90,7 +96,7 @@ function loadStoredWidth() {
|
||||||
if (props.localStorageName) {
|
if (props.localStorageName) {
|
||||||
const storedWidthValue = localStorage.getItem(props.localStorageName);
|
const storedWidthValue = localStorage.getItem(props.localStorageName);
|
||||||
if (storedWidthValue) {
|
if (storedWidthValue) {
|
||||||
storedWidth.value = parseInt(storedWidthValue) || undefined;
|
storedWidth.value = storedWidthValue;
|
||||||
console.log("[res] loaded stored width");
|
console.log("[res] loaded stored width");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue