mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Fix third column profile in topics.
This commit is contained in:
parent
602ba5bba9
commit
48fb410bc7
15 changed files with 63 additions and 28 deletions
|
@ -69,6 +69,7 @@ bool UrlRequiresConfirmation(const QUrl &url) {
|
|||
"|t\\.me"
|
||||
"|te\\.?legra\\.ph"
|
||||
"|graph\\.org"
|
||||
"|fragment\\.com"
|
||||
"|telesco\\.pe"
|
||||
")$",
|
||||
url.host(),
|
||||
|
|
|
@ -37,6 +37,11 @@ const PeerNotifySettings &Thread::notify() const {
|
|||
return const_cast<Thread*>(this)->notify();
|
||||
}
|
||||
|
||||
bool Thread::canWrite() const {
|
||||
const auto topic = asTopic();
|
||||
return topic ? topic->canWrite() : peer()->canWrite();
|
||||
}
|
||||
|
||||
void Thread::setUnreadThingsKnown() {
|
||||
_flags |= Flag::UnreadThingsKnown;
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ public:
|
|||
[[nodiscard]] PeerNotifySettings ¬ify();
|
||||
[[nodiscard]] const PeerNotifySettings ¬ify() const;
|
||||
|
||||
[[nodiscard]] bool canWrite() const;
|
||||
void setUnreadThingsKnown();
|
||||
[[nodiscard]] HistoryUnreadThings::Proxy unreadMentions();
|
||||
[[nodiscard]] HistoryUnreadThings::ConstProxy unreadMentions() const;
|
||||
|
|
|
@ -4618,13 +4618,13 @@ void HistoryWidget::showMembersDropdown() {
|
|||
}
|
||||
|
||||
bool HistoryWidget::pushTabbedSelectorToThirdSection(
|
||||
not_null<PeerData*> peer,
|
||||
not_null<Data::Thread*> thread,
|
||||
const Window::SectionShow ¶ms) {
|
||||
if (!_tabbedPanel) {
|
||||
return true;
|
||||
} else if (!peer->canWrite()) {
|
||||
} else if (!thread->canWrite()) {
|
||||
Core::App().settings().setTabbedReplacedWithInfo(true);
|
||||
controller()->showPeerInfo(peer, params.withThirdColumn());
|
||||
controller()->showPeerInfo(thread, params.withThirdColumn());
|
||||
return false;
|
||||
}
|
||||
Core::App().settings().setTabbedReplacedWithInfo(false);
|
||||
|
@ -4670,7 +4670,7 @@ bool HistoryWidget::preventsClose(Fn<void()> &&continueCallback) const {
|
|||
}
|
||||
|
||||
void HistoryWidget::toggleTabbedSelectorMode() {
|
||||
if (!_peer) {
|
||||
if (!_history) {
|
||||
return;
|
||||
}
|
||||
if (_tabbedPanel) {
|
||||
|
@ -4679,7 +4679,7 @@ void HistoryWidget::toggleTabbedSelectorMode() {
|
|||
Core::App().settings().setTabbedSelectorSectionEnabled(true);
|
||||
Core::App().saveSettingsDelayed();
|
||||
pushTabbedSelectorToThirdSection(
|
||||
_peer,
|
||||
_history,
|
||||
Window::SectionShow::Way::ClearStack);
|
||||
} else {
|
||||
_tabbedPanel->toggleAnimated();
|
||||
|
|
|
@ -269,7 +269,7 @@ public:
|
|||
|
||||
// Tabbed selector management.
|
||||
bool pushTabbedSelectorToThirdSection(
|
||||
not_null<PeerData*> peer,
|
||||
not_null<Data::Thread*> thread,
|
||||
const Window::SectionShow ¶ms) override;
|
||||
bool returnTabbedSelector() override;
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ struct SendActionUpdate {
|
|||
|
||||
struct SetHistoryArgs {
|
||||
required<History*> history;
|
||||
MsgId topicRootId = 0;
|
||||
Fn<bool()> showSlowmodeError;
|
||||
rpl::producer<int> slowmodeSecondsLeft;
|
||||
rpl::producer<bool> sendDisabledBySlowmode;
|
||||
|
|
|
@ -29,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_user.h"
|
||||
#include "data/data_chat.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_forum_topic.h"
|
||||
#include "data/stickers/data_stickers.h"
|
||||
#include "data/stickers/data_custom_emoji.h"
|
||||
#include "data/data_web_page.h"
|
||||
|
@ -893,6 +894,7 @@ void ComposeControls::setHistory(SetHistoryArgs &&args) {
|
|||
Expects(!_history && *args.history);
|
||||
|
||||
_showSlowmodeError = std::move(args.showSlowmodeError);
|
||||
_topicRootId = args.topicRootId;
|
||||
_slowmodeSecondsLeft = rpl::single(0)
|
||||
| rpl::then(std::move(args.slowmodeSecondsLeft));
|
||||
_sendDisabledBySlowmode = rpl::single(false)
|
||||
|
@ -2287,7 +2289,7 @@ void ComposeControls::escape() {
|
|||
}
|
||||
|
||||
bool ComposeControls::pushTabbedSelectorToThirdSection(
|
||||
not_null<PeerData*> peer,
|
||||
not_null<Data::Thread*> thread,
|
||||
const Window::SectionShow ¶ms) {
|
||||
if (!_tabbedPanel) {
|
||||
return true;
|
||||
|
@ -2344,8 +2346,11 @@ void ComposeControls::toggleTabbedSelectorMode() {
|
|||
&& !_window->adaptive().isOneColumn()) {
|
||||
Core::App().settings().setTabbedSelectorSectionEnabled(true);
|
||||
Core::App().saveSettingsDelayed();
|
||||
const auto topic = _topicRootId
|
||||
? _history->peer->forumTopicFor(_topicRootId)
|
||||
: nullptr;
|
||||
pushTabbedSelectorToThirdSection(
|
||||
_history->peer,
|
||||
(topic ? topic : (Data::Thread*)_history),
|
||||
Window::SectionShow::Way::ClearStack);
|
||||
} else {
|
||||
_tabbedPanel->toggleAnimated();
|
||||
|
|
|
@ -143,7 +143,7 @@ public:
|
|||
void setMimeDataHook(MimeDataHook hook);
|
||||
|
||||
bool pushTabbedSelectorToThirdSection(
|
||||
not_null<PeerData*> peer,
|
||||
not_null<Data::Thread*> thread,
|
||||
const Window::SectionShow ¶ms);
|
||||
bool returnTabbedSelector();
|
||||
|
||||
|
@ -291,6 +291,7 @@ private:
|
|||
rpl::variable<bool> _sendDisabledBySlowmode;
|
||||
rpl::variable<std::optional<QString>> _writeRestriction;
|
||||
rpl::variable<bool> _hidden;
|
||||
MsgId _topicRootId = 0;
|
||||
Mode _mode = Mode::Normal;
|
||||
|
||||
const std::unique_ptr<Ui::RpWidget> _wrap;
|
||||
|
|
|
@ -1556,9 +1556,11 @@ void RepliesWidget::setInternalState(
|
|||
}
|
||||
|
||||
bool RepliesWidget::pushTabbedSelectorToThirdSection(
|
||||
not_null<PeerData*> peer,
|
||||
not_null<Data::Thread*> thread,
|
||||
const Window::SectionShow ¶ms) {
|
||||
return _composeControls->pushTabbedSelectorToThirdSection(peer, params);
|
||||
return _composeControls->pushTabbedSelectorToThirdSection(
|
||||
thread,
|
||||
params);
|
||||
}
|
||||
|
||||
bool RepliesWidget::returnTabbedSelector() {
|
||||
|
|
|
@ -108,7 +108,7 @@ public:
|
|||
|
||||
// Tabbed selector management.
|
||||
bool pushTabbedSelectorToThirdSection(
|
||||
not_null<PeerData*> peer,
|
||||
not_null<Data::Thread*> thread,
|
||||
const Window::SectionShow ¶ms) override;
|
||||
bool returnTabbedSelector() override;
|
||||
|
||||
|
|
|
@ -920,9 +920,11 @@ void ScheduledWidget::setInternalState(
|
|||
}
|
||||
|
||||
bool ScheduledWidget::pushTabbedSelectorToThirdSection(
|
||||
not_null<PeerData*> peer,
|
||||
not_null<Data::Thread*> thread,
|
||||
const Window::SectionShow ¶ms) {
|
||||
return _composeControls->pushTabbedSelectorToThirdSection(peer, params);
|
||||
return _composeControls->pushTabbedSelectorToThirdSection(
|
||||
thread,
|
||||
params);
|
||||
}
|
||||
|
||||
bool ScheduledWidget::returnTabbedSelector() {
|
||||
|
|
|
@ -91,7 +91,7 @@ public:
|
|||
|
||||
// Tabbed selector management.
|
||||
bool pushTabbedSelectorToThirdSection(
|
||||
not_null<PeerData*> peer,
|
||||
not_null<Data::Thread*> thread,
|
||||
const Window::SectionShow ¶ms) override;
|
||||
bool returnTabbedSelector() override;
|
||||
|
||||
|
|
|
@ -380,7 +380,10 @@ void TopBarWidget::toggleInfoSection() {
|
|||
Core::App().saveSettingsDelayed();
|
||||
if (isThreeColumn) {
|
||||
_controller->showSection(
|
||||
Info::Memento::Default(_activeChat.key.peer()),
|
||||
(_activeChat.key.topic()
|
||||
? std::make_shared<Info::Memento>(
|
||||
_activeChat.key.topic())
|
||||
: Info::Memento::Default(_activeChat.key.peer())),
|
||||
Window::SectionShow().withThirdColumn());
|
||||
} else {
|
||||
_controller->resizeForThirdSection();
|
||||
|
@ -1009,12 +1012,17 @@ void TopBarWidget::updateControlsVisibility() {
|
|||
: (section == Section::ChatsList)
|
||||
? (_activeChat.key.peer() && _activeChat.key.peer()->isForum())
|
||||
: false);
|
||||
const auto hasInfo = !_activeChat.key.folder()
|
||||
&& (section == Section::History
|
||||
? true
|
||||
: (section == Section::Replies)
|
||||
? (_activeChat.key.topic() != nullptr)
|
||||
: false);
|
||||
updateSearchVisibility();
|
||||
_menuToggle->setVisible(hasMenu
|
||||
&& !_chooseForReportReason
|
||||
&& !_narrowMode);
|
||||
_infoToggle->setVisible(historyMode
|
||||
&& !_activeChat.key.folder()
|
||||
_infoToggle->setVisible(hasInfo
|
||||
&& !isOneColumn
|
||||
&& _controller->canShowThirdSection()
|
||||
&& !_chooseForReportReason);
|
||||
|
|
|
@ -2194,16 +2194,24 @@ void MainWidget::updateControlsGeometry() {
|
|||
anim::type::instant,
|
||||
anim::activation::background);
|
||||
const auto active = _controller->activeChatCurrent();
|
||||
if (const auto peer = active.peer()) {
|
||||
if (const auto thread = active.thread()) {
|
||||
if (Core::App().settings().tabbedSelectorSectionEnabled()) {
|
||||
if (_mainSection) {
|
||||
_mainSection->pushTabbedSelectorToThirdSection(peer, params);
|
||||
_mainSection->pushTabbedSelectorToThirdSection(
|
||||
thread,
|
||||
params);
|
||||
} else {
|
||||
_history->pushTabbedSelectorToThirdSection(peer, params);
|
||||
_history->pushTabbedSelectorToThirdSection(
|
||||
thread,
|
||||
params);
|
||||
}
|
||||
} else if (Core::App().settings().thirdSectionInfoEnabled()) {
|
||||
_controller->showSection(
|
||||
Info::Memento::Default(peer),
|
||||
(thread->asTopic()
|
||||
? std::make_shared<Info::Memento>(
|
||||
thread->asTopic())
|
||||
: Info::Memento::Default(
|
||||
thread->asHistory()->peer)),
|
||||
params.withThirdColumn());
|
||||
}
|
||||
}
|
||||
|
@ -2491,11 +2499,11 @@ void MainWidget::updateThirdColumnToCurrentChat(
|
|||
thirdSectionForCurrentMainSection(key),
|
||||
params.withThirdColumn());
|
||||
};
|
||||
auto switchTabbedFast = [&](not_null<PeerData*> peer) {
|
||||
auto switchTabbedFast = [&](not_null<Data::Thread*> thread) {
|
||||
saveOldThirdSection();
|
||||
return _mainSection
|
||||
? _mainSection->pushTabbedSelectorToThirdSection(peer, params)
|
||||
: _history->pushTabbedSelectorToThirdSection(peer, params);
|
||||
? _mainSection->pushTabbedSelectorToThirdSection(thread, params)
|
||||
: _history->pushTabbedSelectorToThirdSection(thread, params);
|
||||
};
|
||||
if (isThreeColumn()
|
||||
&& settings.tabbedSelectorSectionEnabled()
|
||||
|
@ -2505,8 +2513,8 @@ void MainWidget::updateThirdColumnToCurrentChat(
|
|||
settings.setTabbedSelectorSectionEnabled(true);
|
||||
settings.setTabbedReplacedWithInfo(true);
|
||||
} else if (settings.tabbedReplacedWithInfo()
|
||||
&& key.history()
|
||||
&& switchTabbedFast(key.history()->peer)) {
|
||||
&& key.thread()
|
||||
&& switchTabbedFast(key.thread())) {
|
||||
settings.setTabbedReplacedWithInfo(false);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -18,6 +18,7 @@ class PeerData;
|
|||
|
||||
namespace Data {
|
||||
struct ReactionId;
|
||||
class ForumTopic;
|
||||
} // namespace Data
|
||||
|
||||
namespace Main {
|
||||
|
@ -58,7 +59,7 @@ public:
|
|||
|
||||
// Tabbed selector management.
|
||||
virtual bool pushTabbedSelectorToThirdSection(
|
||||
not_null<PeerData*> peer,
|
||||
not_null<Data::Thread*> thread,
|
||||
const SectionShow ¶ms) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue