Add the Anti Dopamine feature
authorHyphen <hyphen@tfwno.gf>
Wed, 2 Sep 2020 17:50:48 +0000 (19:50 +0200)
committerr <r@freesoftwareextremist.com>
Thu, 3 Sep 2020 04:49:11 +0000 (04:49 +0000)
model/settings.go
renderer/model.go
service/service.go
service/transport.go
templates/notification.tmpl
templates/settings.tmpl
templates/status.tmpl

index fa69672ac2e0fef5b5e75452f9aa727153dc4a50..b7c77cf3d0456d56012008196c82b8873544ffd5 100644 (file)
@@ -9,6 +9,7 @@ type Settings struct {
        AutoRefreshNotifications bool   `json:"auto_refresh_notifications"`
        FluorideMode             bool   `json:"fluoride_mode"`
        DarkMode                 bool   `json:"dark_mode"`
+       AntiDopamineMode         bool   `json:"anti_dopamine_mode"`
 }
 
 func NewSettings() *Settings {
@@ -21,5 +22,6 @@ func NewSettings() *Settings {
                AutoRefreshNotifications: false,
                FluorideMode:             false,
                DarkMode:                 false,
+               AntiDopamineMode:         false,
        }
 }
index 85c73b85aa6bbd032863c46c56444e105b10b6ec..7ea8c22d1c751b9bacb1678b4306fede582de055 100644 (file)
@@ -13,6 +13,7 @@ type Context struct {
        DarkMode        bool
        CSRFToken       string
        UserID          string
+       AntiDopamineMode bool
 }
 
 type NavData struct {
index 35ce3bd28dd95579bd03b88ebd6507ff04fde723..cc59cb6e3254230099b0c04a98783567e1f79038 100644 (file)
@@ -116,6 +116,7 @@ func getRendererContext(c *model.Client) *renderer.Context {
                DarkMode:        settings.DarkMode,
                CSRFToken:       session.CSRFToken,
                UserID:          session.UserID,
+               AntiDopamineMode: settings.AntiDopamineMode,
        }
 }
 
@@ -402,13 +403,19 @@ func (svc *service) ServeNotificationPage(c *model.Client, maxID string,
        var nextLink string
        var unreadCount int
        var readID string
+       var excludes []string
        var pg = mastodon.Pagination{
                MaxID: maxID,
                MinID: minID,
                Limit: 20,
        }
 
-       notifications, err := c.GetNotifications(ctx, &pg)
+       dope := c.Session.Settings.AntiDopamineMode
+       if dope {
+               excludes = append(excludes, "follow", "favourite", "reblog")
+       }
+
+       notifications, err := c.GetNotifications(ctx, &pg, excludes...)
        if err != nil {
                return
        }
index 131c5800be9f27d0b0492fe5f55951a9409f2a8b..7d27a848e02207eb8998c66c61a2221f0afee301 100644 (file)
@@ -591,6 +591,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
                arn := req.FormValue("auto_refresh_notifications") == "true"
                fluorideMode := req.FormValue("fluoride_mode") == "true"
                darkMode := req.FormValue("dark_mode") == "true"
+               antiDopamineMode := req.FormValue("anti_dopamine_mode") == "true"
 
                settings := &model.Settings{
                        DefaultVisibility:        visibility,
@@ -601,6 +602,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
                        AutoRefreshNotifications: arn,
                        FluorideMode:             fluorideMode,
                        DarkMode:                 darkMode,
+                       AntiDopamineMode:         antiDopamineMode,
                }
 
                err := s.SaveSettings(c, settings)
index b1855a6162f0efe3aae6c3209916d00f731ba976..227bc5721b08789625f52b4d1e08d62b915cd0ce 100644 (file)
@@ -3,7 +3,9 @@
 <div class="notification-title-container">
        <div class="notification-title">
                Notifications
-               {{if gt .UnreadCount 0}}({{.UnreadCount }}){{end}}
+               {{if and (not $.Ctx.AntiDopamineMode) (gt .UnreadCount 0)}}
+                       ({{.UnreadCount }})
+               {{end}}
        </div>
        <a class="notification-refresh" href="/notifications" target="_self">refresh</a>
        {{if .ReadID}}
index d0710c3b0f4df321044a7336b25f887366c75920..ab5f03c3bac20306dc0fe49f2cd71d6006aa65dd 100644 (file)
                <input id="dark-mode" name="dark_mode" type="checkbox" value="true" {{if .Settings.DarkMode}}checked{{end}}>
                <label for="dark-mode"> Use dark theme </label>
        </div>
+       <div class="settings-form-field">
+               <input id="anti-dopamine-mode" name="anti_dopamine_mode" type="checkbox"
+               value="true" {{if .Settings.AntiDopamineMode}}checked{{end}}>
+               <label for="anti-dopamine-mode"> Remove addictive social media features </label>
+       </div>
        <button type="submit"> Save </button>
 </form>
 
index 3c0533bb37f82db9c9e4fd003b0ae0301813e907..de0909b8b0b8ca45d976914c0ab4af83d902b550 100644 (file)
                                                reply
                                        </a>
                                        <a class="status-reply-count" href="/thread/{{.ID}}#status-{{.ID}}" {{if $.Ctx.ThreadInNewTab}}target="_blank"{{end}}>
-                                               {{if .RepliesCount}} ({{DisplayInteractionCount .RepliesCount}}) {{end}}
+                                               {{if and (not $.Ctx.AntiDopamineMode) .RepliesCount}}
+                                                       ({{DisplayInteractionCount .RepliesCount}})
+                                               {{end}}
                                        </a>
                                </div>
                                <div class="status-action">
                                        {{end}}
                                        {{end}}
                                        <a class="status-retweet-count" href="/retweetedby/{{.ID}}" title="click to see the the list"> 
-                                               {{if .ReblogsCount}} ({{DisplayInteractionCount .ReblogsCount}}) {{end}}
+                                               {{if and (not $.Ctx.AntiDopamineMode) .ReblogsCount}}
+                                                       ({{DisplayInteractionCount .ReblogsCount}})
+                                               {{end}}
                                        </a>
                                </div>
                                <div class="status-action">
                                        </form>
                                        {{end}}
                                        <a class="status-like-count" href="/likedby/{{.ID}}" title="click to see the the list"> 
-                                               {{if .FavouritesCount}} ({{DisplayInteractionCount .FavouritesCount}}) {{end}}
+                                               {{if and (not $.Ctx.AntiDopamineMode) .FavouritesCount}}
+                                                       ({{DisplayInteractionCount .FavouritesCount}})
+                                               {{end}}
                                        </a>
                                </div>
                                <div class="status-action">