diff --git a/components/Message.vue b/components/Message.vue
index c926616..8be0d66 100644
--- a/components/Message.vue
+++ b/components/Message.vue
@@ -43,9 +43,9 @@
{{ date.toLocaleTimeString(undefined, { hour12: props.format == "12", timeStyle: "short" }) }}
-
+
+
-
@@ -89,10 +89,10 @@ console.log("[MSG] reply message:", props.replyMessage);
const linkRegex = /https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)/g;
const linkMatches = props.message.message.matchAll(linkRegex).map(link => link[0]);
-const mediaLinks: string[] = [];
+const mediaLinks = ref([]);
console.log("link matches:", linkMatches);
-const hasEmbed = ref(false);
+const hideText = ref(false);
const sanitized = ref();
@@ -121,23 +121,35 @@ onMounted(async () => {
console.log("added listeners");
}
+ const links: string[] = [];
for (const link of linkMatches) {
- console.log("link:", link);
- try {
- const res = await $fetch.raw(link);
- if (res.ok && res.headers.get("content-type")?.match(/^image\/(apng|gif|jpeg|png|webp)$/)) {
- console.log("link is image");
- mediaLinks.push(link);
+ console.log("link:", link);
+ try {
+ const res = await $fetch.raw(link);
+ if (res.ok && res.headers.get("content-type")?.match(/^image\/(apng|gif|jpeg|png|webp)$/)) {
+ console.log("link is image");
+ links.push(link);
+ }
+ } catch (error) {
+ console.error(error);
}
- if (mediaLinks.length) {
- hasEmbed.value = true
- };
- } catch (error) {
- console.error(error);
- }
-}
-console.log("media links:", mediaLinks);
+ mediaLinks.value = [...links];
+ }
+
+ if (mediaLinks.value.length) {
+ const nonLinks = props.message.message.split(linkRegex);
+ let invalidContent = false;
+ for (const nonLink of nonLinks) {
+ if (nonLink != "" && nonLink != "\n" && nonLink != "
") {
+ invalidContent = true;
+ break;
+ }
+ }
+ hideText.value = !invalidContent;
+ };
+
+ console.log("media links:", mediaLinks);
});
//function toggleTooltip(e: Event) {
@@ -177,9 +189,8 @@ function getDayDifference(date1: Date, date2: Date) {
text-align: left;
/* border: 1px solid lightcoral; */
display: grid;
- grid-template-columns: 2rem 1fr;
+ grid-template-columns: 4rem 1fr;
align-items: center;
- column-gap: 1dvw;
width: 100%;
overflow-wrap: anywhere;
}
@@ -213,10 +224,9 @@ function getDayDifference(date1: Date, date2: Date) {
.message-data {
/* border: 1px solid white; */
- margin-left: .5dvw;
display: flex;
flex-direction: column;
- height: fit-content;
+ height: 100%;
width: 100%;
grid-row: 2;
grid-column: 2;
@@ -228,10 +238,10 @@ function getDayDifference(date1: Date, date2: Date) {
}
.message-author-avatar {
- min-height: 2em;
- max-height: 2em;
- min-width: 2em;
- max-width: 2em;
+ min-height: 2.5em;
+ max-height: 2.5em;
+ min-width: 2.5em;
+ max-width: 2.5em;
}
.left-column {
@@ -242,8 +252,11 @@ function getDayDifference(date1: Date, date2: Date) {
white-space: nowrap;
grid-row: 2;
grid-column: 1;
+ height: 100%;
+ align-items: start;
}
+
.author-username {
margin-right: .5dvw;
color: white;
diff --git a/components/MessageMedia.vue b/components/MessageMedia.vue
index ab62387..0a8ff16 100644
--- a/components/MessageMedia.vue
+++ b/components/MessageMedia.vue
@@ -34,9 +34,16 @@ function createModal(link: string) {