mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Add "View Discussion" button to third column.
This commit is contained in:
parent
65d6636a41
commit
e92270a9ab
9 changed files with 65 additions and 17 deletions
|
@ -121,8 +121,12 @@ struct EntryState {
|
|||
FilterId filterId = 0;
|
||||
FullReplyTo currentReplyTo;
|
||||
|
||||
friend inline auto operator<=>(EntryState, EntryState) noexcept
|
||||
= default;
|
||||
friend inline auto operator<=>(
|
||||
const EntryState&,
|
||||
const EntryState&) = default;
|
||||
friend inline bool operator==(
|
||||
const EntryState&,
|
||||
const EntryState&) = default;
|
||||
};
|
||||
|
||||
struct SearchState {
|
||||
|
|
|
@ -1014,7 +1014,7 @@ void HistoryWidget::refreshTopBarActiveChat() {
|
|||
const auto state = computeDialogsEntryState();
|
||||
_topBar->setActiveChat(state, _history->sendActionPainter());
|
||||
if (state.key) {
|
||||
controller()->setCurrentDialogsEntryState(state);
|
||||
controller()->setDialogsEntryState(state);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1989,7 +1989,7 @@ bool HistoryWidget::notify_switchInlineBotButtonReceived(
|
|||
UserData *samePeerBot,
|
||||
MsgId samePeerReplyTo) {
|
||||
if (samePeerBot) {
|
||||
const auto to = controller()->currentDialogsEntryState();
|
||||
const auto to = controller()->dialogsEntryStateCurrent();
|
||||
if (!to.key.owningHistory()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -2222,7 +2222,7 @@ void HistoryWidget::showHistory(
|
|||
_showAtMsgHighlightPart = {};
|
||||
_showAtMsgHighlightPartOffsetHint = 0;
|
||||
|
||||
const auto wasState = controller()->currentDialogsEntryState();
|
||||
const auto wasState = controller()->dialogsEntryStateCurrent();
|
||||
const auto startBot = (showAtMsgId == ShowAndStartBotMsgId);
|
||||
_showAndMaybeSendStart = (showAtMsgId == ShowAndMaybeStartBotMsgId);
|
||||
if (startBot || _showAndMaybeSendStart) {
|
||||
|
|
|
@ -1521,7 +1521,7 @@ void RepliesWidget::refreshTopBarActiveChat() {
|
|||
};
|
||||
_topBar->setActiveChat(state, _sendAction.get());
|
||||
_composeControls->setCurrentDialogsEntryState(state);
|
||||
controller()->setCurrentDialogsEntryState(state);
|
||||
controller()->setDialogsEntryState(state);
|
||||
}
|
||||
|
||||
void RepliesWidget::refreshUnreadCountBadge(std::optional<int> count) {
|
||||
|
|
|
@ -186,7 +186,7 @@ ScheduledWidget::ScheduledWidget(
|
|||
};
|
||||
_topBar->setActiveChat(state, nullptr);
|
||||
_composeControls->setCurrentDialogsEntryState(state);
|
||||
controller->setCurrentDialogsEntryState(state);
|
||||
controller->setDialogsEntryState(state);
|
||||
|
||||
_topBar->move(0, 0);
|
||||
_topBar->resizeToWidth(width());
|
||||
|
|
|
@ -967,6 +967,8 @@ private:
|
|||
not_null<UserData*> user);
|
||||
Ui::MultiSlideTracker fillChannelButtons(
|
||||
not_null<ChannelData*> channel);
|
||||
Ui::MultiSlideTracker fillDiscussionButtons(
|
||||
not_null<ChannelData*> channel);
|
||||
|
||||
void addReportReaction(Ui::MultiSlideTracker &tracker);
|
||||
void addReportReaction(
|
||||
|
@ -1915,7 +1917,11 @@ void DetailsFiller::setupMainButtons() {
|
|||
return fillUserButtons(user);
|
||||
});
|
||||
} else if (const auto channel = _peer->asChannel()) {
|
||||
if (!channel->isMegagroup()) {
|
||||
if (channel->isMegagroup()) {
|
||||
wrapButtons([=] {
|
||||
return fillDiscussionButtons(channel);
|
||||
});
|
||||
} else {
|
||||
wrapButtons([=] {
|
||||
return fillChannelButtons(channel);
|
||||
});
|
||||
|
@ -2080,6 +2086,37 @@ Ui::MultiSlideTracker DetailsFiller::fillChannelButtons(
|
|||
return tracker;
|
||||
}
|
||||
|
||||
Ui::MultiSlideTracker DetailsFiller::fillDiscussionButtons(
|
||||
not_null<ChannelData*> channel) {
|
||||
using namespace rpl::mappers;
|
||||
|
||||
Ui::MultiSlideTracker tracker;
|
||||
auto window = _controller->parentController();
|
||||
auto viewDiscussionVisible = rpl::combine(
|
||||
_controller->wrapValue(),
|
||||
window->dialogsEntryStateValue()
|
||||
) | rpl::map([=](Wrap wrap, const Dialogs::EntryState &state) {
|
||||
const auto history = state.key.history();
|
||||
return (wrap == Wrap::Side)
|
||||
&& (state.section == Dialogs::EntryState::Section::Replies)
|
||||
&& history
|
||||
&& (history->peer == channel);
|
||||
});
|
||||
auto viewDiscussion = [=] {
|
||||
window->showPeerHistory(
|
||||
channel,
|
||||
Window::SectionShow::Way::Forward);
|
||||
};
|
||||
AddMainButton(
|
||||
_wrap,
|
||||
tr::lng_profile_view_discussion(),
|
||||
std::move(viewDiscussionVisible),
|
||||
std::move(viewDiscussion),
|
||||
tracker);
|
||||
|
||||
return tracker;
|
||||
}
|
||||
|
||||
object_ptr<Ui::RpWidget> DetailsFiller::fill() {
|
||||
Expects(!_topic || !_topic->creating());
|
||||
|
||||
|
|
|
@ -348,7 +348,7 @@ WebViewContext ResolveContext(
|
|||
WebViewContext context) {
|
||||
if (!context.dialogsEntryState.key) {
|
||||
if (const auto strong = context.controller.get()) {
|
||||
context.dialogsEntryState = strong->currentDialogsEntryState();
|
||||
context.dialogsEntryState = strong->dialogsEntryStateCurrent();
|
||||
}
|
||||
}
|
||||
if (!context.action) {
|
||||
|
|
|
@ -700,7 +700,7 @@ void Inner::switchPm() {
|
|||
} else {
|
||||
_inlineBot->botInfo->startToken = _switchPmStartToken;
|
||||
_inlineBot->botInfo->inlineReturnTo
|
||||
= _controller->currentDialogsEntryState();
|
||||
= _controller->dialogsEntryStateCurrent();
|
||||
_controller->showPeerHistory(
|
||||
_inlineBot,
|
||||
Window::SectionShow::Way::ClearStack,
|
||||
|
|
|
@ -1847,13 +1847,18 @@ bool SessionController::jumpToChatListEntry(Dialogs::RowDescriptor row) {
|
|||
return false;
|
||||
}
|
||||
|
||||
void SessionController::setCurrentDialogsEntryState(
|
||||
void SessionController::setDialogsEntryState(
|
||||
Dialogs::EntryState state) {
|
||||
_currentDialogsEntryState = state;
|
||||
_dialogsEntryState = state;
|
||||
}
|
||||
|
||||
Dialogs::EntryState SessionController::currentDialogsEntryState() const {
|
||||
return _currentDialogsEntryState;
|
||||
Dialogs::EntryState SessionController::dialogsEntryStateCurrent() const {
|
||||
return _dialogsEntryState.current();
|
||||
}
|
||||
|
||||
auto SessionController::dialogsEntryStateValue() const
|
||||
-> rpl::producer<Dialogs::EntryState> {
|
||||
return _dialogsEntryState.value();
|
||||
}
|
||||
|
||||
bool SessionController::switchInlineQuery(
|
||||
|
|
|
@ -394,8 +394,10 @@ public:
|
|||
rpl::producer<Dialogs::Key> activeChatValue() const;
|
||||
bool jumpToChatListEntry(Dialogs::RowDescriptor row);
|
||||
|
||||
void setCurrentDialogsEntryState(Dialogs::EntryState state);
|
||||
[[nodiscard]] Dialogs::EntryState currentDialogsEntryState() const;
|
||||
void setDialogsEntryState(Dialogs::EntryState state);
|
||||
[[nodiscard]] Dialogs::EntryState dialogsEntryStateCurrent() const;
|
||||
[[nodiscard]] auto dialogsEntryStateValue() const
|
||||
-> rpl::producer<Dialogs::EntryState>;
|
||||
bool switchInlineQuery(
|
||||
Dialogs::EntryState to,
|
||||
not_null<UserData*> bot,
|
||||
|
@ -708,7 +710,7 @@ private:
|
|||
int _chatEntryHistoryPosition = -1;
|
||||
bool _filtersActivated = false;
|
||||
|
||||
Dialogs::EntryState _currentDialogsEntryState;
|
||||
rpl::variable<Dialogs::EntryState> _dialogsEntryState;
|
||||
|
||||
base::Timer _invitePeekTimer;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue