Did you get a resolution for this or have to hack it? I have encountered the same issue when trying to subscribe viewers to their PubSub whisper channels. With the following code
// Twitch function handlers
var twitch = window.Twitch.ext;
var firstTimeOnly = true;
twitch.onAuthorized((auth) => {
console.log("Twitch: onAuthorized called");
console.log("The channel ID is", auth.channelId);
// console.log("The extension clientId is", auth.clientId);
console.log("My Twitch opaque user id is", auth.userId);
// console.log("The JWT token is", auth.token);
if (firstTimeOnly) {
firstTimeOnly = false;
console.log("Subbing to pubsub whisper");
// Listen to this viewer's private PubSub whisper channel
twitch.listen('whisper-abc'+auth.userId, (target, type, msg) => {
console.log("New Twitch PubSub whisper:", msg);
});
}
});
My console output is:
Twitch: onAuthorized called
The channel ID is 174234373
My Twitch opaque user id is #############
Subbing to pubsub whisper
*****EBS SENDS 'hello' TO WHISPER******
New Twitch PubSub whisper: hello
New Twitch PubSub whisper: hello
So the callback is subscribed twice. With that boolean lock on it.
The heck?