NotificationHistory: better display for unread notifications
This commit is contained in:
parent
4578aad0bc
commit
a2ea3c116d
3 changed files with 21 additions and 6 deletions
|
|
@ -299,6 +299,8 @@ Singleton {
|
||||||
property JsonObject notifications: JsonObject {
|
property JsonObject notifications: JsonObject {
|
||||||
property bool doNotDisturb: false
|
property bool doNotDisturb: false
|
||||||
property list<string> monitors: []
|
property list<string> monitors: []
|
||||||
|
// Last time the user opened the notification history (ms since epoch)
|
||||||
|
property double lastSeenTs: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// audio
|
// audio
|
||||||
|
|
|
||||||
|
|
@ -74,16 +74,21 @@ NIconButton {
|
||||||
z: 2
|
z: 2
|
||||||
active: userShowUnreadBadge && (!userHideWhenZero || computeUnreadCount() > 0)
|
active: userShowUnreadBadge && (!userHideWhenZero || computeUnreadCount() > 0)
|
||||||
sourceComponent: Rectangle {
|
sourceComponent: Rectangle {
|
||||||
width: 16 * scaling
|
id: badge
|
||||||
|
readonly property int count: computeUnreadCount()
|
||||||
|
readonly property string label: count <= 99 ? String(count) : "99+"
|
||||||
|
readonly property real pad: 8 * scaling
|
||||||
height: 16 * scaling
|
height: 16 * scaling
|
||||||
radius: width / 2
|
width: Math.max(height, textNode.implicitWidth + pad)
|
||||||
|
radius: height / 2
|
||||||
color: Color.mError
|
color: Color.mError
|
||||||
border.color: Color.mSurface
|
border.color: Color.mSurface
|
||||||
border.width: 1
|
border.width: 1
|
||||||
visible: computeUnreadCount() > 0 || !userHideWhenZero
|
visible: count > 0 || !userHideWhenZero
|
||||||
NText {
|
NText {
|
||||||
|
id: textNode
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
text: Math.min(computeUnreadCount(), 9)
|
text: badge.label
|
||||||
font.pointSize: Style.fontSizeXXS * scaling
|
font.pointSize: Style.fontSizeXXS * scaling
|
||||||
color: Color.mOnError
|
color: Color.mOnError
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -201,12 +201,17 @@ Singleton {
|
||||||
const items = historyAdapter.history || []
|
const items = historyAdapter.history || []
|
||||||
for (var i = 0; i < items.length; i++) {
|
for (var i = 0; i < items.length; i++) {
|
||||||
const it = items[i]
|
const it = items[i]
|
||||||
|
// Coerce legacy second-based timestamps to milliseconds
|
||||||
|
var ts = it.timestamp
|
||||||
|
if (typeof ts === "number" && ts < 1e12) {
|
||||||
|
ts = ts * 1000
|
||||||
|
}
|
||||||
historyModel.append({
|
historyModel.append({
|
||||||
"summary": it.summary || "",
|
"summary": it.summary || "",
|
||||||
"body": it.body || "",
|
"body": it.body || "",
|
||||||
"appName": it.appName || "",
|
"appName": it.appName || "",
|
||||||
"urgency": it.urgency,
|
"urgency": it.urgency,
|
||||||
"timestamp": it.timestamp ? new Date(it.timestamp) : new Date()
|
"timestamp": ts ? new Date(ts) : new Date()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
@ -225,7 +230,10 @@ Singleton {
|
||||||
"body": n.body,
|
"body": n.body,
|
||||||
"appName": n.appName,
|
"appName": n.appName,
|
||||||
"urgency": n.urgency,
|
"urgency": n.urgency,
|
||||||
"timestamp": (n.timestamp instanceof Date) ? n.timestamp.getTime() : n.timestamp
|
"timestamp"// Always persist in milliseconds
|
||||||
|
: (n.timestamp instanceof Date) ? n.timestamp.getTime(
|
||||||
|
) : (typeof n.timestamp === "number"
|
||||||
|
&& n.timestamp < 1e12 ? n.timestamp * 1000 : n.timestamp)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
historyAdapter.history = arr
|
historyAdapter.history = arr
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue