summaryrefslogtreecommitdiff
path: root/pkg/backend/donate.go
blob: d21668769c782a143d106e4701c755b6f151fe70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package backend

import (
	"log"
	"time"
)

func needsDonationReminder() bool {
	return ctx.cfg.NeedsDonationReminder()
}

func donateAccepted() {
	stmut.Lock()
	defer stmut.Unlock()
	ctx.DonateDialog = false
	log.Println("marking as donated")
	ctx.cfg.SetDonated()
	go trigger(OnStatusChanged)
}

func donateRejected() {
	timer := time.NewTimer(time.Hour)
	go func() {
		<-timer.C
		showDonate()
	}()
}

func showDonate() {
	stmut.Lock()
	defer stmut.Unlock()
	ctx.DonateDialog = true
	ctx.cfg.SetLastReminded()
	go trigger(OnStatusChanged)
}