2017-01-01 13:07:36 +01:00
|
|
|
#include "channel.h"
|
2017-01-18 21:30:23 +01:00
|
|
|
#include "messages/message.h"
|
2017-01-16 03:15:07 +01:00
|
|
|
#include "windows.h"
|
2017-01-01 13:07:36 +01:00
|
|
|
|
2017-01-11 01:08:20 +01:00
|
|
|
#include <memory>
|
|
|
|
|
2017-01-18 21:30:23 +01:00
|
|
|
namespace chatterino {
|
|
|
|
|
2017-01-16 03:15:07 +01:00
|
|
|
Channel::Channel(const QString &channel)
|
2017-01-18 04:33:30 +01:00
|
|
|
: messages()
|
|
|
|
, name((channel.length() > 0 && channel[0] == '#') ? channel.mid(1)
|
|
|
|
: channel)
|
|
|
|
, bttvChannelEmotes()
|
|
|
|
, ffzChannelEmotes()
|
|
|
|
, messageMutex()
|
|
|
|
, subLink("https://www.twitch.tv/" + name +
|
|
|
|
"/subscribe?ref=in_chat_subscriber_link")
|
|
|
|
, channelLink("https://twitch.tv/" + name)
|
|
|
|
, popoutPlayerLink("https://player.twitch.tv/?channel=" + name)
|
2017-01-01 13:07:36 +01:00
|
|
|
{
|
2017-01-07 20:43:55 +01:00
|
|
|
}
|
2017-01-05 16:07:20 +01:00
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
QVector<std::shared_ptr<Message>>
|
|
|
|
Channel::getMessagesClone()
|
2017-01-05 16:07:20 +01:00
|
|
|
{
|
2017-01-18 04:33:30 +01:00
|
|
|
this->messageMutex.lock();
|
|
|
|
QVector<std::shared_ptr<Message>> M(this->messages);
|
2017-01-11 01:08:20 +01:00
|
|
|
M.detach();
|
2017-01-18 04:33:30 +01:00
|
|
|
this->messageMutex.unlock();
|
2017-01-05 16:07:20 +01:00
|
|
|
return M;
|
|
|
|
}
|
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
void
|
|
|
|
Channel::addMessage(std::shared_ptr<Message> message)
|
2017-01-05 16:07:20 +01:00
|
|
|
{
|
2017-01-18 04:33:30 +01:00
|
|
|
this->messageMutex.lock();
|
|
|
|
this->messages.append(message);
|
|
|
|
this->messageMutex.unlock();
|
2017-01-16 03:15:07 +01:00
|
|
|
|
|
|
|
Windows::repaintVisibleChatWidgets();
|
2017-01-05 16:07:20 +01:00
|
|
|
}
|
2017-01-18 21:30:23 +01:00
|
|
|
}
|