Luigit
repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by admin

quickshell/nuguland/test-fixtures/ui/task-services/Notifications.qml

Raw
import QtQuick

Item {
    property int unreadCount: 1
    property bool dnd: false
    property string replyDraft: ""
    property string replyError: ""
    property bool receivedKnownDraft: false
    property int editCount: 0
    property int sendCount: 0
    property int externalUpdates: 0
    property int actionCount: 0

    function notificationRow() {
        return {
            "id": "notification-fixture",
            "appName": "fixture chat",
            "appIcon": "",
            "image": "",
            "summary": externalUpdates > 0 ? "fixture message updated" : "fixture message",
            "body": "synthetic notification body",
            "time": 1,
            "urgency": "normal",
            "value": -1,
            "resident": true,
            "hasInlineReply": true,
            "inlineReplyPlaceholder": "reply to fixture",
            "actionRows": [],
            "replyDraft": replyDraft,
            "replyError": replyError
        };
    }

    function stateJson() {
        return JSON.stringify({
            "groups": [
                {
                    "id": "fixture chat",
                    "appName": "fixture chat",
                    "count": 1,
                    "previewCount": 1,
                    "expanded": false,
                    "visibleNotifications": [notificationRow()]
                }
            ],
            "dnd": dnd,
            "activeCount": 1
        });
    }

    function setReplyDraft(id, text) {
        replyDraft = String(text || "");
        receivedKnownDraft = replyDraft === "fixture-only";
        replyError = "";
        editCount++;
        return stateJson();
    }

    function sendReply(id, text) {
        replyDraft = String(text || "");
        receivedKnownDraft = replyDraft === "fixture-only";
        replyError = "reply not sent";
        sendCount++;
        return stateJson();
    }

    function runAction(id, actionId) {
        actionCount++;
        return stateJson();
    }

    function toggleGroup(appName) {
        return stateJson();
    }

    function toggleDnd() {
        dnd = !dnd;
        return stateJson();
    }

    function discardAllNotifications() {
        return stateJson();
    }

    function externalUpdate() {
        externalUpdates++;
    }
}