mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 22:54:01 +02:00
Simplified signature of ResolveQuickDialogLottieIconName.
This commit is contained in:
parent
efc7cc4980
commit
47506d70ed
3 changed files with 32 additions and 36 deletions
|
@ -1944,13 +1944,14 @@ bool InnerWidget::addQuickActionRipple(
|
||||||
if (!history) {
|
if (!history) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
const auto type = ResolveQuickDialogLabel(history, action, _filterId);
|
||||||
|
if (type == Dialogs::Ui::QuickDialogActionLabel::Disabled) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
const auto key = history->peer->id.value;
|
const auto key = history->peer->id.value;
|
||||||
const auto context = ensureQuickAction(key);
|
const auto context = ensureQuickAction(key);
|
||||||
|
|
||||||
auto name = ResolveQuickDialogLottieIconName(
|
auto name = ResolveQuickDialogLottieIconName(type);
|
||||||
history->peer,
|
|
||||||
action,
|
|
||||||
_filterId);
|
|
||||||
context->icon = Lottie::MakeIcon({
|
context->icon = Lottie::MakeIcon({
|
||||||
.name = std::move(name),
|
.name = std::move(name),
|
||||||
.sizeOverride = Size(st::dialogsQuickActionSize),
|
.sizeOverride = Size(st::dialogsQuickActionSize),
|
||||||
|
@ -5156,8 +5157,11 @@ void InnerWidget::prepareQuickAction(
|
||||||
Expects(key != 0);
|
Expects(key != 0);
|
||||||
|
|
||||||
const auto context = ensureQuickAction(key);
|
const auto context = ensureQuickAction(key);
|
||||||
const auto peer = session().data().peer(PeerId(key));
|
auto name = ResolveQuickDialogLottieIconName(
|
||||||
auto name = ResolveQuickDialogLottieIconName(peer, action, _filterId);
|
ResolveQuickDialogLabel(
|
||||||
|
session().data().history(PeerId(key)),
|
||||||
|
action,
|
||||||
|
_filterId));
|
||||||
context->icon = Lottie::MakeIcon({
|
context->icon = Lottie::MakeIcon({
|
||||||
.name = std::move(name),
|
.name = std::move(name),
|
||||||
.sizeOverride = Size(st::dialogsQuickActionSize),
|
.sizeOverride = Size(st::dialogsQuickActionSize),
|
||||||
|
|
|
@ -95,35 +95,29 @@ void PerformQuickDialogAction(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ResolveQuickDialogLottieIconName(
|
QString ResolveQuickDialogLottieIconName(Ui::QuickDialogActionLabel action) {
|
||||||
not_null<PeerData*> peer,
|
switch (action) {
|
||||||
Ui::QuickDialogAction action,
|
case Ui::QuickDialogActionLabel::Mute:
|
||||||
FilterId filterId) {
|
return u"swipe_mute"_q;
|
||||||
if (action == Dialogs::Ui::QuickDialogAction::Mute) {
|
case Ui::QuickDialogActionLabel::Unmute:
|
||||||
const auto history = peer->owner().history(peer);
|
return u"swipe_unmute"_q;
|
||||||
const auto isMuted = rpl::variable<bool>(
|
case Ui::QuickDialogActionLabel::Pin:
|
||||||
MuteMenu::ThreadDescriptor(history).isMutedValue()).current();
|
return u"swipe_pin"_q;
|
||||||
return isMuted ? u"swipe_unmute"_q : u"swipe_mute"_q;
|
case Ui::QuickDialogActionLabel::Unpin:
|
||||||
} else if (action == Dialogs::Ui::QuickDialogAction::Pin) {
|
return u"swipe_unpin"_q;
|
||||||
const auto history = peer->owner().history(peer);
|
case Ui::QuickDialogActionLabel::Read:
|
||||||
const auto entry = (Dialogs::Entry*)(history);
|
return u"swipe_read"_q;
|
||||||
return entry->isPinnedDialog(filterId)
|
case Ui::QuickDialogActionLabel::Unread:
|
||||||
? u"swipe_unpin"_q
|
return u"swipe_unread"_q;
|
||||||
: u"swipe_pin"_q;
|
case Ui::QuickDialogActionLabel::Archive:
|
||||||
} else if (action == Dialogs::Ui::QuickDialogAction::Read) {
|
return u"swipe_archive"_q;
|
||||||
const auto history = peer->owner().history(peer);
|
case Ui::QuickDialogActionLabel::Unarchive:
|
||||||
return Window::IsUnreadThread(history)
|
return u"swipe_unarchive"_q;
|
||||||
? u"swipe_read"_q
|
case Ui::QuickDialogActionLabel::Delete:
|
||||||
: u"swipe_unread"_q;
|
|
||||||
} else if (action == Dialogs::Ui::QuickDialogAction::Archive) {
|
|
||||||
const auto history = peer->owner().history(peer);
|
|
||||||
return Window::IsArchived(history)
|
|
||||||
? u"swipe_unarchive"_q
|
|
||||||
: u"swipe_archive"_q;
|
|
||||||
} else if (action == Dialogs::Ui::QuickDialogAction::Delete) {
|
|
||||||
return u"swipe_delete"_q;
|
return u"swipe_delete"_q;
|
||||||
|
default:
|
||||||
|
return u"swipe_disabled"_q;
|
||||||
}
|
}
|
||||||
return u"swipe_disabled"_q;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ui::QuickDialogActionLabel ResolveQuickDialogLabel(
|
Ui::QuickDialogActionLabel ResolveQuickDialogLabel(
|
||||||
|
|
|
@ -32,9 +32,7 @@ void PerformQuickDialogAction(
|
||||||
FilterId filterId);
|
FilterId filterId);
|
||||||
|
|
||||||
[[nodiscard]] QString ResolveQuickDialogLottieIconName(
|
[[nodiscard]] QString ResolveQuickDialogLottieIconName(
|
||||||
not_null<PeerData*> peer,
|
Ui::QuickDialogActionLabel action);
|
||||||
Ui::QuickDialogAction action,
|
|
||||||
FilterId filterId);
|
|
||||||
|
|
||||||
[[nodiscard]] Ui::QuickDialogActionLabel ResolveQuickDialogLabel(
|
[[nodiscard]] Ui::QuickDialogActionLabel ResolveQuickDialogLabel(
|
||||||
not_null<History*> history,
|
not_null<History*> history,
|
||||||
|
|
Loading…
Add table
Reference in a new issue