feat: Add Live Emote Updates for BTTV (#4147)
This feature is enabled by default and can be disabled in settings with the "Enable BTTV live emotes updates" setting. Co-authored-by: Felanbird <41973452+Felanbird@users.noreply.github.com> Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -13,6 +13,8 @@ struct Emote;
|
||||
using EmotePtr = std::shared_ptr<const Emote>;
|
||||
class EmoteMap;
|
||||
class Channel;
|
||||
struct BttvLiveUpdateEmoteUpdateAddMessage;
|
||||
struct BttvLiveUpdateEmoteRemoveMessage;
|
||||
|
||||
class BttvEmotes final
|
||||
{
|
||||
@@ -33,6 +35,41 @@ public:
|
||||
std::function<void(EmoteMap &&)> callback,
|
||||
bool manualRefresh);
|
||||
|
||||
/**
|
||||
* Adds an emote to the `channelEmoteMap`.
|
||||
* This will _copy_ the emote map and
|
||||
* update the `Atomic`.
|
||||
*
|
||||
* @return The added emote.
|
||||
*/
|
||||
static EmotePtr addEmote(
|
||||
const QString &channelDisplayName,
|
||||
Atomic<std::shared_ptr<const EmoteMap>> &channelEmoteMap,
|
||||
const BttvLiveUpdateEmoteUpdateAddMessage &message);
|
||||
|
||||
/**
|
||||
* Updates an emote in this `channelEmoteMap`.
|
||||
* This will _copy_ the emote map and
|
||||
* update the `Atomic`.
|
||||
*
|
||||
* @return pair<old emote, new emote> if any emote was updated.
|
||||
*/
|
||||
static boost::optional<std::pair<EmotePtr, EmotePtr>> updateEmote(
|
||||
const QString &channelDisplayName,
|
||||
Atomic<std::shared_ptr<const EmoteMap>> &channelEmoteMap,
|
||||
const BttvLiveUpdateEmoteUpdateAddMessage &message);
|
||||
|
||||
/**
|
||||
* Removes an emote from this `channelEmoteMap`.
|
||||
* This will _copy_ the emote map and
|
||||
* update the `Atomic`.
|
||||
*
|
||||
* @return The removed emote if any emote was removed.
|
||||
*/
|
||||
static boost::optional<EmotePtr> removeEmote(
|
||||
Atomic<std::shared_ptr<const EmoteMap>> &channelEmoteMap,
|
||||
const BttvLiveUpdateEmoteRemoveMessage &message);
|
||||
|
||||
private:
|
||||
Atomic<std::shared_ptr<const EmoteMap>> global_;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user