fixed twitch emotes

This commit is contained in:
fourtf 2017-01-26 10:18:02 +01:00
parent a5e7ef9980
commit 1828fe1ec9
2 changed files with 15 additions and 7 deletions

View file

@ -18,10 +18,10 @@ Channel::Channel(const QString &channel)
, channelLink("https://twitch.tv/" + name)
, popoutPlayerLink("https://player.twitch.tv/?channel=" + name)
{
for (int i = 0; i < 40; i++) {
addMessage(std::shared_ptr<messages::Message>(
new messages::Message("test xD test")));
}
// for (int i = 0; i < 40; i++) {
// addMessage(std::shared_ptr<messages::Message>(
// new messages::Message("test xD test")));
// }
}
QVector<std::shared_ptr<messages::Message>>

View file

@ -1,6 +1,8 @@
#include "emotes.h"
#include "resources.h"
#include <QDebug>
namespace chatterino {
QString Emotes::twitchEmoteTemplate(
@ -26,7 +28,10 @@ Emotes::Emotes()
messages::LazyLoadedImage *
Emotes::getTwitchEmoteById(const QString &name, long id)
{
return Emotes::twitchEmoteFromCache.getOrAdd(id, [&name, id] {
qDebug() << "loading twitch emote: " << id;
return Emotes::twitchEmoteFromCache.getOrAdd(id, [&name, &id] {
qDebug() << "loading twitch emote: " << id;
qreal scale;
QString url = getTwitchEmoteLink(id, scale);
return new messages::LazyLoadedImage(url, scale, name,
@ -39,8 +44,11 @@ Emotes::getTwitchEmoteLink(long id, qreal &scale)
{
scale = .5;
return Emotes::twitchEmoteTemplate.replace("{id}", QString::number(id))
.replace("{scale}", "2");
QString value = Emotes::twitchEmoteTemplate;
value.detach();
return value.replace("{id}", QString::number(id)).replace("{scale}", "2");
}
messages::LazyLoadedImage *