mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Added system message on new date (#2748)
Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
parent
dcd65b5978
commit
d59bb805bb
|
@ -3,6 +3,7 @@
|
|||
## Unversioned
|
||||
|
||||
- Major: New split for channels going live! /live. (#1797)
|
||||
- Minor: Added a message that displays a new date on new day. (#1016)
|
||||
- Minor: Hosting messages are now clickable. (#2655)
|
||||
- Minor: Messages held by automod are now shown to the user. (#2626)
|
||||
- Bugfix: Strip newlines from stream titles to prevent text going off of split header (#2755)
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace chatterino {
|
|||
//
|
||||
Channel::Channel(const QString &name, Type type)
|
||||
: completionModel(*this)
|
||||
, lastDate_(QDate::currentDate())
|
||||
, name_(name)
|
||||
, type_(type)
|
||||
{
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "common/FlagsEnum.hpp"
|
||||
#include "messages/LimitedQueue.hpp"
|
||||
|
||||
#include <QDate>
|
||||
#include <QString>
|
||||
#include <QTimer>
|
||||
#include <boost/optional.hpp>
|
||||
|
@ -97,6 +98,7 @@ public:
|
|||
static std::shared_ptr<Channel> getEmpty();
|
||||
|
||||
CompletionModel completionModel;
|
||||
QDate lastDate_;
|
||||
|
||||
protected:
|
||||
virtual void onConnected();
|
||||
|
|
|
@ -744,6 +744,24 @@ void TwitchChannel::loadRecentMessages()
|
|||
|
||||
for (auto message : messages)
|
||||
{
|
||||
if (message->tags().contains("rm-received-ts"))
|
||||
{
|
||||
QDate msgDate = QDateTime::fromMSecsSinceEpoch(
|
||||
message->tags()
|
||||
.value("rm-received-ts")
|
||||
.toLongLong())
|
||||
.date();
|
||||
if (msgDate != shared.get()->lastDate_)
|
||||
{
|
||||
shared.get()->lastDate_ = msgDate;
|
||||
auto msg = makeSystemMessage(
|
||||
msgDate.toString(Qt::SystemLocaleLongDate),
|
||||
QTime(0, 0));
|
||||
msg->flags.set(MessageFlag::RecentMessage);
|
||||
allBuiltMessages.emplace_back(msg);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto builtMessage :
|
||||
handler.parseMessage(shared.get(), message))
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "ChannelView.hpp"
|
||||
|
||||
#include <QClipboard>
|
||||
#include <QDate>
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
#include <QGraphicsBlurEffect>
|
||||
|
@ -22,6 +23,7 @@
|
|||
#include "messages/Emote.hpp"
|
||||
#include "messages/LimitedQueueSnapshot.hpp"
|
||||
#include "messages/Message.hpp"
|
||||
#include "messages/MessageBuilder.hpp"
|
||||
#include "messages/MessageElement.hpp"
|
||||
#include "messages/layouts/MessageLayout.hpp"
|
||||
#include "messages/layouts/MessageLayoutElement.hpp"
|
||||
|
@ -602,6 +604,15 @@ void ChannelView::setChannel(ChannelPtr underlyingChannel)
|
|||
boost::optional<MessageFlags> overridingFlags) {
|
||||
if (this->shouldIncludeMessage(message))
|
||||
{
|
||||
if (this->channel_->lastDate_ != QDate::currentDate())
|
||||
{
|
||||
this->channel_->lastDate_ = QDate::currentDate();
|
||||
auto msg =
|
||||
makeSystemMessage(QDate::currentDate().toString(
|
||||
Qt::SystemLocaleLongDate),
|
||||
QTime(0, 0));
|
||||
this->channel_->addMessage(msg);
|
||||
}
|
||||
// When the message was received in the underlyingChannel,
|
||||
// logging will be handled. Prevent duplications.
|
||||
if (overridingFlags)
|
||||
|
|
Loading…
Reference in a new issue