mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 22:54:01 +02:00
Added remain time to notification menu item when peer is muted.
This commit is contained in:
parent
d7bf9e285c
commit
93563358ca
3 changed files with 22 additions and 1 deletions
|
@ -396,4 +396,18 @@ QString FormatTTLTiny(float64 ttl) {
|
|||
: tr::lng_years_tiny({}, lt_count, std::ceil(ttl / (86400 * 360)));
|
||||
}
|
||||
|
||||
QString FormatMuteForTiny(float64 sec) {
|
||||
return (sec <= 60)
|
||||
? QString()
|
||||
: (sec <= 60 * 59)
|
||||
? tr::lng_minutes_tiny(tr::now, lt_count, std::ceil(sec / 60))
|
||||
: (sec <= 3600 * 23)
|
||||
? tr::lng_hours_tiny(tr::now, lt_count, std::ceil(sec / 3600))
|
||||
: (sec <= 86400 * 6)
|
||||
? tr::lng_days_tiny(tr::now, lt_count, std::ceil(sec / 86400))
|
||||
: (sec <= (86400 * 7) * 3)
|
||||
? tr::lng_weeks_tiny(tr::now, lt_count, std::ceil(sec / (86400 * 7)))
|
||||
: QString();
|
||||
}
|
||||
|
||||
} // namespace Ui
|
||||
|
|
|
@ -28,6 +28,7 @@ inline constexpr auto FileStatusSizeFailed = 0x7FFFFFF2;
|
|||
[[nodiscard]] QString FormatImageSizeText(const QSize &size);
|
||||
[[nodiscard]] QString FormatPhone(const QString &phone);
|
||||
[[nodiscard]] QString FormatTTLTiny(float64 ttl);
|
||||
[[nodiscard]] QString FormatMuteForTiny(float64 sec);
|
||||
|
||||
struct CurrencyRule {
|
||||
const char *international = "";
|
||||
|
|
|
@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "lang/lang_keys.h"
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
#include "base/options.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "boxes/delete_messages_box.h"
|
||||
#include "boxes/max_invite_box.h"
|
||||
#include "boxes/mute_settings_box.h"
|
||||
|
@ -22,6 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "boxes/peers/edit_contact_box.h"
|
||||
#include "ui/boxes/report_box.h"
|
||||
#include "ui/toast/toast.h"
|
||||
#include "ui/text/format_values.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
#include "ui/widgets/checkbox.h"
|
||||
|
@ -131,7 +133,11 @@ void PeerMenuAddMuteSubmenuAction(
|
|||
peer->owner().requestNotifySettings(peer);
|
||||
const auto isMuted = peer->owner().notifyIsMuted(peer);
|
||||
if (isMuted) {
|
||||
addAction(tr::lng_mute_menu_unmute(tr::now), [=] {
|
||||
const auto text = tr::lng_mute_menu_unmute(tr::now)
|
||||
+ '\t'
|
||||
+ Ui::FormatMuteForTiny(peer->notifyMuteUntil().value_or(0)
|
||||
- base::unixtime::now());
|
||||
addAction(text, [=] {
|
||||
peer->owner().updateNotifySettings(peer, 0);
|
||||
}, &st::menuIconUnmute);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue