diff --git a/channel.cpp b/channel.cpp index ec7b178a9..360e88d70 100644 --- a/channel.cpp +++ b/channel.cpp @@ -30,6 +30,8 @@ Channel::Channel(const QString &channel) // addMessage(std::shared_ptr( // new messages::Message("test xD test"))); // } + + reloadChannelEmotes(); } void @@ -65,10 +67,11 @@ Channel::reloadBttvEmotes() this->getBttvChannelEmotes().insert( code, - Emotes::getBttvChannelEmoteFromCaches().getOrAdd(id, [=] { - return new messages::LazyLoadedImage( - url, 1, code, code + "\nChannel Bttv Emote"); - })); + Emotes::getBttvChannelEmoteFromCaches().getOrAdd( + id, [&code, &url] { + return new messages::LazyLoadedImage( + url, 1, code, code + "\nChannel Bttv Emote"); + })); } } @@ -82,7 +85,7 @@ Channel::reloadFfzEmotes() { QNetworkAccessManager *manager = new QNetworkAccessManager(); - QUrl url("https://api.frankerfacez.com/v1/set/global"); + QUrl url("http://api.frankerfacez.com/v1/room/" + this->name); QNetworkRequest request(url); QNetworkReply *reply = manager->get(request); @@ -109,9 +112,13 @@ Channel::reloadFfzEmotes() QJsonObject urls = object.value("urls").toObject(); QString url1 = "http:" + urls.value("1").toString(); - Emotes::getBttvEmotes().insert( - code, new messages::LazyLoadedImage( - url1, 1, code, code + "\nGlobal Ffz Emote")); + this->getFfzChannelEmotes().insert( + code, + Emotes::getFfzChannelEmoteFromCaches().getOrAdd( + id, [&code, &url1] { + return new messages::LazyLoadedImage( + url1, 1, code, code + "\nGlobal Ffz Emote"); + })); } } } diff --git a/channel.h b/channel.h index e2da2b076..05d067021 100644 --- a/channel.h +++ b/channel.h @@ -21,13 +21,13 @@ public: Channel(const QString &channel); // properties - const ConcurrentMap & + ConcurrentMap & getBttvChannelEmotes() { return bttvChannelEmotes; } - const ConcurrentMap & + ConcurrentMap & getFfzChannelEmotes() { return ffzChannelEmotes; diff --git a/channel.h.zT7500 b/channel.h.zT7500 deleted file mode 100644 index 8760581af..000000000 --- a/channel.h.zT7500 +++ /dev/null @@ -1,129 +0,0 @@ -#ifndef CHANNEL_H -#define CHANNEL_H - -#include "concurrentmap.h" -#include "messages/lazyloadedimage.h" - -#include -#include -#include -#include -#include - -namespace chatterino { -namespace messages { -class Message; -} - -class Channel -{ -public: - Channel(const QString &channel); - - // properties - const ConcurrentMap & - getBttvChannelEmotes() const - { - return bttvChannelEmotes; - } - - const ConcurrentMap & - getFfzChannelEmotes() const - { - return ffzChannelEmotes; - } - - const QMutex & - getMessageMutex() const - { - return messageMutex; - } - - const QString & - getName() const - { - return name; - } - - int - getRoomID() const - { - return roomID; - } - - const QString & - getSubLink() const - { - return subLink; - } - const QString & - getChannelLink() const - { - return channelLink; - } - const QString & - getPopoutPlayerLink() const - { - return popoutPlayerLink; - } - - bool - getIsLive() const - { - return isLive; - } - int - getStreamViewerCount() const - { - return streamViewerCount; - } - const QString & - getStreamStatus() const - { - return streamStatus; - } - const QString & - getStreamGame() const - { - return streamGame; - } - - // methods - void addMessage(std::shared_ptr message); - - QVector> getMessagesClone(); - - QVector> & - getMessages() const - { - return messages; - } - - QMutex & - getMessageMutes() const - { - return messageMutex; - } - -private: - QVector> messages; - - QString name; - int roomID; - - ConcurrentMap bttvChannelEmotes; - ConcurrentMap ffzChannelEmotes; - QMutex messageMutex; - - QString subLink; - QString channelLink; - QString popoutPlayerLink; - - bool isLive; - int streamViewerCount; - QString streamStatus; - QString streamGame; -}; -} - -#endif // CHANNEL_H diff --git a/emotes.cpp b/emotes.cpp index b8b690b44..95d8e528b 100644 --- a/emotes.cpp +++ b/emotes.cpp @@ -22,7 +22,7 @@ ConcurrentMap Emotes::ffzEmotes; ConcurrentMap Emotes::chatterinoEmotes; ConcurrentMap Emotes::bttvChannelEmoteFromCaches; -ConcurrentMap +ConcurrentMap Emotes::ffzChannelEmoteFromCaches; ConcurrentMap Emotes::twitchEmoteFromCache; ConcurrentMap Emotes::miscImageFromCache; diff --git a/emotes.h b/emotes.h index 3e0389591..50df0aa76 100644 --- a/emotes.h +++ b/emotes.h @@ -43,7 +43,7 @@ public: return bttvChannelEmoteFromCaches; } - static ConcurrentMap & + static ConcurrentMap & getFfzChannelEmoteFromCaches() { return ffzChannelEmoteFromCaches; @@ -93,7 +93,7 @@ private: static ConcurrentMap chatterinoEmotes; static ConcurrentMap bttvChannelEmoteFromCaches; - static ConcurrentMap + static ConcurrentMap ffzChannelEmoteFromCaches; static ConcurrentMap twitchEmoteFromCache;