diff --git a/gui/backend.go b/gui/backend.go index 9453d88f860ba9b9e31e3806e181e6b9ceb3f8f4..96f50de468ce280a47c9ce3d626a1484f314e7d6 100644 --- a/gui/backend.go +++ b/gui/backend.go @@ -40,6 +40,11 @@ func DonateAccepted() { backend.DonateAccepted() } +//export DonateSeen +func DonateSeen() { + backend.DonateSeen() +} + //export SubscribeToEvent func SubscribeToEvent(event string, f unsafe.Pointer) { backend.SubscribeToEvent(event, f) diff --git a/gui/handlers.cpp b/gui/handlers.cpp index 6cafab54f69fc6fc225b7ec0e5dcd80b7bc6ea70..8f0e0d057a031012d5f194335fb84187263eb5c0 100644 --- a/gui/handlers.cpp +++ b/gui/handlers.cpp @@ -37,6 +37,11 @@ void Backend::donateAccepted() DonateAccepted(); } +void Backend::donateSeen() +{ + DonateSeen(); +} + void Backend::login(QString username, QString password) { Login(toGoStr(username), toGoStr(password)); diff --git a/gui/handlers.h b/gui/handlers.h index c342a977dcffebd03672bb017a4030aa764b2c39..8283645dcd0096eeab3a377d95c6bca44f959c71 100644 --- a/gui/handlers.h +++ b/gui/handlers.h @@ -35,6 +35,7 @@ public slots: void switchOn(); void switchOff(); void donateAccepted(); + void donateSeen(); void login(QString username, QString password); void resetError(QString errlabel); void resetNotification(QString label); diff --git a/gui/qml/main.qml b/gui/qml/main.qml index 4ac1972eac3a9141a54cb6b4c401745ad37eb2c9..aed08ea3d8d2c28e3da853394f4a80816aa809ac 100644 --- a/gui/qml/main.qml +++ b/gui/qml/main.qml @@ -21,11 +21,10 @@ ApplicationWindow { onDataChanged: { ctx = JSON.parse(jsonModel.getJson()) - // FIXME -- we need to inform the backend that we've already seen - // this. Otherwise this keeps popping randonmly on state changes. if (ctx.donateDialog == 'true') { console.debug(jsonModel.getJson()) donate.visible = true + backend.donateSeen() } if (ctx.loginDialog == 'true') { console.debug(jsonModel.getJson()) diff --git a/pkg/backend/api.go b/pkg/backend/api.go index 4390fef7c1e71adec76ea3811a5e18fea74b52ba..a799b0eb4b4d7cf341e3f297fc88c423af969da9 100644 --- a/pkg/backend/api.go +++ b/pkg/backend/api.go @@ -68,6 +68,10 @@ func DonateAccepted() { donateAccepted() } +func DonateSeen() { + donateSeen() +} + func SubscribeToEvent(event string, f unsafe.Pointer) { subscribe(event, f) } diff --git a/pkg/backend/donate.go b/pkg/backend/donate.go index f87934a9ea9c4174b4977ef42557dd4ef7716241..c16c0f4e9f91f8518630f5f19d4650a223cb42c7 100644 --- a/pkg/backend/donate.go +++ b/pkg/backend/donate.go @@ -4,12 +4,12 @@ import ( "time" ) -// runDonationReminder checks every hour if we need to show the reminder, +// runDonationReminder checks every six hours if we need to show the reminder, // and trigger the launching of the dialog if needed. func runDonationReminder() { go func() { for { - time.Sleep(time.Hour) + time.Sleep(time.Hour * 6) if needsDonationReminder() { showDonate() } @@ -21,6 +21,14 @@ func needsDonationReminder() bool { return ctx.cfg.NeedsDonationReminder() } +/* to be called from the gui, the visibility toggle will be updated on the next + status change */ +func donateSeen() { + statusMutex.Lock() + defer statusMutex.Unlock() + ctx.DonateDialog = false +} + func donateAccepted() { statusMutex.Lock() defer statusMutex.Unlock()