mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Support General topic somehow.
This commit is contained in:
parent
8cd5105813
commit
57af221d39
12 changed files with 29 additions and 27 deletions
|
@ -689,7 +689,7 @@ QString ApiWrap::exportDirectMessageLink(
|
||||||
auto linkItemId = item->id;
|
auto linkItemId = item->id;
|
||||||
auto linkCommentId = MsgId();
|
auto linkCommentId = MsgId();
|
||||||
auto linkThreadId = MsgId();
|
auto linkThreadId = MsgId();
|
||||||
//auto linkThreadIsTopic = false;
|
auto linkThreadIsTopic = false;
|
||||||
if (inRepliesContext) {
|
if (inRepliesContext) {
|
||||||
if (const auto rootId = item->replyToTop()) {
|
if (const auto rootId = item->replyToTop()) {
|
||||||
const auto root = item->history()->owner().message(
|
const auto root = item->history()->owner().message(
|
||||||
|
@ -711,7 +711,7 @@ QString ApiWrap::exportDirectMessageLink(
|
||||||
} else {
|
} else {
|
||||||
// Reply in a thread, maybe comment in a private channel.
|
// Reply in a thread, maybe comment in a private channel.
|
||||||
linkThreadId = rootId;
|
linkThreadId = rootId;
|
||||||
//linkThreadIsTopic = (item->topicRootId() == rootId);
|
linkThreadIsTopic = (item->topicRootId() == rootId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -723,7 +723,7 @@ QString ApiWrap::exportDirectMessageLink(
|
||||||
+ '/'
|
+ '/'
|
||||||
+ (linkCommentId
|
+ (linkCommentId
|
||||||
? (post + "?comment=" + QString::number(linkCommentId.bare))
|
? (post + "?comment=" + QString::number(linkCommentId.bare))
|
||||||
: (linkThreadId/* && !linkThreadIsTopic*/)
|
: (linkThreadId && !linkThreadIsTopic)
|
||||||
? (post + "?thread=" + QString::number(linkThreadId.bare))
|
? (post + "?thread=" + QString::number(linkThreadId.bare))
|
||||||
: linkThreadId
|
: linkThreadId
|
||||||
? (QString::number(linkThreadId.bare) + '/' + post)
|
? (QString::number(linkThreadId.bare) + '/' + post)
|
||||||
|
|
|
@ -51,6 +51,8 @@ class Forum;
|
||||||
|
|
||||||
class ForumTopic final : public Thread {
|
class ForumTopic final : public Thread {
|
||||||
public:
|
public:
|
||||||
|
static constexpr auto kGeneralId = 1;
|
||||||
|
|
||||||
ForumTopic(not_null<Forum*> forum, MsgId rootId);
|
ForumTopic(not_null<Forum*> forum, MsgId rootId);
|
||||||
~ForumTopic();
|
~ForumTopic();
|
||||||
|
|
||||||
|
@ -58,6 +60,10 @@ public:
|
||||||
return history();
|
return history();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool isGeneral() const {
|
||||||
|
return (_rootId == kGeneralId);
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] std::shared_ptr<RepliesList> replies() const;
|
[[nodiscard]] std::shared_ptr<RepliesList> replies() const;
|
||||||
[[nodiscard]] not_null<ChannelData*> channel() const;
|
[[nodiscard]] not_null<ChannelData*> channel() const;
|
||||||
[[nodiscard]] not_null<History*> history() const;
|
[[nodiscard]] not_null<History*> history() const;
|
||||||
|
|
|
@ -304,7 +304,7 @@ void RepliesList::injectRootMessage(not_null<Viewer*> viewer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto root = lookupRoot();
|
const auto root = lookupRoot();
|
||||||
if (!root || root->topicRootId()) {
|
if (!root || root->topicRootId() != Data::ForumTopic::kGeneralId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
injectRootDivider(root, slice);
|
injectRootDivider(root, slice);
|
||||||
|
|
|
@ -2088,14 +2088,8 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
||||||
const auto itemId = item->fullId();
|
const auto itemId = item->fullId();
|
||||||
const auto canReply = [&] {
|
const auto canReply = [&] {
|
||||||
const auto peer = item->history()->peer;
|
const auto peer = item->history()->peer;
|
||||||
if (const auto forum = peer->forum()) {
|
const auto topic = item->topic();
|
||||||
const auto topicRootId = item->topicRootId();
|
return topic ? topic->canWrite() : peer->canWrite();
|
||||||
const auto topic = item->topic();
|
|
||||||
return topic
|
|
||||||
? topic->canWrite()
|
|
||||||
: peer->canWrite(!topicRootId);
|
|
||||||
}
|
|
||||||
return peer->canWrite();
|
|
||||||
}();
|
}();
|
||||||
if (canReply) {
|
if (canReply) {
|
||||||
_menu->addAction(tr::lng_context_reply_msg(tr::now), [=] {
|
_menu->addAction(tr::lng_context_reply_msg(tr::now), [=] {
|
||||||
|
|
|
@ -231,7 +231,8 @@ MsgId LookupReplyToTop(HistoryItem *replyTo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LookupReplyIsTopicPost(HistoryItem *replyTo) {
|
bool LookupReplyIsTopicPost(HistoryItem *replyTo) {
|
||||||
return replyTo && (replyTo->topicRootId() != 0);
|
return replyTo
|
||||||
|
&& (replyTo->topicRootId() != Data::ForumTopic::kGeneralId);
|
||||||
}
|
}
|
||||||
|
|
||||||
MTPMessageReplyHeader NewMessageReplyHeader(const Api::SendAction &action) {
|
MTPMessageReplyHeader NewMessageReplyHeader(const Api::SendAction &action) {
|
||||||
|
@ -1502,7 +1503,7 @@ MsgId HistoryMessage::topicRootId() const {
|
||||||
; reply && reply->topicPost) {
|
; reply && reply->topicPost) {
|
||||||
return reply->replyToTop();
|
return reply->replyToTop();
|
||||||
}
|
}
|
||||||
return 0;
|
return Data::ForumTopic::kGeneralId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryMessage::setText(const TextWithEntities &textWithEntities) {
|
void HistoryMessage::setText(const TextWithEntities &textWithEntities) {
|
||||||
|
|
|
@ -1344,7 +1344,7 @@ MsgId HistoryService::topicRootId() const {
|
||||||
} else if (Has<HistoryServiceTopicInfo>()) {
|
} else if (Has<HistoryServiceTopicInfo>()) {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
return 0;
|
return Data::ForumTopic::kGeneralId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryService::setReplyFields(
|
void HistoryService::setReplyFields(
|
||||||
|
|
|
@ -6721,7 +6721,7 @@ void HistoryWidget::processReply() {
|
||||||
return processCancel();
|
return processCancel();
|
||||||
} else if (const auto forum = _peer->forum()) {
|
} else if (const auto forum = _peer->forum()) {
|
||||||
const auto topicRootId = _processingReplyItem->topicRootId();
|
const auto topicRootId = _processingReplyItem->topicRootId();
|
||||||
if (!topicRootId || forum->topicDeleted(topicRootId)) {
|
if (forum->topicDeleted(topicRootId)) {
|
||||||
return processCancel();
|
return processCancel();
|
||||||
} else if (const auto topic = forum->topicFor(topicRootId)) {
|
} else if (const auto topic = forum->topicFor(topicRootId)) {
|
||||||
if (!topic->canWrite()) {
|
if (!topic->canWrite()) {
|
||||||
|
|
|
@ -686,7 +686,7 @@ auto Element::contextDependentServiceText() -> TextWithLinks {
|
||||||
}
|
}
|
||||||
const auto peerId = item->history()->peer->id;
|
const auto peerId = item->history()->peer->id;
|
||||||
const auto topicRootId = item->topicRootId();
|
const auto topicRootId = item->topicRootId();
|
||||||
if (!topicRootId || !peerIsChannel(peerId)) {
|
if (!peerIsChannel(peerId)) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
const auto from = item->from();
|
const auto from = item->from();
|
||||||
|
|
|
@ -2711,13 +2711,8 @@ bool Message::displayFastReply() const {
|
||||||
const auto canWrite = [&] {
|
const auto canWrite = [&] {
|
||||||
const auto item = data();
|
const auto item = data();
|
||||||
const auto peer = item->history()->peer;
|
const auto peer = item->history()->peer;
|
||||||
if (peer->isForum()) {
|
const auto topic = item->topic();
|
||||||
const auto topic = item->topic();
|
return topic ? topic->canWrite() : peer->canWrite();
|
||||||
return topic
|
|
||||||
? topic->canWrite()
|
|
||||||
: peer->canWrite(!item->topicRootId());
|
|
||||||
}
|
|
||||||
return peer->canWrite();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return hasFastReply()
|
return hasFastReply()
|
||||||
|
|
|
@ -1467,7 +1467,11 @@ void RepliesWidget::refreshTopBarActiveChat() {
|
||||||
|
|
||||||
MsgId RepliesWidget::replyToId() const {
|
MsgId RepliesWidget::replyToId() const {
|
||||||
const auto custom = _composeControls->replyingToMessage().msg;
|
const auto custom = _composeControls->replyingToMessage().msg;
|
||||||
return custom ? custom : _rootId;
|
return custom
|
||||||
|
? custom
|
||||||
|
: (_rootId == Data::ForumTopic::kGeneralId)
|
||||||
|
? MsgId()
|
||||||
|
: _rootId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RepliesWidget::refreshUnreadCountBadge(std::optional<int> count) {
|
void RepliesWidget::refreshUnreadCountBadge(std::optional<int> count) {
|
||||||
|
|
|
@ -4166,9 +4166,9 @@ void OverlayWidget::setContext(
|
||||||
not_null<PeerData*>> context) {
|
not_null<PeerData*>> context) {
|
||||||
if (const auto item = std::get_if<ItemContext>(&context)) {
|
if (const auto item = std::get_if<ItemContext>(&context)) {
|
||||||
_message = item->item;
|
_message = item->item;
|
||||||
_topicRootId = item->topicRootId;
|
|
||||||
_history = _message->history();
|
_history = _message->history();
|
||||||
_peer = _history->peer;
|
_peer = _history->peer;
|
||||||
|
_topicRootId = _peer->isForum() ? item->topicRootId : MsgId();
|
||||||
} else if (const auto peer = std::get_if<not_null<PeerData*>>(&context)) {
|
} else if (const auto peer = std::get_if<not_null<PeerData*>>(&context)) {
|
||||||
_peer = *peer;
|
_peer = *peer;
|
||||||
_history = _peer->owner().history(_peer);
|
_history = _peer->owner().history(_peer);
|
||||||
|
|
|
@ -257,10 +257,12 @@ void Uploader::sendProgressUpdate(
|
||||||
const auto history = item->history();
|
const auto history = item->history();
|
||||||
auto &manager = _api->session().sendProgressManager();
|
auto &manager = _api->session().sendProgressManager();
|
||||||
manager.update(history, type, progress);
|
manager.update(history, type, progress);
|
||||||
if (const auto replyTo = item->topicRootId()) {
|
if (const auto replyTo = item->replyToTop()) {
|
||||||
if (history->peer->isMegagroup()) {
|
if (history->peer->isMegagroup()) {
|
||||||
manager.update(history, replyTo, type, progress);
|
manager.update(history, replyTo, type, progress);
|
||||||
}
|
}
|
||||||
|
} else if (history->peer->isForum()) {
|
||||||
|
manager.update(history, item->topicRootId(), type, progress);
|
||||||
}
|
}
|
||||||
_api->session().data().requestItemRepaint(item);
|
_api->session().data().requestItemRepaint(item);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue