From a9bac2afa679240813ff27ba35d499d2fcf75ed2 Mon Sep 17 00:00:00 2001 From: Bill Date: Wed, 3 Aug 2022 22:16:44 -0400 Subject: [PATCH] Chat changes --- src/api/utils/RoomChatFormatter.ts | 13 ++++++------- src/components/room/widgets/chat/ChatWidgetView.tsx | 7 ++++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/api/utils/RoomChatFormatter.ts b/src/api/utils/RoomChatFormatter.ts index 9c80de72..8da83aca 100644 --- a/src/api/utils/RoomChatFormatter.ts +++ b/src/api/utils/RoomChatFormatter.ts @@ -1,6 +1,7 @@ import * as joypixels from 'emoji-toolkit'; const allowedColours: Map = new Map(); + allowedColours.set('r', 'red'); allowedColours.set('b', 'blue'); allowedColours.set('g', 'green'); @@ -23,14 +24,13 @@ allowedColours.set('brown', 'brown'); allowedColours.set('purple', 'purple'); allowedColours.set('pink', 'pink'); -function encodeHTML(str: string) +const encodeHTML = (str: string) => { - return str.replace(/([\u00A0-\u9999<>&])(.|$)/g, function(full, char, next) + return str.replace(/([\u00A0-\u9999<>&])(.|$)/g, (full, char, next) => { if(char !== '&' || next !== '#') { - if(/[\u00A0-\u9999<>&]/.test(next)) - next = '&#' + next.charCodeAt(0) + ';'; + if(/[\u00A0-\u9999<>&]/.test(next)) next = '&#' + next.charCodeAt(0) + ';'; return '&#' + char.charCodeAt(0) + ';' + next; } @@ -39,12 +39,11 @@ function encodeHTML(str: string) }); } - -export function RoomChatFormatter(content: string): string +export const RoomChatFormatter = (content: string) => { let result = ''; - content = encodeHTML(content) + content = encodeHTML(content); content = (joypixels.shortnameToUnicode(content) as string) if(content.startsWith('@') && content.indexOf('@', 1) > -1) diff --git a/src/components/room/widgets/chat/ChatWidgetView.tsx b/src/components/room/widgets/chat/ChatWidgetView.tsx index 4a28746b..88d97e60 100644 --- a/src/components/room/widgets/chat/ChatWidgetView.tsx +++ b/src/components/room/widgets/chat/ChatWidgetView.tsx @@ -22,16 +22,17 @@ export const ChatWidgetView: FC<{}> = props => { const collides = chatMessages[i]; - if(!collides || (chat === collides) || (tempChats.indexOf(collides) >= 0) || ((collides.top - moved) >= (chat.top + chat.height))) continue; + if(!collides || (chat === collides) || (tempChats.indexOf(collides) >= 0) || (((collides.top + collides.height) - moved) > (chat.top + chat.height))) continue; - if(DoChatsOverlap(chat, collides, -moved, 4)) + chat.skipMovement = true; + + if(DoChatsOverlap(chat, collides, -moved, 0)) { const amount = Math.abs((collides.top + collides.height) - chat.top); tempChats.push(collides); collides.top -= amount; - collides.skipMovement = true; checkOverlappingChats(collides, amount, tempChats);