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
+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