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();
|
return _tagsEnabled.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rpl::producer<bool> ChatFilters::tagsEnabledChanges() const {
|
||||||
|
return _tagsEnabled.changes();
|
||||||
|
}
|
||||||
|
|
||||||
void ChatFilters::requestToggleTags(bool value, Fn<void()> fail) {
|
void ChatFilters::requestToggleTags(bool value, Fn<void()> fail) {
|
||||||
if (_toggleTagsRequestId) {
|
if (_toggleTagsRequestId) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -213,6 +213,7 @@ public:
|
||||||
|
|
||||||
[[nodiscard]] bool tagsEnabled() const;
|
[[nodiscard]] bool tagsEnabled() const;
|
||||||
[[nodiscard]] rpl::producer<bool> tagsEnabledValue() const;
|
[[nodiscard]] rpl::producer<bool> tagsEnabledValue() const;
|
||||||
|
[[nodiscard]] rpl::producer<bool> tagsEnabledChanges() const;
|
||||||
void requestToggleTags(bool value, Fn<void()> fail);
|
void requestToggleTags(bool value, Fn<void()> fail);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -1162,6 +1162,17 @@ not_null<const PeerData*> PeerData::migrateToOrMe() const {
|
||||||
return this;
|
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 {
|
ChannelData *PeerData::monoforumBroadcast() const {
|
||||||
const auto monoforum = asMonoforum();
|
const auto monoforum = asMonoforum();
|
||||||
return monoforum ? monoforum->monoforumLink() : nullptr;
|
return monoforum ? monoforum->monoforumLink() : nullptr;
|
||||||
|
|
|
@ -305,6 +305,8 @@ public:
|
||||||
[[nodiscard]] ChannelData *migrateTo() const;
|
[[nodiscard]] ChannelData *migrateTo() const;
|
||||||
[[nodiscard]] not_null<PeerData*> migrateToOrMe();
|
[[nodiscard]] not_null<PeerData*> migrateToOrMe();
|
||||||
[[nodiscard]] not_null<const PeerData*> migrateToOrMe() const;
|
[[nodiscard]] not_null<const PeerData*> migrateToOrMe() const;
|
||||||
|
[[nodiscard]] not_null<PeerData*> userpicPaintingPeer();
|
||||||
|
[[nodiscard]] not_null<const PeerData*> userpicPaintingPeer() const;
|
||||||
|
|
||||||
// isMonoforum() ? monoforumLink() : nullptr
|
// isMonoforum() ? monoforumLink() : nullptr
|
||||||
[[nodiscard]] ChannelData *monoforumBroadcast() const;
|
[[nodiscard]] ChannelData *monoforumBroadcast() const;
|
||||||
|
|
|
@ -366,7 +366,9 @@ InnerWidget::InnerWidget(
|
||||||
|
|
||||||
rpl::merge(
|
rpl::merge(
|
||||||
session().settings().archiveCollapsedChanges() | rpl::map_to(false),
|
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) {
|
) | rpl::start_with_next([=](bool refreshHeight) {
|
||||||
if (refreshHeight) {
|
if (refreshHeight) {
|
||||||
_chatsFilterTags.clear();
|
_chatsFilterTags.clear();
|
||||||
|
@ -379,11 +381,8 @@ InnerWidget::InnerWidget(
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
session().data().chatsFilters().tagsEnabledValue(
|
session().data().chatsFilters().tagsEnabledValue(
|
||||||
) | rpl::distinct_until_changed() | rpl::start_with_next([=](bool tags) {
|
) | rpl::start_with_next([=](bool tags) {
|
||||||
_handleChatListEntryTagRefreshesLifetime.destroy();
|
_handleChatListEntryTagRefreshesLifetime.destroy();
|
||||||
if (_shownList->updateHeights(_narrowRatio)) {
|
|
||||||
refresh();
|
|
||||||
}
|
|
||||||
if (!tags) {
|
if (!tags) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1499,8 +1498,16 @@ bool InnerWidget::isRowActive(
|
||||||
not_null<Row*> row,
|
not_null<Row*> row,
|
||||||
const RowDescriptor &entry) const {
|
const RowDescriptor &entry) const {
|
||||||
const auto key = row->key();
|
const auto key = row->key();
|
||||||
return (entry.key == key)
|
if (entry.key == key) {
|
||||||
|| (entry.key.sublist() && key.peer() && key.peer()->isSelf());
|
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(
|
bool InnerWidget::isSearchResultActive(
|
||||||
|
|
|
@ -320,7 +320,9 @@ Row::~Row() {
|
||||||
void Row::recountHeight(float64 narrowRatio, FilterId filterId) {
|
void Row::recountHeight(float64 narrowRatio, FilterId filterId) {
|
||||||
if (const auto history = _id.history()) {
|
if (const auto history = _id.history()) {
|
||||||
const auto hasTags = _id.entry()->hasChatsFilterTags(filterId);
|
const auto hasTags = _id.entry()->hasChatsFilterTags(filterId);
|
||||||
_height = (history->isForum() || history->amMonoforumAdmin())
|
const auto wideRow = history->isForum()
|
||||||
|
|| history->amMonoforumAdmin();
|
||||||
|
_height = wideRow
|
||||||
? anim::interpolate(
|
? anim::interpolate(
|
||||||
hasTags
|
hasTags
|
||||||
? st::taggedForumDialogRow.height
|
? st::taggedForumDialogRow.height
|
||||||
|
|
|
@ -942,8 +942,7 @@ void Widget::chosenRow(const ChosenRow &row) {
|
||||||
return;
|
return;
|
||||||
} else if (history
|
} else if (history
|
||||||
&& history->peer->amMonoforumAdmin()
|
&& history->peer->amMonoforumAdmin()
|
||||||
&& !row.message.fullId
|
&& !row.message.fullId) {
|
||||||
&& !controller()->adaptive().isOneColumn()) {
|
|
||||||
const auto monoforum = history->peer->monoforum();
|
const auto monoforum = history->peer->monoforum();
|
||||||
if (controller()->shownMonoforum().current() == monoforum) {
|
if (controller()->shownMonoforum().current() == monoforum) {
|
||||||
controller()->closeMonoforum();
|
controller()->closeMonoforum();
|
||||||
|
@ -954,10 +953,12 @@ void Widget::chosenRow(const ChosenRow &row) {
|
||||||
controller()->showMonoforum(
|
controller()->showMonoforum(
|
||||||
monoforum,
|
monoforum,
|
||||||
Window::SectionShow().withChildColumn());
|
Window::SectionShow().withChildColumn());
|
||||||
controller()->showThread(
|
if (!controller()->adaptive().isOneColumn()) {
|
||||||
history,
|
controller()->showThread(
|
||||||
ShowAtUnreadMsgId,
|
history,
|
||||||
Window::SectionShow::Way::ClearStack);
|
ShowAtUnreadMsgId,
|
||||||
|
Window::SectionShow::Way::ClearStack);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else if (history) {
|
} else if (history) {
|
||||||
|
|
|
@ -929,10 +929,16 @@ void TopBarWidget::refreshInfoButton() {
|
||||||
&& !rootChatsListBar())) {
|
&& !rootChatsListBar())) {
|
||||||
_info.destroy();
|
_info.destroy();
|
||||||
} else if (const auto peer = _activeChat.key.peer()) {
|
} 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>(
|
auto info = object_ptr<Ui::UserpicButton>(
|
||||||
this,
|
this,
|
||||||
peer,
|
_controller,
|
||||||
st::topBarInfoButton);
|
infoPeer->userpicPaintingPeer(),
|
||||||
|
Ui::UserpicButton::Role::Custom,
|
||||||
|
Ui::UserpicButton::Source::PeerPhoto,
|
||||||
|
st::topBarInfoButton,
|
||||||
|
infoPeer->monoforumBroadcast() != nullptr);
|
||||||
info->showSavedMessagesOnSelf(true);
|
info->showSavedMessagesOnSelf(true);
|
||||||
_info.destroy();
|
_info.destroy();
|
||||||
_info = std::move(info);
|
_info = std::move(info);
|
||||||
|
|
|
@ -628,9 +628,7 @@ Cover::Cover(
|
||||||
: object_ptr<Ui::UserpicButton>(
|
: object_ptr<Ui::UserpicButton>(
|
||||||
this,
|
this,
|
||||||
controller,
|
controller,
|
||||||
(_peer->monoforumBroadcast()
|
_peer->userpicPaintingPeer(),
|
||||||
? _peer->monoforumBroadcast()
|
|
||||||
: _peer),
|
|
||||||
Ui::UserpicButton::Role::OpenPhoto,
|
Ui::UserpicButton::Role::OpenPhoto,
|
||||||
Ui::UserpicButton::Source::PeerPhoto,
|
Ui::UserpicButton::Source::PeerPhoto,
|
||||||
_st.photo,
|
_st.photo,
|
||||||
|
|
|
@ -1906,6 +1906,7 @@ void SessionController::showForum(
|
||||||
}
|
}
|
||||||
}, _shownForumLifetime);
|
}, _shownForumLifetime);
|
||||||
content()->showForum(forum, params);
|
content()->showForum(forum, params);
|
||||||
|
closeMonoforum();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionController::closeForum() {
|
void SessionController::closeForum() {
|
||||||
|
@ -1980,6 +1981,7 @@ void SessionController::showMonoforum(
|
||||||
closeMonoforum();
|
closeMonoforum();
|
||||||
}, _shownMonoforumLifetime);
|
}, _shownMonoforumLifetime);
|
||||||
content()->showMonoforum(monoforum, params);
|
content()->showMonoforum(monoforum, params);
|
||||||
|
closeForum();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionController::closeMonoforum() {
|
void SessionController::closeMonoforum() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue