feat: add pinning functionality for streamers in a channel section#97
feat: add pinning functionality for streamers in a channel section#97maksPodstawski wants to merge 1 commit intomasterfrom
Conversation
There was a problem hiding this comment.
Key Issues
The assignment of this.channelId in both updateNames() and run() could cause a race condition due to the asynchronous nature of updateNames(). The condition on line 79 fails to check if isPinned.value exists, risking a runtime error if isPinned is undefined.
| "https://enhancer.at/assets/brand/logo.png", | ||
| ); | ||
| const pinnedEnabled = await this.settingsService().getSettingsKey("pinnedStreamersEnabled"); | ||
| this.channelId = await this.getChannelId(); |
There was a problem hiding this comment.
🐛 Possible Bug
The this.channelId is assigned twice - once in updateNames() and again in the run() method. Since updateNames() is now async, this could lead to a race condition where the channel ID gets overwritten with a different value before the pin toggle handler executes.
| this.channelId = await this.getChannelId(); | |
| const channelId = await this.getChannelId(); | |
| this.channelId = channelId; |
| if (!channelId || !isPinned) return; | ||
| isPinned.value = await this.togglePinnedStreamer(channelId); |
There was a problem hiding this comment.
🐛 Possible Bug
The condition if (!channelId || !isPinned) return; on line 79 only checks if isPinned is falsy, but doesn't verify if isPinned.value exists before using it on line 80. This could lead to a runtime error if isPinned is a signal object but its value is undefined.
| if (!channelId || !isPinned) return; | |
| isPinned.value = await this.togglePinnedStreamer(channelId); | |
| if (!channelId || !isPinned || isPinned.value === undefined) return; | |
| isPinned.value = await this.togglePinnedStreamer(channelId); |
Description
Briefly explain what this PR does. Is it a bug fix, new feature, or a refactor?
Testing
Select all the environments you tested this PR with:
Twitch
Kick
Please describe how you tested this change in the selected environments.
Related Issues
If this PR addresses an issue, link it here (e.g.,
Closes #123).✨
Description by Callstackai
This PR adds pinning functionality for streamers in a channel section, allowing users to pin their favorite streamers for easier access.
Diagrams of code changes
sequenceDiagram participant User participant ChannelSection participant PinStreamerModule participant Settings User->>ChannelSection: Views channel ChannelSection->>Settings: Get pinnedStreamers setting Settings-->>ChannelSection: Returns pinned streamers list User->>ChannelSection: Clicks pin button ChannelSection->>PinStreamerModule: togglePinnedStreamer(channelId) PinStreamerModule->>Settings: Update pinnedStreamers setting PinStreamerModule->>PinStreamerModule: Emit pinnedStreamersUpdated event Note over ChannelSection,PinStreamerModule: Both modules listen for pinnedStreamersUpdated PinStreamerModule-->>ChannelSection: Update pin state PinStreamerModule->>PinStreamerModule: Refresh pins in DOM ChannelSection-->>User: Update UI with new pin stateFiles Changed