Add option to subscribe to and pin reply threads (#4680)

Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
nerix
2023-06-17 17:41:52 +02:00
committed by GitHub
parent 2d3d3ae46e
commit aff9342647
15 changed files with 194 additions and 69 deletions
+1 -1
View File
@@ -46,7 +46,7 @@ enum class MessageFlag : int64_t {
FirstMessage = (1LL << 23),
ReplyMessage = (1LL << 24),
ElevatedMessage = (1LL << 25),
ParticipatedThread = (1LL << 26),
SubscribedThread = (1LL << 26),
CheerMessage = (1LL << 27),
LiveUpdatesAdd = (1LL << 28),
LiveUpdatesRemove = (1LL << 29),
+17 -5
View File
@@ -1,4 +1,4 @@
#include "MessageThread.hpp"
#include "messages/MessageThread.hpp"
#include "messages/Message.hpp"
#include "util/DebugCount.hpp"
@@ -58,14 +58,26 @@ size_t MessageThread::liveCount(
return count;
}
bool MessageThread::participated() const
void MessageThread::markSubscribed()
{
return this->participated_;
if (this->subscription_ == Subscription::Subscribed)
{
return;
}
this->subscription_ = Subscription::Subscribed;
this->subscriptionUpdated();
}
void MessageThread::markParticipated()
void MessageThread::markUnsubscribed()
{
this->participated_ = true;
if (this->subscription_ == Subscription::Unsubscribed)
{
return;
}
this->subscription_ = Subscription::Unsubscribed;
this->subscriptionUpdated();
}
} // namespace chatterino
+26 -3
View File
@@ -1,5 +1,6 @@
#pragma once
#include <boost/signals2.hpp>
#include <QString>
#include <memory>
@@ -11,6 +12,12 @@ struct Message;
class MessageThread
{
public:
enum class Subscription : uint8_t {
None,
Subscribed,
Unsubscribed,
};
MessageThread(std::shared_ptr<const Message> rootMessage);
~MessageThread();
@@ -23,9 +30,22 @@ public:
/// Returns the number of live reply references
size_t liveCount(const std::shared_ptr<const Message> &exclude) const;
bool participated() const;
bool subscribed() const
{
return this->subscription_ == Subscription::Subscribed;
}
void markParticipated();
/// Returns true if and only if the user manually unsubscribed from the thread
/// @see #markUnsubscribed()
bool unsubscribed() const
{
return this->subscription_ == Subscription::Unsubscribed;
}
/// Subscribe to this thread.
void markSubscribed();
/// Unsubscribe from this thread.
void markUnsubscribed();
const QString &rootId() const
{
@@ -42,11 +62,14 @@ public:
return replies_;
}
boost::signals2::signal<void()> subscriptionUpdated;
private:
const QString rootMessageId_;
const std::shared_ptr<const Message> rootMessage_;
std::vector<std::weak_ptr<const Message>> replies_;
bool participated_ = false;
Subscription subscription_ = Subscription::None;
};
} // namespace chatterino