feat: Live Emote Updates for 7TV (#4090)

Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
nerix
2022-11-13 12:07:41 +01:00
committed by GitHub
parent 8fa89b4073
commit 39f7d8ac4c
35 changed files with 1833 additions and 54 deletions
+23
View File
@@ -1,8 +1,10 @@
#pragma once
#include "common/Atomic.hpp"
#include "messages/Image.hpp"
#include "messages/ImageSet.hpp"
#include <boost/optional.hpp>
#include <functional>
#include <memory>
#include <unordered_map>
@@ -15,6 +17,13 @@ struct Emote {
Tooltip tooltip;
Url homePage;
bool zeroWidth;
EmoteId id;
EmoteAuthor author;
/**
* If this emote is aliased, this contains
* the original (base) name of the emote.
*/
boost::optional<EmoteName> baseName;
// FOURTF: no solution yet, to be refactored later
const QString &getCopyString() const
@@ -30,6 +39,20 @@ using EmotePtr = std::shared_ptr<const Emote>;
class EmoteMap : public std::unordered_map<EmoteName, EmotePtr>
{
public:
/**
* Finds an emote by it's id with a hint to it's name.
*
* 1. Searches by name for the emote, checking if the ids match (fast-path).
* 2. Searches through the map for an emote with the `emoteID` (slow-path).
*
* @param emoteNameHint A hint to the name of the searched emote,
* may be empty.
* @param emoteID The emote id to search for.
* @return An iterator to the found emote (possibly this->end()).
*/
EmoteMap::const_iterator findEmote(const QString &emoteNameHint,
const QString &emoteID) const;
};
using EmoteIdMap = std::unordered_map<EmoteId, EmotePtr>;
using WeakEmoteMap = std::unordered_map<EmoteName, std::weak_ptr<const Emote>>;