aboutsummaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorr <r@freesoftwareextremist.com>2020-11-14 14:08:16 +0000
committerr <r@freesoftwareextremist.com>2020-11-14 14:22:34 +0000
commitc3d90539e9a7addd3c41f44b864b14bde60958dc (patch)
treecc8efc18befd999db4985ef75fc4f42e99da9f78 /service
parent856fe9e8c74e7c8096f7fb04d7b0932171223752 (diff)
downloadbloat-c3d90539e9a7addd3c41f44b864b14bde60958dc.tar.gz
bloat-c3d90539e9a7addd3c41f44b864b14bde60958dc.zip
Add notification interval setting
It replaces the "Auto refresh notifications" checkbox
Diffstat (limited to 'service')
-rw-r--r--service/service.go7
-rw-r--r--service/transport.go22
2 files changed, 17 insertions, 12 deletions
diff --git a/service/service.go b/service/service.go
index 48aafda..1ba99da 100644
--- a/service/service.go
+++ b/service/service.go
@@ -434,7 +434,7 @@ func (svc *service) ServeNotificationPage(c *model.Client, maxID string,
}
commonData := svc.getCommonData(c, "notifications")
- commonData.AutoRefresh = c.Session.Settings.AutoRefreshNotifications
+ commonData.RefreshInterval = c.Session.Settings.NotificationInterval
commonData.Target = "main"
commonData.Count = unreadCount
data := &renderer.NotificationData{
@@ -932,6 +932,11 @@ func (svc *service) UnSubscribe(c *model.Client, id string) (err error) {
}
func (svc *service) SaveSettings(c *model.Client, s *model.Settings) (err error) {
+ switch s.NotificationInterval {
+ case 0, 30, 60, 120, 300, 600:
+ default:
+ return errInvalidArgument
+ }
session, err := svc.sessionRepo.Get(c.Session.ID)
if err != nil {
return
diff --git a/service/transport.go b/service/transport.go
index 6c0975d..3c9392a 100644
--- a/service/transport.go
+++ b/service/transport.go
@@ -589,22 +589,22 @@ func NewHandler(s Service, staticDir string) http.Handler {
threadInNewTab := req.FormValue("thread_in_new_tab") == "true"
hideAttachments := req.FormValue("hide_attachments") == "true"
maskNSFW := req.FormValue("mask_nsfw") == "true"
- arn := req.FormValue("auto_refresh_notifications") == "true"
+ ni, _ := strconv.Atoi(req.FormValue("notification_interval"))
fluorideMode := req.FormValue("fluoride_mode") == "true"
darkMode := req.FormValue("dark_mode") == "true"
antiDopamineMode := req.FormValue("anti_dopamine_mode") == "true"
settings := &model.Settings{
- DefaultVisibility: visibility,
- DefaultFormat: format,
- CopyScope: copyScope,
- ThreadInNewTab: threadInNewTab,
- HideAttachments: hideAttachments,
- MaskNSFW: maskNSFW,
- AutoRefreshNotifications: arn,
- FluorideMode: fluorideMode,
- DarkMode: darkMode,
- AntiDopamineMode: antiDopamineMode,
+ DefaultVisibility: visibility,
+ DefaultFormat: format,
+ CopyScope: copyScope,
+ ThreadInNewTab: threadInNewTab,
+ HideAttachments: hideAttachments,
+ MaskNSFW: maskNSFW,
+ NotificationInterval: ni,
+ FluorideMode: fluorideMode,
+ DarkMode: darkMode,
+ AntiDopamineMode: antiDopamineMode,
}
err := s.SaveSettings(c, settings)