mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-03 21:54:05 +02:00
Added some special cases when quick dialog action can't be performed.
This commit is contained in:
parent
bdf8a37a8f
commit
28c125a3ec
3 changed files with 24 additions and 6 deletions
|
@ -125,6 +125,9 @@ Ui::QuickDialogActionLabel ResolveQuickDialogLabel(
|
|||
Ui::QuickDialogAction action,
|
||||
FilterId filterId) {
|
||||
if (action == Dialogs::Ui::QuickDialogAction::Mute) {
|
||||
if (history->peer->isSelf()) {
|
||||
return Ui::QuickDialogActionLabel::Disabled;
|
||||
}
|
||||
const auto isMuted = rpl::variable<bool>(
|
||||
MuteMenu::ThreadDescriptor(history).isMutedValue()).current();
|
||||
return isMuted
|
||||
|
@ -136,10 +139,17 @@ Ui::QuickDialogActionLabel ResolveQuickDialogLabel(
|
|||
? Ui::QuickDialogActionLabel::Unpin
|
||||
: Ui::QuickDialogActionLabel::Pin;
|
||||
} else if (action == Dialogs::Ui::QuickDialogAction::Read) {
|
||||
return Window::IsUnreadThread(history)
|
||||
const auto unread = Window::IsUnreadThread(history);
|
||||
if (history->isForum() && !unread) {
|
||||
return Ui::QuickDialogActionLabel::Disabled;
|
||||
}
|
||||
return unread
|
||||
? Ui::QuickDialogActionLabel::Read
|
||||
: Ui::QuickDialogActionLabel::Unread;
|
||||
} else if (action == Dialogs::Ui::QuickDialogAction::Archive) {
|
||||
if (!Window::CanArchive(history, history->peer)) {
|
||||
return Ui::QuickDialogActionLabel::Disabled;
|
||||
}
|
||||
return Window::IsArchived(history)
|
||||
? Ui::QuickDialogActionLabel::Unarchive
|
||||
: Ui::QuickDialogActionLabel::Archive;
|
||||
|
|
|
@ -684,12 +684,8 @@ void Filler::addToggleArchive() {
|
|||
}
|
||||
const auto peer = _peer;
|
||||
const auto history = _request.key.history();
|
||||
if (history && history->useTopPromotion()) {
|
||||
if (!CanArchive(history, peer)) {
|
||||
return;
|
||||
} else if (peer->isNotificationsUser() || peer->isSelf()) {
|
||||
if (!history || !history->folder()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
const auto isArchived = [=] {
|
||||
return IsArchived(history);
|
||||
|
@ -3320,4 +3316,15 @@ bool IsArchived(not_null<History*> history) {
|
|||
return (history->folder() != nullptr);
|
||||
}
|
||||
|
||||
bool CanArchive(History *history, PeerData *peer) {
|
||||
if (history && history->useTopPromotion()) {
|
||||
return false;
|
||||
} else if (peer && (peer->isNotificationsUser() || peer->isSelf())) {
|
||||
if (!history || !history->folder()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace Window
|
||||
|
|
|
@ -216,5 +216,6 @@ void MarkAsReadThread(not_null<Data::Thread*> thread);
|
|||
void AddSeparatorAndShiftUp(const PeerMenuCallback &addAction);
|
||||
|
||||
[[nodiscard]] bool IsArchived(not_null<History*> history);
|
||||
[[nodiscard]] bool CanArchive(History *history, PeerData *peer);
|
||||
|
||||
} // namespace Window
|
||||
|
|
Loading…
Add table
Reference in a new issue