mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Improve bot with forum opening.
This commit is contained in:
@@ -12,7 +12,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "ui/effects/emoji_fly_animation.h"
|
||||
#include "ui/abstract_button.h"
|
||||
#include "ui/vertical_list.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_document.h"
|
||||
#include "data/data_forum.h"
|
||||
#include "data/data_forum_icons.h"
|
||||
@@ -515,8 +514,7 @@ void EditForumTopicBox(
|
||||
}
|
||||
|
||||
const auto create = [=] {
|
||||
const auto channel = forum->peer->asChannel();
|
||||
if (!channel || !channel->isForum()) {
|
||||
if (!forum->peer->isForum()) {
|
||||
box->closeBox();
|
||||
return;
|
||||
} else if (title->getLastText().trimmed().isEmpty()) {
|
||||
@@ -527,7 +525,7 @@ void EditForumTopicBox(
|
||||
controller->showSection(
|
||||
std::make_shared<ChatMemento>(ChatViewId{
|
||||
.history = forum,
|
||||
.repliesRootId = channel->forum()->reserveCreatingId(
|
||||
.repliesRootId = forum->peer->forum()->reserveCreatingId(
|
||||
title->getLastText().trimmed(),
|
||||
state->defaultIcon.current().colorId,
|
||||
state->iconId.current()),
|
||||
|
||||
@@ -1135,7 +1135,7 @@ void Controller::fillForumButton() {
|
||||
_forumSavedValue = _peer->isForum();
|
||||
_forumTabsSavedValue = !_peer->isChannel()
|
||||
|| !_peer->isForum()
|
||||
|| _peer->asChannel()->useSubsectionTabs();
|
||||
|| _peer->useSubsectionTabs();
|
||||
|
||||
const auto changes = std::make_shared<rpl::event_stream<>>();
|
||||
const auto label = [=] {
|
||||
|
||||
@@ -206,11 +206,11 @@ void Thread::setHasPinnedMessages(bool has) {
|
||||
}
|
||||
|
||||
void Thread::saveMeAsActiveSubsectionThread() {
|
||||
if (const auto channel = owningHistory()->peer->asChannel()) {
|
||||
if (channel->useSubsectionTabs()) {
|
||||
if (const auto forum = channel->forum()) {
|
||||
forum->saveActiveSubsectionThread(this);
|
||||
} else if (const auto monoforum = channel->monoforum()) {
|
||||
if (const auto peer = owningHistory()->peer; peer->useSubsectionTabs()) {
|
||||
if (const auto forum = peer->forum()) {
|
||||
forum->saveActiveSubsectionThread(this);
|
||||
} else if (const auto channel = peer->asChannel()) {
|
||||
if (const auto monoforum = channel->monoforum()) {
|
||||
monoforum->saveActiveSubsectionThread(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "api/api_sensitive_content.h"
|
||||
#include "api/api_statistics.h"
|
||||
#include "base/timer_rpl.h"
|
||||
#include "core/application.h"
|
||||
#include "storage/localstorage.h"
|
||||
#include "storage/storage_account.h"
|
||||
#include "storage/storage_user_photos.h"
|
||||
@@ -34,6 +35,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "api/api_peer_photo.h"
|
||||
#include "apiwrap.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "window/notifications_manager.h"
|
||||
#include "styles/style_chat.h"
|
||||
|
||||
namespace {
|
||||
@@ -496,10 +498,10 @@ void UserData::setAccessHash(uint64 accessHash) {
|
||||
|
||||
void UserData::setFlags(UserDataFlags which) {
|
||||
if (!isBot()) {
|
||||
which &= ~UserDataFlag::Forum;
|
||||
which &= ~Flag::Forum;
|
||||
}
|
||||
const auto diff = flags() ^ which;
|
||||
if (diff & UserDataFlag::Deleted) {
|
||||
if (diff & Flag::Deleted) {
|
||||
invalidateEmptyUserpic();
|
||||
}
|
||||
// Let Data::Forum live till the end of _flags.set.
|
||||
@@ -515,8 +517,20 @@ void UserData::setFlags(UserDataFlags which) {
|
||||
info->ensureForum(this);
|
||||
}
|
||||
}
|
||||
_flags.set((flags() & UserDataFlag::Self)
|
||||
| (which & ~UserDataFlag::Self));
|
||||
_flags.set((flags() & Flag::Self) | (which & ~Flag::Self));
|
||||
if (diff & Flag::Forum) {
|
||||
if (const auto history = this->owner().historyLoaded(this)) {
|
||||
if (diff & Flag::Forum) {
|
||||
Core::App().notifications().clearFromHistory(history);
|
||||
history->updateChatListEntryHeight();
|
||||
if (history->inChatList()) {
|
||||
if (const auto forum = this->forum()) {
|
||||
forum->preloadTopics();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (const auto raw = takenForum.get()) {
|
||||
owner().forumIcons().clearUserpicsReset(raw);
|
||||
}
|
||||
|
||||
@@ -3171,7 +3171,7 @@ void History::tryMarkForumIntervalRead(
|
||||
MsgId wasInboxReadBefore,
|
||||
MsgId nowInboxReadBefore) {
|
||||
if (!isForum()
|
||||
|| !peer->asChannel()->useSubsectionTabs()
|
||||
|| !peer->useSubsectionTabs()
|
||||
|| (nowInboxReadBefore <= wasInboxReadBefore)) {
|
||||
return;
|
||||
} else if (loadedAtBottom() && nowInboxReadBefore >= minMsgId()) {
|
||||
@@ -3477,10 +3477,8 @@ bool History::suggestDraftAllowed() const {
|
||||
bool History::hasForumThreadBars() const {
|
||||
if (amMonoforumAdmin()) {
|
||||
return true;
|
||||
} else if (const auto channel = peer->asChannel()) {
|
||||
return channel->forum() && channel->useSubsectionTabs();
|
||||
}
|
||||
return false;
|
||||
return peer->useSubsectionTabs();
|
||||
}
|
||||
|
||||
void History::forumTabsChanged(bool forumTabs) {
|
||||
|
||||
@@ -1600,7 +1600,7 @@ void ChatWidget::validateSubsectionTabs() {
|
||||
}
|
||||
|
||||
void ChatWidget::refreshJoinGroupButton() {
|
||||
if (!_repliesRootId) {
|
||||
if (!_repliesRootId || !_peer->isChannel()) {
|
||||
return;
|
||||
}
|
||||
const auto set = [&](std::unique_ptr<Ui::FlatButton> button) {
|
||||
|
||||
@@ -111,7 +111,7 @@ rpl::producer<Ui::RequestsBarContent> RequestsBarContentByPeer(
|
||||
const auto pushNext = [=](bool now = false) {
|
||||
if ((!showInForum
|
||||
&& peer->isForum()
|
||||
&& !peer->asChannel()->useSubsectionTabs())
|
||||
&& !peer->useSubsectionTabs())
|
||||
|| (std::min(state->current.count, kRecentRequestsLimit)
|
||||
!= state->users.size())) {
|
||||
return;
|
||||
|
||||
@@ -840,11 +840,8 @@ bool SubsectionTabs::switchTo(
|
||||
|
||||
bool SubsectionTabs::UsedFor(not_null<Data::Thread*> thread) {
|
||||
const auto history = thread->owningHistory();
|
||||
if (history->amMonoforumAdmin()) {
|
||||
return true;
|
||||
}
|
||||
const auto channel = history->peer->asChannel();
|
||||
return channel && channel->useSubsectionTabs();
|
||||
return history->amMonoforumAdmin()
|
||||
|| history->peer->useSubsectionTabs();
|
||||
}
|
||||
|
||||
} // namespace HistoryView
|
||||
|
||||
@@ -1281,7 +1281,7 @@ Window::SessionController *Manager::openNotificationMessage(
|
||||
|
||||
const auto separateId = !topic
|
||||
? Window::SeparateId(history->peer)
|
||||
: history->peer->asChannel()->useSubsectionTabs()
|
||||
: history->peer->useSubsectionTabs()
|
||||
? Window::SeparateId(Window::SeparateType::Chat, topic)
|
||||
: Window::SeparateId(Window::SeparateType::Forum, history);
|
||||
const auto separate = Core::App().separateWindowFor(separateId);
|
||||
|
||||
@@ -699,7 +699,7 @@ void Filler::addNewWindow() {
|
||||
if (const auto strong = weak.get()) {
|
||||
const auto forum = !strong->asTopic()
|
||||
&& peer->isForum()
|
||||
&& !peer->asChannel()->useSubsectionTabs();
|
||||
&& !peer->useSubsectionTabs();
|
||||
controller->showInNewWindow(SeparateId(
|
||||
forum ? SeparateType::Forum : SeparateType::Chat,
|
||||
strong));
|
||||
@@ -1429,6 +1429,7 @@ void Filler::addViewAsMessages() {
|
||||
void Filler::addViewAsTopics() {
|
||||
if (!_peer
|
||||
|| !_peer->isForum()
|
||||
|| !_peer->isChannel()
|
||||
|| (_peer->asChannel()->flags() & ChannelDataFlag::ForumTabs)
|
||||
|| !_controller->adaptive().isOneColumn()) {
|
||||
return;
|
||||
@@ -2815,7 +2816,7 @@ base::weak_qptr<Ui::BoxContent> ShowForwardMessagesBox(
|
||||
return true;
|
||||
}
|
||||
const auto id = SeparateId(
|
||||
((peer->isForum() && !peer->asChannel()->useSubsectionTabs())
|
||||
((peer->isForum() && !peer->useSubsectionTabs())
|
||||
? SeparateType::Forum
|
||||
: SeparateType::Chat),
|
||||
thread);
|
||||
|
||||
Reference in New Issue
Block a user