From 2f1f352342e8e707beabd8d0c180887182e28c9a Mon Sep 17 00:00:00 2001 From: "kali kaneko (leap communications)" <kali@leap.se> Date: Thu, 20 Aug 2020 20:22:48 +0200 Subject: [PATCH] [feat] reset notification --- gui/backend.go | 5 +++++ gui/handlers.cpp | 5 +++++ gui/handlers.h | 1 + gui/qml/LoginOKDialog.qml | 3 ++- gui/qml/main.qml | 2 +- pkg/backend/api.go | 16 ++++++++++++++-- pkg/backend/init.go | 7 ------- 7 files changed, 28 insertions(+), 11 deletions(-) diff --git a/gui/backend.go b/gui/backend.go index c953d182..5fa6134a 100644 --- a/gui/backend.go +++ b/gui/backend.go @@ -81,6 +81,11 @@ func ResetError(errname string) { backend.ResetError(errname) } +//export ResetNotification +func ResetNotification(label string) { + backend.ResetNotification(label) +} + //export InstallHelpers func InstallHelpers() { backend.InstallHelpers() diff --git a/gui/handlers.cpp b/gui/handlers.cpp index f34133e2..71e5d38b 100644 --- a/gui/handlers.cpp +++ b/gui/handlers.cpp @@ -52,6 +52,11 @@ void Backend::resetError(QString errlabel) ResetError(toGoStr(errlabel)); } +void Backend::resetNotification(QString label) +{ + ResetNotification(toGoStr(label)); +} + void Backend::quit() { Quit(); diff --git a/gui/handlers.h b/gui/handlers.h index 9299827f..e3d0e2a9 100644 --- a/gui/handlers.h +++ b/gui/handlers.h @@ -40,6 +40,7 @@ public slots: void donateAccepted(); void login(QString username, QString password); void resetError(QString errlabel); + void resetNotification(QString label); void quit(); }; diff --git a/gui/qml/LoginOKDialog.qml b/gui/qml/LoginOKDialog.qml index be023dd9..bceda186 100644 --- a/gui/qml/LoginOKDialog.qml +++ b/gui/qml/LoginOKDialog.qml @@ -13,7 +13,8 @@ Dialog { } function _loginOk() { - backend.resetError("bad_auth") + visible: false; + backend.resetNotification("login_ok"); } visible: false diff --git a/gui/qml/main.qml b/gui/qml/main.qml index fe69a3bc..9f8bea3f 100644 --- a/gui/qml/main.qml +++ b/gui/qml/main.qml @@ -16,12 +16,12 @@ ApplicationWindow { target: jsonModel onDataChanged: { ctx = JSON.parse(jsonModel.getJson()); + if (ctx.donateDialog == 'true') { console.debug(jsonModel.getJson()) donate.visible = true } if (ctx.loginDialog == 'true') { - console.debug(jsonModel.getJson()) login.visible = true } if (ctx.loginOk == 'true') { diff --git a/pkg/backend/api.go b/pkg/backend/api.go index 7aa55279..125f7f58 100644 --- a/pkg/backend/api.go +++ b/pkg/backend/api.go @@ -86,8 +86,20 @@ func RefreshContext() *C.char { } func ResetError(errname string) { - log.Println("DEBUG: resetting error", errname) - resetErrors(errname) + if ctx.Errors == errname { + ctx.Errors = "" + } +} + +func ResetNotification(label string) { + switch label { + case "login_ok": + ctx.LoginOk = false + break + default: + break + } + go trigger(OnStatusChanged) } func InstallHelpers() { diff --git a/pkg/backend/init.go b/pkg/backend/init.go index af43bab4..be4427af 100644 --- a/pkg/backend/init.go +++ b/pkg/backend/init.go @@ -40,13 +40,6 @@ func checkErrors(errCh chan string) { } } -func resetErrors(errname string) { - if ctx.Errors == errname { - ctx.Errors = "" - log.Println("DEBUG: reset error", errname) - } -} - func initializeBitmask(errCh chan string, opts *InitOpts) { if ctx == nil { log.Println("bug: cannot initialize bitmask, ctx is nil!") -- GitLab