mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-10-28 14:07:47 -04:00
notifications: refresh relative times on the lock screen, in NotificationsTab and in history (#3965)
port 2.0
(cherry picked from commit 3d4ea22e73)
This commit is contained in:
1 parent
7ed525a679
commit
0acaaa4b44
3 files changed
+21
-7
No files matched your search
@@ -94,6 +94,11 @@ FocusScope {
|
||||
LayoutMirroring.enabled: I18n.isRtl
|
||||
LayoutMirroring.childrenInherit: true
|
||||
|
||||
Ref {
|
||||
service: NotificationService
|
||||
active: root.live
|
||||
}
|
||||
|
||||
onLiveChanged: {
|
||||
if (!live) {
|
||||
keyboard.reset();
|
||||
|
||||
@@ -38,7 +38,7 @@ Notifications.NotificationCard {
|
||||
onDismissRequested: NotificationService.removeFromHistory(historyItem.id)
|
||||
|
||||
function formatHistoryTime(timestamp) {
|
||||
NotificationService.timeUpdateTick;
|
||||
NotificationService.relativeTimeNow;
|
||||
NotificationService.clockFormatChanged;
|
||||
const now = new Date();
|
||||
const date = new Date(timestamp);
|
||||
|
||||
@@ -610,12 +610,22 @@ Singleton {
|
||||
SystemClock {
|
||||
id: minuteClock
|
||||
precision: SystemClock.Minutes
|
||||
enabled: root.overlayOpen || SettingsData.hasTimedNotificationRules
|
||||
enabled: root.relativeTimesShown || SettingsData.hasTimedNotificationRules
|
||||
}
|
||||
|
||||
// Current time in ms for rule-expiry bindings. Reads 0 while the clock is
|
||||
// off, which is safe: the clock is off exactly when no rule carries an
|
||||
// expiry, so no binding can depend on the value moving.
|
||||
// Views that show relative times without calling onOverlayOpen(), such
|
||||
// as NotificationsTab, hold a Ref while visible.
|
||||
property int refCount: 0
|
||||
|
||||
readonly property bool relativeTimesShown: overlayOpen || IdleService.isShellLocked || refCount > 0
|
||||
|
||||
// Relative-time bindings read this to refresh every minute while
|
||||
// relativeTimesShown. It stays null otherwise, so clock ticks for timed
|
||||
// rules do not re-evaluate them.
|
||||
readonly property var relativeTimeNow: relativeTimesShown ? minuteClock.date : null
|
||||
|
||||
// Current time in ms for rule-expiry bindings. Reads 0 while no rule
|
||||
// carries an expiry, so no binding can depend on the value moving.
|
||||
readonly property double notificationRuleNowMs: SettingsData.hasTimedNotificationRules ? minuteClock.date.getTime() : 0
|
||||
|
||||
// Formatted remaining time for a rule's expiresAt, driven by the ticking
|
||||
@@ -915,8 +925,7 @@ Singleton {
|
||||
|
||||
readonly property date time: new Date()
|
||||
readonly property string timeStr: {
|
||||
if (root.overlayOpen)
|
||||
minuteClock.date;
|
||||
root.relativeTimeNow;
|
||||
root.clockFormatChanged;
|
||||
|
||||
const now = new Date();
|
||||
|
||||
Reference in new issue
Block a user