all repos — honk @ 4b0764e21d2eab5ab1bf47324bbe6a4110f0eadb

my fork of honk

add unread count for chatter
Ted Unangst tedu@tedunangst.com
Sun, 26 Dec 2021 23:19:04 -0500
commit

4b0764e21d2eab5ab1bf47324bbe6a4110f0eadb

parent

522d6cd474e9421d04b2b54b0ac035fb87ecff75

5 files changed, 51 insertions(+), 7 deletions(-)

jump to
M database.godatabase.go

@@ -596,10 +596,51 @@ break

} } err = tx.Commit() + chatplusone(ch.UserID) } else { tx.Rollback() } return err +} + +func chatplusone(userid int64) { + var user *WhatAbout + ok := somenumberedusers.Get(userid, &user) + if !ok { + return + } + options := user.Options + options.Chats += 1 + j, err := jsonify(options) + if err == nil { + db := opendatabase() + _, err = db.Exec("update users set options = ? where username = ?", j, user.Name) + } + if err != nil { + log.Printf("error plussing chat: %s", err) + } + somenamedusers.Clear(user.Name) + somenumberedusers.Clear(user.ID) +} + +func chatnewnone(userid int64) { + var user *WhatAbout + ok := somenumberedusers.Get(userid, &user) + if !ok || user.Options.Chats == 0 { + return + } + options := user.Options + options.Chats = 0 + j, err := jsonify(options) + if err == nil { + db := opendatabase() + _, err = db.Exec("update users set options = ? where username = ?", j, user.Name) + } + if err != nil { + log.Printf("error noneing chat: %s", err) + } + somenamedusers.Clear(user.Name) + somenumberedusers.Clear(user.ID) } func loadchatter(userid int64) []*Chatter {
M docs/changelog.txtdocs/changelog.txt

@@ -2,6 +2,8 @@ changelog

=== next ++ Unread count for chatter. + + More flexible hashtag characters. + Fix the memetizer to work in more environments.
M honk.gohonk.go

@@ -55,6 +55,7 @@ Avatar string `json:",omitempty"`

MapLink string `json:",omitempty"` Reaction string `json:",omitempty"` MentionAll bool + Chats int } type KeyInfo struct {
M views/header.htmlviews/header.html

@@ -17,7 +17,7 @@ <body>

<header> {{ if .UserInfo }} <details id="topmenu"> -<summary>menu<span> {{ .UserInfo.Username }}</span></summary> +<summary>menu<span> {{ .UserInfo.Name }}</span></summary> <ul> <li><a id="homelink" href="/">home</a> <li><a id="atmelink" href="/atme">@me</a>

@@ -31,7 +31,7 @@ <li><a class="combolink" href="/c/{{ . }}">{{ . }}</a>

{{ end }} </ul> </details> -<li><a href="/chatter">chatter</a> +<li><a href="/chatter">chatter{{ if .UserInfo.Options.Chats }} ({{ .UserInfo.Options.Chats }}){{ end }}</a> <li><a href="/o">tags</a> <li><a href="/events">events</a> <li><a id="longagolink" href="/longago">long ago</a>

@@ -43,7 +43,7 @@ <li style="list-style-type:none; margin-left:-1em">

<details> <summary>more stuff</summary> <ul> -<li><a href="/{{ .UserSep }}/{{ .UserInfo.Username }}">my honks</a> +<li><a href="/{{ .UserSep }}/{{ .UserInfo.Name }}">my honks</a> <li><a href="/about">about</a> <li><a href="/front">front</a> <li><a href="/funzone">funzone</a>
M web.goweb.go

@@ -75,17 +75,16 @@ return ml

} func getInfo(r *http.Request) map[string]interface{} { - u := login.GetUserInfo(r) templinfo := make(map[string]interface{}) templinfo["StyleParam"] = getassetparam(viewDir + "/views/style.css") templinfo["LocalStyleParam"] = getassetparam(dataDir + "/views/local.css") templinfo["JSParam"] = getassetparam(viewDir + "/views/honkpage.js") - templinfo["UserStyle"] = getuserstyle(u) templinfo["ServerName"] = serverName templinfo["IconName"] = iconName - templinfo["UserInfo"] = u templinfo["UserSep"] = userSep - if u != nil { + if u := login.GetUserInfo(r); u != nil { + templinfo["UserInfo"], _ = butwhatabout(u.Username) + templinfo["UserStyle"] = getuserstyle(u) var combos []string combocache.Get(u.UserID, &combos) templinfo["Combos"] = combos

@@ -1763,6 +1762,7 @@ }

func showchatter(w http.ResponseWriter, r *http.Request) { u := login.GetUserInfo(r) + chatnewnone(u.UserID) chatter := loadchatter(u.UserID) for _, chat := range chatter { for _, ch := range chat.Chonks {