Skip to content

Handle 7TV personal emote set entitlements for current user #48

@BP602

Description

@BP602

Problem

Personal emote sets are only loaded once at login via validateSessionToken(). If the current user subscribes to 7TV or gains/loses access to a personal emote set while the app is running, the entitlement.create or entitlement.delete event is received but not processed.

Current Behavior

  • ✅ Personal emote sets loaded at login for current user
  • ✅ Personal emote set updates handled (emote_set.update events)
  • ❌ Personal emote set grants not handled (entitlement.create with kind: EMOTE_SET)
  • ❌ Personal emote set revocations not handled (entitlement.delete with kind: EMOTE_SET)

Expected Behavior

When the current user gains or loses access to a personal emote set while the app is running, the app should:

  1. For entitlement.create:

    • Check if the event is for the current user (compare body.object.user.id with stored stvId)
    • Fetch the emote set details using getPersonalEmoteSet(userId)
    • Add to personalEmoteSets state
    • Update localStorage.setItem('stvPersonalEmoteSets', ...)
  2. For entitlement.delete:

    • Check if the event is for the current user
    • Remove the emote set with matching ref_id from personalEmoteSets
    • Update localStorage

Implementation Notes

Placeholder Handler Location

src/renderer/src/providers/ChatProvider.jsx:3363

handlePersonalEmoteSetEntitlement: (body, action) => {
  const emoteSetId = body?.object?.ref_id;
  const userId = body?.object?.user?.id;
  const username = body?.object?.user?.connections?.find((c) => c.platform === "KICK")?.username;

  // TODO: Check if this is the current user
  const currentUserStvId = localStorage.getItem('stvId');
  if (userId !== currentUserStvId) {
    return; // Ignore other users' entitlements
  }

  if (action === 'create') {
    // Fetch and add emote set
  } else if (action === 'delete') {
    // Remove emote set
  }
}

Current User Identification

  • localStorage.getItem('stvId') - current user's 7TV ID
  • localStorage.getItem('kickUsername') - current user's Kick username

Available Functions

  • utils/services/seventv/stvAPI.js: getPersonalEmoteSet(userId) exists
  • Need to expose via preload as window.app.stv.getPersonalEmoteSet

Related Files

  • src/renderer/src/providers/ChatProvider.jsx - handler location
  • utils/services/seventv/stvAPI.js - getPersonalEmoteSet function
  • src/preload/index.js - initial load at login, needs to expose API

Scope

This issue is only for handling the current user's personal emote sets. Tracking other users' personal emote sets (for rendering their emotes in chat) is a separate feature request.

Branch

Related changes on perf/seventv-cosmetics-performance-optimization

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions