From 50308ce43ceca2ec02e2aaacf14796ae809dd336 Mon Sep 17 00:00:00 2001 From: Nicholas Pease Date: Fri, 19 Apr 2024 00:09:51 -0400 Subject: [PATCH 1/3] Fix Delete --- frontend-next/src/components/app/datatypes.js | 2 +- frontend-next/src/components/app/friends/page.js | 2 +- frontend-next/src/components/app/page/chat.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend-next/src/components/app/datatypes.js b/frontend-next/src/components/app/datatypes.js index 48da176..602fb96 100644 --- a/frontend-next/src/components/app/datatypes.js +++ b/frontend-next/src/components/app/datatypes.js @@ -111,7 +111,7 @@ const generateColor = (user_str) => { */ export function Chat({ chatObj, user, path }) { function deleteMessage() { - remove(ref(database, `/rooms/${path}/chats/${chatObj.timestamp}-${chatObj.user}`)) + remove(ref(database, `${path}/chats/${chatObj.timestamp}-${chatObj.user}`)) } var messageFilterBypass = [undefined, null, '', ' ', '\'', '\"'] if (!messageFilterBypass.includes(chatObj.body) && (chatObj.body.length != 1 && !chatObj.body[0].match(/\W/))) { diff --git a/frontend-next/src/components/app/friends/page.js b/frontend-next/src/components/app/friends/page.js index fc0a6b7..2d6e84b 100644 --- a/frontend-next/src/components/app/friends/page.js +++ b/frontend-next/src/components/app/friends/page.js @@ -36,7 +36,7 @@ export function DMRoom({ roomObj, user }) { ); diff --git a/frontend-next/src/components/app/page/chat.js b/frontend-next/src/components/app/page/chat.js index 254c174..4df9604 100644 --- a/frontend-next/src/components/app/page/chat.js +++ b/frontend-next/src/components/app/page/chat.js @@ -36,7 +36,7 @@ export function ChatRoom({ roomObj, user }) { ); -- 2.52.0 From f1e23ac056b3d90a8b1a5075cfea6d47ae512ea7 Mon Sep 17 00:00:00 2001 From: Nicholas Pease Date: Fri, 19 Apr 2024 01:59:43 -0400 Subject: [PATCH 2/3] Better Picture Detection / Handling --- frontend-next/src/components/app/datatypes.js | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/frontend-next/src/components/app/datatypes.js b/frontend-next/src/components/app/datatypes.js index 48da176..d17892f 100644 --- a/frontend-next/src/components/app/datatypes.js +++ b/frontend-next/src/components/app/datatypes.js @@ -37,29 +37,42 @@ let dateOptions = { minute: "2-digit", }; +/** + * Photo URL Test + * @param {String} url - URL to Test + * @returns {Boolean} - Image Loaded (True) or Not (False) + */ +function imageProcessing(url) { + var img = new Image(); + img.src = url; + return img.complete; +} + + /** * Rich Message Formatting * @param {String} message - Message to Format * @returns {String} - Formatted Message (IN HTML) */ function RMF(message) { - var IMG_END = [".jpg", ".jpeg", ".png", ".gif", ".webp"] var URLREGEX = /[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/g; var URLmatch = message.match(URLREGEX); var newMessage = URLmatch ? [] : message if (URLmatch) { for (var i = 0; i < URLmatch.length; i++) { - if (IMG_END.includes(URLmatch[i].slice(-4)) || IMG_END.includes(URLmatch[i].slice(-5))) { - // Its a photo - newMessage.push(()) - } else { + if (imageProcessing("https://"+URLmatch[i])) { newMessage.push(( - {URLmatch.length == 1 && message.split(URLmatch[i])[0]} - {URLmatch[i]} + {(URLmatch.length == 1) && message.split(URLmatch[i])[0].replace("https://","")} + {(i == URLmatch.length || URLmatch.length == 1) && message.split(URLmatch[i])[1]} )) + } else { + newMessage.push(( + {URLmatch.length == 1 && message.split(URLmatch[i])[0]} + {URLmatch[i]} + {(i == URLmatch.length || URLmatch.length == 1) && message.split(URLmatch[i])[1]} + )) } - } } return newMessage -- 2.52.0 From 45f9ec19d192e2a2bd638ac780de40651a287c50 Mon Sep 17 00:00:00 2001 From: Nicholas Pease Date: Fri, 19 Apr 2024 02:08:03 -0400 Subject: [PATCH 3/3] Circle Icon Fix --- frontend-next/src/components/app/friends/dm.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend-next/src/components/app/friends/dm.js b/frontend-next/src/components/app/friends/dm.js index 44071c1..d42f2cc 100644 --- a/frontend-next/src/components/app/friends/dm.js +++ b/frontend-next/src/components/app/friends/dm.js @@ -3,7 +3,7 @@ import { database } from "../../../../firebase-config" import { ref, set, get } from "firebase/database"; import ChatIcon from '@mui/icons-material/Chat'; - +import CircleIcon from '@mui/icons-material/Circle'; export function openDM(user, uid) { var uid1 = user.uid < uid? user.uid : uid -- 2.52.0