# shellcheck shell=bash
xrc:mod:lib     gt      notification/ls         \
                        notification/ll         \
                        notification/info       \
                        notification/mark

___x_cmd_gt_notification(){
    param:subcmd ___x_cmd_gt_notification                                   \
        ls                  "Interactive UI show users's notification"      \
        ll                  "List users's notification threads"             \
        info                "Get notification thread by ID"                 \
        mark                "Mark notification as read by ID"

    param:subcmd:try
    param:run


    ___x_cmd_gt_notification _param_help_doc
    return 1
}

___x_cmd_gt_notification____ui_handler(){
    if [ -n "$ENFORCE_JSON" ] || [ -n "$json" ]; then
        ___x_cmd_cmds_cat
        ___x_cmd_gt_http_error
        return
    fi

    (
        local id=; local full_name=; local unread=; local title=; local url=
        case "$1" in
            Info)
                ___x_cmd jo env . id=.id Repo=.repository.full_name unread=.unread title=.content url=.subject.url
                msg="Successfully get notification info."
                error_msg="Get notification info failure."

                if [ -n "$id" ]; then
                    ___x_cmd_ui_tf true "$msg" "number: $id" ${Repo+"Repo: $Repo"} ${unread+"Unread: $unread"}  ${title+"Title: $title"} ${url+"Url: $url"}
                else
                    ___x_cmd_ui_tf false "$error_msg" >&2
                    ___x_cmd_gt____handle_resp
                    return 1
                fi
                ;;
        esac


    )
}
