Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
MrQuackDuck committed Dec 11, 2024
1 parent cff00f3 commit 4caa540
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 77 deletions.
124 changes: 64 additions & 60 deletions src/shared/lib/emojis.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
{
"SMILEYS_AND_EMOTICON": [
{
"value": "😁",
"name": "beaming face with smiling eyes :grin:"
},
{
"value": "😂",
"name": "face with tears of joy :joy:"
},
{
"value": "😍",
"name": "smiling face with heart-eyes :heart_eyes:"
"value": "😢",
"name": "crying face :cry:"
},
{
"value": "😭",
"name": "loudly crying face :sob:"
},
{
"value": "😎",
"name": "smiling face with sunglasses cool :sunglasses:"
},
{
"value": "🤯",
"name": "exploding head mind blown :exploding_head:"
},
{
"value": "🤩",
"name": "star struck stars in eyes :star-struck:"
},
{
"value": "😊",
"name": "smiling face with smiling eyes :blush:"
Expand All @@ -25,8 +41,8 @@
"name": "face blowing a kiss :kissing_heart:"
},
{
"value": "💕",
"name": "two hearts :two_hearts:"
"value": "😍",
"name": "smiling face with heart-eyes :heart_eyes:"
},
{
"value": "😩",
Expand All @@ -40,10 +56,6 @@
"value": "😏",
"name": "smirking face :smirk:"
},
{
"value": "😁",
"name": "beaming face with smiling eyes :grin:"
},
{
"value": "😉",
"name": "winking face :wink:"
Expand All @@ -60,14 +72,6 @@
"value": "🙈",
"name": "see-no-evil monkey :see_no_evil:"
},
{
"value": "😢",
"name": "crying face :cry:"
},
{
"value": "😎",
"name": "smiling face with sunglasses cool :sunglasses:"
},
{
"value": "😅",
"name": "grinning face with sweat :sweat_smile:"
Expand All @@ -81,29 +85,65 @@
"name": "grinning face with smiling eyes :smile:"
},
{
"value": "💜",
"name": "purple heart :purple_heart:"
},
{
"value": "💔",
"name": "broken heart :broken_heart:"
"value": "😑",
"name": "expressionless face :expressionless:"
},
{
"value": "💯",
"name": "hundred points :hundred_points:"
},
{
"value": "😑",
"name": "expressionless face :expressionless:"
"value": "",
"name": "red heart :red_heart:"
},
{
"value": "💋",
"name": "kiss mark :kiss:"
},
{
"value": "💘",
"name": "heart with arrow :cupid:"
},
{
"value": "💗",
"name": "growing heart :heartpulse:"
},
{
"value": "💞",
"name": "revolving hearts :revolving_hearts:"
},
{
"value": "💕",
"name": "two hearts :two_hearts:"
},
{
"value": "💔",
"name": "broken heart :broken_heart:"
},
{
"value": "💓",
"name": "beating heart :heartbeat:"
},
{
"value": "💖",
"name": "sparkling heart :sparkling_heart:"
},
{
"value": "💛",
"name": "yellow heart :yellow_heart:"
},
{
"value": "💙",
"name": "blue heart :blue_heart:"
},
{
"value": "💚",
"name": "green heart :green_heart:"
},
{
"value": "💜",
"name": "purple heart :purple_heart:"
},
{
"value": "😕",
"name": "confused face :confused:"
Expand All @@ -128,26 +168,10 @@
"value": "😪",
"name": "sleepy face :sleepy:"
},
{
"value": "💘",
"name": "heart with arrow :cupid:"
},
{
"value": "💗",
"name": "growing heart :heartpulse:"
},
{
"value": "💞",
"name": "revolving hearts :revolving_hearts:"
},
{
"value": "🙊",
"name": "speak-no-evil monkey :speak_no_evil:"
},
{
"value": "💋",
"name": "kiss mark :kiss:"
},
{
"value": "😱",
"name": "face screaming in fear :scream:"
Expand All @@ -172,10 +196,6 @@
"value": "💀",
"name": "skull skeleton :skull:"
},
{
"value": "💛",
"name": "yellow heart :yellow_heart:"
},
{
"value": "😤",
"name": "face with steam from nose :triumph:"
Expand All @@ -200,18 +220,10 @@
"value": "😷",
"name": "face with medical mask :mask:"
},
{
"value": "💚",
"name": "green heart :green_heart:"
},
{
"value": "😣",
"name": "persevering face :persevere:"
},
{
"value": "💓",
"name": "beating heart :heartbeat:"
},
{
"value": "😚",
"name": "kissing face with closed eyes :kissing_closed_eyes:"
Expand Down Expand Up @@ -436,17 +448,9 @@
"value": "🗨",
"name": "left speech bubble :speech_left:"
},
{
"value": "",
"name": "smiling face :smiling_face:"
},
{
"value": "",
"name": "heart exclamation :heart_exclamation:"
},
{
"value": "",
"name": "red heart :red_heart:"
}
],
"PEOPLE_AND_BODY": [
Expand Down
30 changes: 13 additions & 17 deletions src/widgets/chat-section/ui/ChatSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ function ChatSection({ room, setAsideVisibility, setVoiceChatSectionVisibility }
if (!scrollAreaRef.current) return;
if (isSmooth) scrollAreaRef.current.scrollTo({ top: scrollAreaRef.current.scrollHeight, behavior: "smooth" });
else scrollAreaRef.current.scrollTop = scrollAreaRef.current.scrollHeight;

let lastMessage = messages[messages.length - 1];
lastMessageIdScrolledToBottom.current = lastMessage?.id;
}, 0);
}

