mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 22:54:01 +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,
|
Ui::QuickDialogAction action,
|
||||||
FilterId filterId) {
|
FilterId filterId) {
|
||||||
if (action == Dialogs::Ui::QuickDialogAction::Mute) {
|
if (action == Dialogs::Ui::QuickDialogAction::Mute) {
|
||||||
|
if (history->peer->isSelf()) {
|
||||||
|
return Ui::QuickDialogActionLabel::Disabled;
|
||||||
|
}
|
||||||
const auto isMuted = rpl::variable<bool>(
|
const auto isMuted = rpl::variable<bool>(
|
||||||
MuteMenu::ThreadDescriptor(history).isMutedValue()).current();
|
MuteMenu::ThreadDescriptor(history).isMutedValue()).current();
|
||||||
return isMuted
|
return isMuted
|
||||||
|
@ -136,10 +139,17 @@ Ui::QuickDialogActionLabel ResolveQuickDialogLabel(
|
||||||
? Ui::QuickDialogActionLabel::Unpin
|
? Ui::QuickDialogActionLabel::Unpin
|
||||||
: Ui::QuickDialogActionLabel::Pin;
|
: Ui::QuickDialogActionLabel::Pin;
|
||||||
} else if (action == Dialogs::Ui::QuickDialogAction::Read) {
|
} 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::Read
|
||||||
: Ui::QuickDialogActionLabel::Unread;
|
: Ui::QuickDialogActionLabel::Unread;
|
||||||
} else if (action == Dialogs::Ui::QuickDialogAction::Archive) {
|
} else if (action == Dialogs::Ui::QuickDialogAction::Archive) {
|
||||||
|
if (!Window::CanArchive(history, history->peer)) {
|
||||||
|
return Ui::QuickDialogActionLabel::Disabled;
|
||||||
|
}
|
||||||
return Window::IsArchived(history)
|
return Window::IsArchived(history)
|
||||||
? Ui::QuickDialogActionLabel::Unarchive
|
? Ui::QuickDialogActionLabel::Unarchive
|
||||||
: Ui::QuickDialogActionLabel::Archive;
|
: Ui::QuickDialogActionLabel::Archive;
|
||||||
|
|
|
@ -684,12 +684,8 @@ void Filler::addToggleArchive() {
|
||||||
}
|
}
|
||||||
const auto peer = _peer;
|
const auto peer = _peer;
|
||||||
const auto history = _request.key.history();
|
const auto history = _request.key.history();
|
||||||
if (history && history->useTopPromotion()) {
|
if (!CanArchive(history, peer)) {
|
||||||
return;
|
return;
|
||||||
} else if (peer->isNotificationsUser() || peer->isSelf()) {
|
|
||||||
if (!history || !history->folder()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const auto isArchived = [=] {
|
const auto isArchived = [=] {
|
||||||
return IsArchived(history);
|
return IsArchived(history);
|
||||||
|
@ -3320,4 +3316,15 @@ bool IsArchived(not_null<History*> history) {
|
||||||
return (history->folder() != nullptr);
|
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
|
} // namespace Window
|
||||||
|
|
|
@ -216,5 +216,6 @@ void MarkAsReadThread(not_null<Data::Thread*> thread);
|
||||||
void AddSeparatorAndShiftUp(const PeerMenuCallback &addAction);
|
void AddSeparatorAndShiftUp(const PeerMenuCallback &addAction);
|
||||||
|
|
||||||
[[nodiscard]] bool IsArchived(not_null<History*> history);
|
[[nodiscard]] bool IsArchived(not_null<History*> history);
|
||||||
|
[[nodiscard]] bool CanArchive(History *history, PeerData *peer);
|
||||||
|
|
||||||
} // namespace Window
|
} // namespace Window
|
||||||
|
|
Loading…
Add table
Reference in a new issue