Compare commits
No commits in common. "29a24b42057fdf69bb1be3ffb769bf773059b78f" and "427aeb438ccad5d843f2d27202aca58ee8b9db8b" have entirely different histories.
29a24b4205
...
427aeb438c
2 changed files with 15 additions and 15 deletions
|
|
@ -133,7 +133,7 @@ M.PopupPanel {
|
||||||
|
|
||||||
// Notification list
|
// Notification list
|
||||||
Repeater {
|
Repeater {
|
||||||
model: M.NotifService.list.slice(0, 20)
|
model: M.NotifService.active.slice(0, 20)
|
||||||
|
|
||||||
delegate: Item {
|
delegate: Item {
|
||||||
id: notifItem
|
id: notifItem
|
||||||
|
|
|
||||||
|
|
@ -12,23 +12,26 @@ QtObject {
|
||||||
property var list: []
|
property var list: []
|
||||||
property bool dnd: false
|
property bool dnd: false
|
||||||
|
|
||||||
readonly property var popups: list.filter(n => n.popup)
|
readonly property var active: list.filter(n => !n.closed)
|
||||||
readonly property int count: list.length
|
readonly property var popups: list.filter(n => n.popup && !n.closed)
|
||||||
|
readonly property int count: active.length
|
||||||
|
|
||||||
function dismiss(notifId) {
|
function dismiss(notifId) {
|
||||||
const idx = list.findIndex(n => n.id === notifId);
|
const n = list.find(n => n.id === notifId);
|
||||||
if (idx >= 0) {
|
if (n) {
|
||||||
const n = list[idx];
|
n.popup = false;
|
||||||
|
n.closed = true;
|
||||||
n.notification?.dismiss();
|
n.notification?.dismiss();
|
||||||
list.splice(idx, 1);
|
|
||||||
_changed();
|
_changed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function dismissAll() {
|
function dismissAll() {
|
||||||
for (const n of list.slice())
|
for (const n of list.slice()) {
|
||||||
|
n.popup = false;
|
||||||
|
n.closed = true;
|
||||||
n.notification?.dismiss();
|
n.notification?.dismiss();
|
||||||
list = [];
|
}
|
||||||
_changed();
|
_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -82,7 +85,7 @@ QtObject {
|
||||||
|
|
||||||
// Dismiss excess popups (keep in history, just hide popup)
|
// Dismiss excess popups (keep in history, just hide popup)
|
||||||
const max = M.Modules.notifications.maxPopups || 4;
|
const max = M.Modules.notifications.maxPopups || 4;
|
||||||
const currentPopups = root.list.filter(n => n.popup);
|
const currentPopups = root.list.filter(n => n.popup && !n.closed);
|
||||||
if (currentPopups.length > max) {
|
if (currentPopups.length > max) {
|
||||||
for (let i = max; i < currentPopups.length; i++)
|
for (let i = max; i < currentPopups.length; i++)
|
||||||
currentPopups[i].popup = false;
|
currentPopups[i].popup = false;
|
||||||
|
|
@ -120,7 +123,7 @@ QtObject {
|
||||||
property Timer _saveTimer: Timer {
|
property Timer _saveTimer: Timer {
|
||||||
interval: 1000
|
interval: 1000
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
const data = root.list.map(n => ({
|
const data = root.active.map(n => ({
|
||||||
id: n.id,
|
id: n.id,
|
||||||
summary: n.summary,
|
summary: n.summary,
|
||||||
body: n.body,
|
body: n.body,
|
||||||
|
|
@ -139,10 +142,7 @@ QtObject {
|
||||||
onLoaded: {
|
onLoaded: {
|
||||||
try {
|
try {
|
||||||
const data = JSON.parse(text());
|
const data = JSON.parse(text());
|
||||||
for (let i = 0; i < data.length; i++) {
|
for (const n of data) {
|
||||||
const n = data[i];
|
|
||||||
// Prefix persisted IDs to avoid collision with live D-Bus IDs
|
|
||||||
n.id = "p_" + (n.id ?? i) + "_" + n.time;
|
|
||||||
n.popup = false;
|
n.popup = false;
|
||||||
n.closed = false;
|
n.closed = false;
|
||||||
n.notification = null;
|
n.notification = null;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue