mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-07-26 23:43:06 +02:00
Improve monoforum opening.
This commit is contained in:
parent
646b852717
commit
7dc8943840
10 changed files with 53 additions and 19 deletions
|
@ -461,6 +461,10 @@ rpl::producer<bool> ChatFilters::tagsEnabledValue() const {
|
|||
return _tagsEnabled.value();
|
||||
}
|
||||
|
||||
rpl::producer<bool> ChatFilters::tagsEnabledChanges() const {
|
||||
return _tagsEnabled.changes();
|
||||
}
|
||||
|
||||
void ChatFilters::requestToggleTags(bool value, Fn<void()> fail) {
|
||||
if (_toggleTagsRequestId) {
|
||||
return;
|
||||
|
|
|
@ -213,6 +213,7 @@ public:
|
|||
|
||||
[[nodiscard]] bool tagsEnabled() const;
|
||||
[[nodiscard]] rpl::producer<bool> tagsEnabledValue() const;
|
||||
[[nodiscard]] rpl::producer<bool> tagsEnabledChanges() const;
|
||||
void requestToggleTags(bool value, Fn<void()> fail);
|
||||
|
||||
private:
|
||||
|
|
|
@ -1162,6 +1162,17 @@ not_null<const PeerData*> PeerData::migrateToOrMe() const {
|
|||
return this;
|
||||
}
|
||||
|
||||
not_null<PeerData*> PeerData::userpicPaintingPeer() {
|
||||
if (const auto broadcast = monoforumBroadcast()) {
|
||||
return broadcast;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
not_null<const PeerData*> PeerData::userpicPaintingPeer() const {
|
||||
return const_cast<PeerData*>(this)->userpicPaintingPeer();
|
||||
}
|
||||
|
||||
ChannelData *PeerData::monoforumBroadcast() const {
|
||||
const auto monoforum = asMonoforum();
|
||||
return monoforum ? monoforum->monoforumLink() : nullptr;
|
||||
|
|
|
@ -305,6 +305,8 @@ public:
|
|||
[[nodiscard]] ChannelData *migrateTo() const;
|
||||
[[nodiscard]] not_null<PeerData*> migrateToOrMe();
|
||||
[[nodiscard]] not_null<const PeerData*> migrateToOrMe() const;
|
||||
[[nodiscard]] not_null<PeerData*> userpicPaintingPeer();
|
||||
[[nodiscard]] not_null<const PeerData*> userpicPaintingPeer() const;
|
||||
|
||||
// isMonoforum() ? monoforumLink() : nullptr
|
||||
[[nodiscard]] ChannelData *monoforumBroadcast() const;
|
||||
|
|
|
@ -366,7 +366,9 @@ InnerWidget::InnerWidget(
|
|||
|
||||
rpl::merge(
|
||||
session().settings().archiveCollapsedChanges() | rpl::map_to(false),
|
||||
session().data().chatsFilters().changed() | rpl::map_to(true)
|
||||
session().data().chatsFilters().changed() | rpl::map_to(true),
|
||||
session().data().chatsFilters().tagsEnabledChanges(
|
||||
) | rpl::map_to(true)
|
||||
) | rpl::start_with_next([=](bool refreshHeight) {
|
||||
if (refreshHeight) {
|
||||
_chatsFilterTags.clear();
|
||||
|
@ -379,11 +381,8 @@ InnerWidget::InnerWidget(
|
|||
}, lifetime());
|
||||
|
||||
session().data().chatsFilters().tagsEnabledValue(
|
||||
) | rpl::distinct_until_changed() | rpl::start_with_next([=](bool tags) {
|
||||
) | rpl::start_with_next([=](bool tags) {
|
||||
_handleChatListEntryTagRefreshesLifetime.destroy();
|
||||
if (_shownList->updateHeights(_narrowRatio)) {
|
||||
refresh();
|
||||
}
|
||||
if (!tags) {
|
||||
return;
|
||||
}
|
||||
|
@ -1499,8 +1498,16 @@ bool InnerWidget::isRowActive(
|
|||
not_null<Row*> row,
|
||||
const RowDescriptor &entry) const {
|
||||
const auto key = row->key();
|
||||
return (entry.key == key)
|
||||
|| (entry.key.sublist() && key.peer() && key.peer()->isSelf());
|
||||
if (entry.key == key) {
|
||||
return true;
|
||||
} else if (const auto sublist = entry.key.sublist()) {
|
||||
if (!sublist->parentChat()) {
|
||||
// In case we're viewing a Saved Messages sublist,
|
||||
// we want to highlight the Saved Messages row as active.
|
||||
return key.history() && key.peer()->isSelf();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool InnerWidget::isSearchResultActive(
|
||||
|
|
|
@ -320,7 +320,9 @@ Row::~Row() {
|
|||
void Row::recountHeight(float64 narrowRatio, FilterId filterId) {
|
||||
if (const auto history = _id.history()) {
|
||||
const auto hasTags = _id.entry()->hasChatsFilterTags(filterId);
|
||||
_height = (history->isForum() || history->amMonoforumAdmin())
|
||||
const auto wideRow = history->isForum()
|
||||
|| history->amMonoforumAdmin();
|
||||
_height = wideRow
|
||||
? anim::interpolate(
|
||||
hasTags
|
||||
? st::taggedForumDialogRow.height
|
||||
|
|
|
@ -942,8 +942,7 @@ void Widget::chosenRow(const ChosenRow &row) {
|
|||
return;
|
||||
} else if (history
|
||||
&& history->peer->amMonoforumAdmin()
|
||||
&& !row.message.fullId
|
||||
&& !controller()->adaptive().isOneColumn()) {
|
||||
&& !row.message.fullId) {
|
||||
const auto monoforum = history->peer->monoforum();
|
||||
if (controller()->shownMonoforum().current() == monoforum) {
|
||||
controller()->closeMonoforum();
|
||||
|
@ -954,11 +953,13 @@ void Widget::chosenRow(const ChosenRow &row) {
|
|||
controller()->showMonoforum(
|
||||
monoforum,
|
||||
Window::SectionShow().withChildColumn());
|
||||
if (!controller()->adaptive().isOneColumn()) {
|
||||
controller()->showThread(
|
||||
history,
|
||||
ShowAtUnreadMsgId,
|
||||
Window::SectionShow::Way::ClearStack);
|
||||
}
|
||||
}
|
||||
return;
|
||||
} else if (history) {
|
||||
const auto peer = history->peer;
|
||||
|
|
|
@ -929,10 +929,16 @@ void TopBarWidget::refreshInfoButton() {
|
|||
&& !rootChatsListBar())) {
|
||||
_info.destroy();
|
||||
} else if (const auto peer = _activeChat.key.peer()) {
|
||||
const auto sublist = _activeChat.key.sublist();
|
||||
const auto infoPeer = sublist ? sublist->sublistPeer().get() : peer;
|
||||
auto info = object_ptr<Ui::UserpicButton>(
|
||||
this,
|
||||
peer,
|
||||
st::topBarInfoButton);
|
||||
_controller,
|
||||
infoPeer->userpicPaintingPeer(),
|
||||
Ui::UserpicButton::Role::Custom,
|
||||
Ui::UserpicButton::Source::PeerPhoto,
|
||||
st::topBarInfoButton,
|
||||
infoPeer->monoforumBroadcast() != nullptr);
|
||||
info->showSavedMessagesOnSelf(true);
|
||||
_info.destroy();
|
||||
_info = std::move(info);
|
||||
|
|
|
@ -628,9 +628,7 @@ Cover::Cover(
|
|||
: object_ptr<Ui::UserpicButton>(
|
||||
this,
|
||||
controller,
|
||||
(_peer->monoforumBroadcast()
|
||||
? _peer->monoforumBroadcast()
|
||||
: _peer),
|
||||
_peer->userpicPaintingPeer(),
|
||||
Ui::UserpicButton::Role::OpenPhoto,
|
||||
Ui::UserpicButton::Source::PeerPhoto,
|
||||
_st.photo,
|
||||
|
|
|
@ -1906,6 +1906,7 @@ void SessionController::showForum(
|
|||
}
|
||||
}, _shownForumLifetime);
|
||||
content()->showForum(forum, params);
|
||||
closeMonoforum();
|
||||
}
|
||||
|
||||
void SessionController::closeForum() {
|
||||
|
@ -1980,6 +1981,7 @@ void SessionController::showMonoforum(
|
|||
closeMonoforum();
|
||||
}, _shownMonoforumLifetime);
|
||||
content()->showMonoforum(monoforum, params);
|
||||
closeForum();
|
||||
}
|
||||
|
||||
void SessionController::closeMonoforum() {
|
||||
|
|
Loading…
Add table
Reference in a new issue