mirror of
https://gitea.phreedom.club/localhost_frssoft/bloat.git
synced 2024-11-23 07:23:00 +00:00
Add notification interval setting
It replaces the "Auto refresh notifications" checkbox
This commit is contained in:
parent
856fe9e8c7
commit
c3d90539e9
@ -1,29 +1,29 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
type Settings struct {
|
type Settings struct {
|
||||||
DefaultVisibility string `json:"default_visibility"`
|
DefaultVisibility string `json:"default_visibility"`
|
||||||
DefaultFormat string `json:"default_format"`
|
DefaultFormat string `json:"default_format"`
|
||||||
CopyScope bool `json:"copy_scope"`
|
CopyScope bool `json:"copy_scope"`
|
||||||
ThreadInNewTab bool `json:"thread_in_new_tab"`
|
ThreadInNewTab bool `json:"thread_in_new_tab"`
|
||||||
HideAttachments bool `json:"hide_attachments"`
|
HideAttachments bool `json:"hide_attachments"`
|
||||||
MaskNSFW bool `json:"mask_nfsw"`
|
MaskNSFW bool `json:"mask_nfsw"`
|
||||||
AutoRefreshNotifications bool `json:"auto_refresh_notifications"`
|
NotificationInterval int `json:"notifications_interval"`
|
||||||
FluorideMode bool `json:"fluoride_mode"`
|
FluorideMode bool `json:"fluoride_mode"`
|
||||||
DarkMode bool `json:"dark_mode"`
|
DarkMode bool `json:"dark_mode"`
|
||||||
AntiDopamineMode bool `json:"anti_dopamine_mode"`
|
AntiDopamineMode bool `json:"anti_dopamine_mode"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSettings() *Settings {
|
func NewSettings() *Settings {
|
||||||
return &Settings{
|
return &Settings{
|
||||||
DefaultVisibility: "public",
|
DefaultVisibility: "public",
|
||||||
DefaultFormat: "",
|
DefaultFormat: "",
|
||||||
CopyScope: true,
|
CopyScope: true,
|
||||||
ThreadInNewTab: false,
|
ThreadInNewTab: false,
|
||||||
HideAttachments: false,
|
HideAttachments: false,
|
||||||
MaskNSFW: true,
|
MaskNSFW: true,
|
||||||
AutoRefreshNotifications: false,
|
NotificationInterval: 0,
|
||||||
FluorideMode: false,
|
FluorideMode: false,
|
||||||
DarkMode: false,
|
DarkMode: false,
|
||||||
AntiDopamineMode: false,
|
AntiDopamineMode: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,12 +23,12 @@ type NavData struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CommonData struct {
|
type CommonData struct {
|
||||||
Title string
|
Title string
|
||||||
CustomCSS string
|
CustomCSS string
|
||||||
CSRFToken string
|
CSRFToken string
|
||||||
Count int
|
Count int
|
||||||
AutoRefresh bool
|
RefreshInterval int
|
||||||
Target string
|
Target string
|
||||||
}
|
}
|
||||||
|
|
||||||
type ErrorData struct {
|
type ErrorData struct {
|
||||||
|
@ -434,7 +434,7 @@ func (svc *service) ServeNotificationPage(c *model.Client, maxID string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
commonData := svc.getCommonData(c, "notifications")
|
commonData := svc.getCommonData(c, "notifications")
|
||||||
commonData.AutoRefresh = c.Session.Settings.AutoRefreshNotifications
|
commonData.RefreshInterval = c.Session.Settings.NotificationInterval
|
||||||
commonData.Target = "main"
|
commonData.Target = "main"
|
||||||
commonData.Count = unreadCount
|
commonData.Count = unreadCount
|
||||||
data := &renderer.NotificationData{
|
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) {
|
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)
|
session, err := svc.sessionRepo.Get(c.Session.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
@ -589,22 +589,22 @@ func NewHandler(s Service, staticDir string) http.Handler {
|
|||||||
threadInNewTab := req.FormValue("thread_in_new_tab") == "true"
|
threadInNewTab := req.FormValue("thread_in_new_tab") == "true"
|
||||||
hideAttachments := req.FormValue("hide_attachments") == "true"
|
hideAttachments := req.FormValue("hide_attachments") == "true"
|
||||||
maskNSFW := req.FormValue("mask_nsfw") == "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"
|
fluorideMode := req.FormValue("fluoride_mode") == "true"
|
||||||
darkMode := req.FormValue("dark_mode") == "true"
|
darkMode := req.FormValue("dark_mode") == "true"
|
||||||
antiDopamineMode := req.FormValue("anti_dopamine_mode") == "true"
|
antiDopamineMode := req.FormValue("anti_dopamine_mode") == "true"
|
||||||
|
|
||||||
settings := &model.Settings{
|
settings := &model.Settings{
|
||||||
DefaultVisibility: visibility,
|
DefaultVisibility: visibility,
|
||||||
DefaultFormat: format,
|
DefaultFormat: format,
|
||||||
CopyScope: copyScope,
|
CopyScope: copyScope,
|
||||||
ThreadInNewTab: threadInNewTab,
|
ThreadInNewTab: threadInNewTab,
|
||||||
HideAttachments: hideAttachments,
|
HideAttachments: hideAttachments,
|
||||||
MaskNSFW: maskNSFW,
|
MaskNSFW: maskNSFW,
|
||||||
AutoRefreshNotifications: arn,
|
NotificationInterval: ni,
|
||||||
FluorideMode: fluorideMode,
|
FluorideMode: fluorideMode,
|
||||||
DarkMode: darkMode,
|
DarkMode: darkMode,
|
||||||
AntiDopamineMode: antiDopamineMode,
|
AntiDopamineMode: antiDopamineMode,
|
||||||
}
|
}
|
||||||
|
|
||||||
err := s.SaveSettings(c, settings)
|
err := s.SaveSettings(c, settings)
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
{{if $.Ctx.AntiDopamineMode}}
|
{{if $.Ctx.AntiDopamineMode}}
|
||||||
<meta name="antidopamine_mode" content="{{$.Ctx.AntiDopamineMode}}">
|
<meta name="antidopamine_mode" content="{{$.Ctx.AntiDopamineMode}}">
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if .AutoRefresh}}
|
{{if .RefreshInterval}}
|
||||||
<meta http-equiv="refresh" content="30">
|
<meta http-equiv="refresh" content="{{.RefreshInterval}}">
|
||||||
{{end}}
|
{{end}}
|
||||||
<title> {{if gt .Count 0}}({{.Count}}){{end}} {{.Title}} </title>
|
<title> {{if gt .Count 0}}({{.Count}}){{end}} {{.Title}} </title>
|
||||||
<link rel="stylesheet" href="/static/style.css">
|
<link rel="stylesheet" href="/static/style.css">
|
||||||
|
@ -22,6 +22,17 @@
|
|||||||
<option value="direct" {{if eq .Settings.DefaultVisibility "direct"}}selected{{end}}>Direct</option>
|
<option value="direct" {{if eq .Settings.DefaultVisibility "direct"}}selected{{end}}>Direct</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="settings-form-field">
|
||||||
|
<label for="notification-interval"> Refresh Notifications </label>
|
||||||
|
<select id="notification-interval" name="notification_interval">
|
||||||
|
<option value="0" {{if eq .Settings.NotificationInterval 0}}selected{{end}}>Disabled</option>
|
||||||
|
<option value="30" {{if eq .Settings.NotificationInterval 30}}selected{{end}}>After 30s</option>
|
||||||
|
<option value="60" {{if eq .Settings.NotificationInterval 60}}selected{{end}}>After 1m</option>
|
||||||
|
<option value="120" {{if eq .Settings.NotificationInterval 120}}selected{{end}}>After 2m</option>
|
||||||
|
<option value="300" {{if eq .Settings.NotificationInterval 300}}selected{{end}}>After 5m</option>
|
||||||
|
<option value="600" {{if eq .Settings.NotificationInterval 600}}selected{{end}}>After 10m</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
<div class="settings-form-field">
|
<div class="settings-form-field">
|
||||||
<input id="copy-scope" name="copy_scope" type="checkbox" value="true" {{if .Settings.CopyScope}}checked{{end}}>
|
<input id="copy-scope" name="copy_scope" type="checkbox" value="true" {{if .Settings.CopyScope}}checked{{end}}>
|
||||||
<label for="copy-scope"> Copy scope when replying </label>
|
<label for="copy-scope"> Copy scope when replying </label>
|
||||||
@ -38,10 +49,6 @@
|
|||||||
<input id="mask-nsfw" name="mask_nsfw" type="checkbox" value="true" {{if .Settings.MaskNSFW}}checked{{end}}>
|
<input id="mask-nsfw" name="mask_nsfw" type="checkbox" value="true" {{if .Settings.MaskNSFW}}checked{{end}}>
|
||||||
<label for="mask-nsfw"> Mask NSFW attachments </label>
|
<label for="mask-nsfw"> Mask NSFW attachments </label>
|
||||||
</div>
|
</div>
|
||||||
<div class="settings-form-field">
|
|
||||||
<input id="auto-refresh-notifications" name="auto_refresh_notifications" type="checkbox" value="true" {{if .Settings.AutoRefreshNotifications}}checked{{end}}>
|
|
||||||
<label for="auto-refresh-notifications"> Auto refresh notifications </label>
|
|
||||||
</div>
|
|
||||||
<div class="settings-form-field">
|
<div class="settings-form-field">
|
||||||
<input id="fluoride-mode" name="fluoride_mode" type="checkbox" value="true" {{if .Settings.FluorideMode}}checked{{end}}>
|
<input id="fluoride-mode" name="fluoride_mode" type="checkbox" value="true" {{if .Settings.FluorideMode}}checked{{end}}>
|
||||||
<label for="fluoride-mode"> Enable <abbr title="Enable JavaScript based functionality, e.g., like/retweet without page reload and reply preview on thread page">fluoride mode</abbr> </label>
|
<label for="fluoride-mode"> Enable <abbr title="Enable JavaScript based functionality, e.g., like/retweet without page reload and reply preview on thread page">fluoride mode</abbr> </label>
|
||||||
|
Loading…
Reference in New Issue
Block a user