mirror-chatterino2/src/providers/twitch/TwitchEmotes.hpp
pajlada a9fc9f949f
Remove unused mutex from Emotes (#3943)
The mutex was initially used to limit access to the twitchEmotesCache_ member
but it's no longer necessary since it's been made a UniqueAccess type
2022-09-03 11:01:56 +00:00

50 lines
1.1 KiB
C++

#pragma once
#include <QColor>
#include <QRegularExpression>
#include <QString>
#include <unordered_map>
#include "common/Aliases.hpp"
#include "common/UniqueAccess.hpp"
#include <memory>
// NB: "default" can be replaced with "static" to always get a non-animated
// variant
#define TWITCH_EMOTE_TEMPLATE \
"https://static-cdn.jtvnw.net/emoticons/v2/{id}/default/dark/{scale}"
namespace chatterino {
struct Emote;
using EmotePtr = std::shared_ptr<const Emote>;
struct CheerEmote {
QColor color;
int minBits;
QRegularExpression regex;
EmotePtr animatedEmote;
EmotePtr staticEmote;
};
struct CheerEmoteSet {
QRegularExpression regex;
std::vector<CheerEmote> cheerEmotes;
};
class TwitchEmotes
{
public:
static QString cleanUpEmoteCode(const QString &dirtyEmoteCode);
TwitchEmotes();
EmotePtr getOrCreateEmote(const EmoteId &id, const EmoteName &name);
private:
Url getEmoteLink(const EmoteId &id, const QString &emoteScale);
UniqueAccess<std::unordered_map<EmoteId, std::weak_ptr<Emote>>>
twitchEmotesCache_;
};
} // namespace chatterino