Closed 6lr61 closed 3 months ago
The enhancement focuses on improving the handling of emote updates within the runSevenTVWebsocket
function. The update introduces additional conditions to better manage the lifecycle of emotes, specifically by addressing both updated and removed emotes more comprehensively in the iteration process. Additionally, in the loadEmotes.ts
file, the quality of displayed emotes has been enhanced by selecting the largest emote for better visual experience.
File | Change Summary |
---|---|
.../sevenTV/sevenTVWebsocket.ts .../chat/loadEmotes.ts |
|
Enhanced the handling of emote updates in runSevenTVWebsocket by including conditions for updated emotes in addition to existing ones for added and pushed emotes. Updated the handling of removed emotes by iterating over updated emotes along with removed and pulled emotes. Improved addSevenTVEmote in loadEmotes.ts to select the largest emote for better quality, specifically looking for '3x.webp' or '3x.avif' files. |
server/src/chat/loadEmotes.ts (2)
`105-106`: Consider simplifying the file selection logic. The current implementation uses a hard-coded check for '3x.webp' or '3x.avif'. Consider using a more flexible approach that selects the largest available file based on a sorted list of file sizes. This would make the code more adaptable to changes in file naming conventions or additional file types. --- `102-109`: > :memo: **NOTE** > This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [106-125] Optimize the repeated code for setting emote properties. The properties for `sevenTVEmotesForClient` are set in two places within the `addSevenTVEmote` function, leading to code duplication. Consider refactoring this into a separate function or method that can be called with the necessary parameters. ```diff + function setEmoteProperties(emoteData, file) { + const imageUrl = `${emoteData.host.url}/${file.name}`; + sevenTVEmotesForClient[emoteData.name] = { + origin: 'sevenTV', + src: imageUrl, + width: file.width, + height: file.height, + modifier: false, + hidden: false, + modifierFlags: emoteData.flags, + id: emoteData.id, + name, + }; + } - // Duplicate code block here + setEmoteProperties(emoteData, file); ```
Extended the 7TV websocket support to handle
updated
messages.An update removes the old emotes from the overlay. This may or may not be desirable.
Tested with the client locally.