Expand Down Expand Up @@ -286,35 +289,28 @@ function ChatSection({ room, setAsideVisibility, setVoiceChatSectionVisibility }
let mainSection = useRef<any>();

// Count the number of messages in each room to control the scroll behavior
const [roomMessagesCount, setRoomMessagesCount] = useState<{[roomGuid: string]: number}>({});
const [roomMessagesCount, setRoomMessagesCount] = useState<{ [roomGuid: string]: number }>({});
const lastMessageIdScrolledToBottom = useRef<number | null>(null);
useEffect(() => {
if (selectedRoomConnection == null) return setMessagesLoaded(false);
if (messages.length == 0 && selectedRoomConnection.connection.state != HubConnectionState.Connected) return setMessagesLoaded(false);

setMessagesLoaded(true);

// Get the current room's GUID

const currentRoomGuid = selectedRoomConnection.roomGuid;

// Get the previous message count for this room
const previousMessageCount = roomMessagesCount[currentRoomGuid] || 0;

// Check if the current messages count is higher than the previous count
const hasNewMessage = messages.length > previousMessageCount;

// Update the messages count for the current room
setRoomMessagesCount(prev => ({

setRoomMessagesCount((prev) => ({
...prev,
[currentRoomGuid]: messages.length
}));

let lastMessage = messages[messages.length - 1];
const hasNewMessage = messages.length > previousMessageCount && lastMessageIdScrolledToBottom.current != lastMessage?.id;
lastMessageIdScrolledToBottom.current = lastMessage?.id;

let theLastMessageIsNewAndUserIsNearBottom: () => boolean = () => (hasNewMessage && isNearBottom(300)) ?? false;
let theLastMessageIsNewAndCurrentUserIsAuthor: () => boolean = () => (
hasNewMessage &&
lastMessage &&
lastMessage.authorHexId == currentUser?.hexId
);
let theLastMessageIsNewAndCurrentUserIsAuthor: () => boolean = () => hasNewMessage && lastMessage && lastMessage.authorHexId == currentUser?.hexId;

// Scroll to the bottom when the user sends a message
if (theLastMessageIsNewAndUserIsNearBottom() || theLastMessageIsNewAndCurrentUserIsAuthor()) {
Expand Down

0 comments on commit 4caa540

Please sign in to comment.