diff --git a/src/7tv-emotes/manifest.json b/src/7tv-emotes/manifest.json index a0ddc86a..9d9ff536 100644 --- a/src/7tv-emotes/manifest.json +++ b/src/7tv-emotes/manifest.json @@ -5,7 +5,7 @@ "main", "clips" ], - "version": "1.4.21", + "version": "1.4.22", "short_name": "7TV", "name": "7TV Emotes", "author": "Melonify", @@ -14,5 +14,5 @@ "website": "https://7tv.app", "settings": "add_ons.7tv_emotes", "created": "2021-07-12T23:18:04.000Z", - "updated": "2024-01-24T20:01:03.706Z" + "updated": "2024-03-29T22:03:31.676Z" } \ No newline at end of file diff --git a/src/7tv-emotes/modules/avatars.js b/src/7tv-emotes/modules/avatars.js index 2e84c2da..17eb6a5c 100644 --- a/src/7tv-emotes/modules/avatars.js +++ b/src/7tv-emotes/modules/avatars.js @@ -158,30 +158,8 @@ export default class Avatars extends FrankerFaceZ.utilities.module.Module { const avatarComponent = this.fine.getOwner(avatar); if (!avatarComponent) return; - // Find the nearest parent that has information about the user login - const parent = this.fine.searchParent(avatarComponent, e => e.props?.user?.login - || e.props?.targetLogin - || e.props?.userLogin - || e.props?.channelLogin - || e.props?.video?.owner?.login - || e.props?.content?.channelLogin, - 50); - - // props.user.login is for our own avatar in the top right - // props.targetLogin is for viewer cards - // props.userLogin appears to be for channels in the sidebar - // props.channelLogin is for the main channel you're watching - // props.content.channelLogin is for theatre / fullscreen mode - // The 'alt' attribute is a fallback - const pprops = parent?.props; - - const login = pprops?.user?.login - || pprops?.targetLogin - || pprops?.userLogin - || pprops?.channelLogin - || pprops?.video?.owner?.login - || pprops?.content?.channelLogin - || avatar.getAttribute('alt'); + const node = this.fine.searchParentNode(avatarComponent, e => e.memoizedProps?.userLogin); + const login = node?.memoizedProps?.userLogin; // No login? No avatar. if (!login) return; diff --git a/src/7tv-emotes/modules/socket.js b/src/7tv-emotes/modules/socket.js index 48ddc76b..68251013 100644 --- a/src/7tv-emotes/modules/socket.js +++ b/src/7tv-emotes/modules/socket.js @@ -75,11 +75,11 @@ export default class Socket extends FrankerFaceZ.utilities.module.Module { async get7TVUserData() { const user = this.site.getUser(); - if (!user) return; - - const resp = await this.stv_api.user.fetchUserData(user.id); - - this._user_id = resp?.user?.id || false; + if (user) { + const resp = await this.stv_api.user.fetchUserData(user.id); + + this._user_id = resp?.user?.id || false; + } this.connect(); } @@ -338,22 +338,22 @@ export default class Socket extends FrankerFaceZ.utilities.module.Module { } } - connect() { - if (!this.site.getUser()) { - return; - } - + connect(is_planned_reconnect = false) { if (this._connected || this._connecting) { return; } this._connecting = true; - this.log.info('Socket: Connecting to socket server...'); + if (!is_planned_reconnect) { + this.log.info('Socket: Connecting to socket server...'); + } this.socket = new WebSocket('wss://events.7tv.io/v3'); this.socket.onopen = () => { - this.log.info('Socket: Connected to socket server.'); + if (!is_planned_reconnect) { + this.log.info('Socket: Connected to socket server.'); + } this._connected = true; this._connecting = false; @@ -371,16 +371,17 @@ export default class Socket extends FrankerFaceZ.utilities.module.Module { return; } - this.log.info('Socket: Lost connection to socket server...', evt); + const is_planned_reconnect = evt.code === 4012; + if (!is_planned_reconnect) { + this.log.info('Socket: Lost connection to socket server...', evt); - if (evt.code !== 4012) { this._connect_attempts++; } this._subscriptions = {}; this._rooms = {}; - this.reconnect(); + this.reconnect(is_planned_reconnect); }; this.socket.onmessage = message => { @@ -396,10 +397,12 @@ export default class Socket extends FrankerFaceZ.utilities.module.Module { }; } - reconnect() { + reconnect(is_planned_reconnect = false) { this.disconnect(); - this.log.info('Socket: Trying to reconnect to socket server...'); + if (!is_planned_reconnect) { + this.log.info('Socket: Trying to reconnect to socket server...'); + } // Optimally this should always end up being 0 on a normal disconnect (End of Stream event) // meaning we'll pretty much immediately reconnect @@ -410,7 +413,7 @@ export default class Socket extends FrankerFaceZ.utilities.module.Module { this._connect_attempts++; setTimeout(() => { - this.connect(); + this.connect(is_planned_reconnect); }, delay); }