perf: consolidate notif timeStr timers into one global tick; fix osd open-on-start
This commit is contained in:
parent
9fa2a72a0b
commit
6c37b6640c
4 changed files with 28 additions and 23 deletions
|
|
@ -29,29 +29,17 @@ QtObject {
|
|||
}
|
||||
}
|
||||
|
||||
// Relative time string
|
||||
property string timeStr: "now"
|
||||
readonly property Timer _timeStrTimer: Timer {
|
||||
running: root.state !== "dismissed"
|
||||
repeat: true
|
||||
interval: 5000
|
||||
onTriggered: root._updateTimeStr()
|
||||
}
|
||||
|
||||
function _updateTimeStr() {
|
||||
const diff = Date.now() - time;
|
||||
// Relative time string — recomputed whenever NotifService._now ticks (single global 5s timer)
|
||||
readonly property string timeStr: {
|
||||
const diff = M.NotifService._now - time;
|
||||
const m = Math.floor(diff / 60000);
|
||||
if (m < 1) {
|
||||
timeStr = "now";
|
||||
return;
|
||||
}
|
||||
if (m < 1)
|
||||
return "now";
|
||||
const h = Math.floor(m / 60);
|
||||
if (h < 1) {
|
||||
timeStr = m + "m";
|
||||
return;
|
||||
}
|
||||
if (h < 1)
|
||||
return m + "m";
|
||||
const d = Math.floor(h / 24);
|
||||
timeStr = d > 0 ? d + "d" : h + "h";
|
||||
return d > 0 ? d + "d" : h + "h";
|
||||
}
|
||||
|
||||
function beginDismiss() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue