mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
fixed having the same chat open multiple times
This commit is contained in:
parent
c6c90d9f50
commit
a92c3dc2a4
5 changed files with 29 additions and 25 deletions
|
@ -20,17 +20,11 @@ Channel::Channel(const QString &channel)
|
|||
: 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)
|
||||
{
|
||||
// for (int i = 0; i < 40; i++) {
|
||||
// addMessage(std::shared_ptr<messages::Message>(
|
||||
// new messages::Message("test xD test")));
|
||||
// }
|
||||
|
||||
reloadChannelEmotes();
|
||||
}
|
||||
|
||||
|
|
|
@ -46,12 +46,6 @@ public:
|
|||
return name.isEmpty();
|
||||
}
|
||||
|
||||
const QMutex &
|
||||
getMessageMutex() const
|
||||
{
|
||||
return messageMutex;
|
||||
}
|
||||
|
||||
const QString &
|
||||
getName() const
|
||||
{
|
||||
|
@ -125,7 +119,6 @@ private:
|
|||
|
||||
ConcurrentMap<QString, messages::LazyLoadedImage *> bttvChannelEmotes;
|
||||
ConcurrentMap<QString, messages::LazyLoadedImage *> ffzChannelEmotes;
|
||||
QMutex messageMutex;
|
||||
|
||||
QString subLink;
|
||||
QString channelLink;
|
||||
|
|
|
@ -31,6 +31,10 @@ Channels::addChannel(const QString &channel)
|
|||
|
||||
QString channelName = channel.toLower();
|
||||
|
||||
if (channel.length() > 1 && channel.at(0) == '/') {
|
||||
return getChannel(channel);
|
||||
}
|
||||
|
||||
auto it = Channels::channels.find(channelName);
|
||||
|
||||
if (it == Channels::channels.end()) {
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "settings.h"
|
||||
#include "widgets/textinputdialog.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFont>
|
||||
#include <QFontDatabase>
|
||||
#include <QPainter>
|
||||
|
@ -47,18 +48,18 @@ ChatWidget::setChannelName(const QString &name)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!this->channelName.isEmpty()) {
|
||||
Channels::removeChannel(this->channelName);
|
||||
|
||||
this->messageAppendedConnection.disconnect();
|
||||
this->messageRemovedConnection.disconnect();
|
||||
}
|
||||
|
||||
this->channelName = channel;
|
||||
this->header.updateChannelText();
|
||||
|
||||
this->view.layoutMessages();
|
||||
|
||||
if (!this->channelName.isEmpty()) {
|
||||
Channels::removeChannel(this->channelName);
|
||||
|
||||
messageAppendedConnection.disconnect();
|
||||
messageRemovedConnection.disconnect();
|
||||
}
|
||||
|
||||
messages.clear();
|
||||
|
||||
if (channel.isEmpty()) {
|
||||
|
@ -67,7 +68,7 @@ ChatWidget::setChannelName(const QString &name)
|
|||
} else {
|
||||
this->channel = Channels::addChannel(channel);
|
||||
|
||||
messageAppendedConnection =
|
||||
this->messageAppendedConnection =
|
||||
this->channel.get()->messageAppended.connect([this](
|
||||
std::shared_ptr<messages::Message> &message) {
|
||||
|
||||
|
@ -75,14 +76,26 @@ ChatWidget::setChannelName(const QString &name)
|
|||
|
||||
auto messageRef = new messages::MessageRef(message);
|
||||
|
||||
qDebug() << "xD";
|
||||
|
||||
this->messages.appendItem(
|
||||
std::shared_ptr<messages::MessageRef>(messageRef), deleted);
|
||||
|
||||
});
|
||||
|
||||
messageRemovedConnection =
|
||||
this->messageRemovedConnection =
|
||||
this->channel.get()->messageRemovedFromStart.connect(
|
||||
[this](std::shared_ptr<messages::Message> &message) {});
|
||||
[this](std::shared_ptr<messages::Message> &) {});
|
||||
|
||||
auto snapshot = this->channel.get()->getMessageSnapshot();
|
||||
|
||||
for (int i = 0; i < snapshot.getLength(); i++) {
|
||||
std::shared_ptr<messages::MessageRef> deleted;
|
||||
|
||||
auto messageRef = new messages::MessageRef(snapshot[i]);
|
||||
|
||||
this->messages.appendItem(
|
||||
std::shared_ptr<messages::MessageRef>(messageRef), deleted);
|
||||
}
|
||||
}
|
||||
|
||||
this->view.layoutMessages();
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
}
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
|
||||
void paintEvent(QPaintEvent *) override;
|
||||
|
||||
private:
|
||||
messages::LimitedQueue<std::shared_ptr<messages::MessageRef>> messages;
|
||||
|
|
Loading…
Reference in a new issue