diff --git a/database.go b/database.go
index 946d2db..a78d36f 100644
--- a/database.go
+++ b/database.go
@@ -595,26 +595,25 @@ func savechonk(ch *Chonk) error {
break
}
}
+ chatplusone(tx, ch.UserID)
err = tx.Commit()
- chatplusone(ch.UserID)
} else {
tx.Rollback()
}
return err
}
-func chatplusone(userid int64) {
+func chatplusone(tx *sql.Tx, userid int64) {
var user *WhatAbout
ok := somenumberedusers.Get(userid, &user)
if !ok {
return
}
options := user.Options
- options.Chats += 1
+ options.ChatCount += 1
j, err := jsonify(options)
if err == nil {
- db := opendatabase()
- _, err = db.Exec("update users set options = ? where username = ?", j, user.Name)
+ _, err = tx.Exec("update users set options = ? where username = ?", j, user.Name)
}
if err != nil {
log.Printf("error plussing chat: %s", err)
@@ -626,11 +625,11 @@ func chatplusone(userid int64) {
func chatnewnone(userid int64) {
var user *WhatAbout
ok := somenumberedusers.Get(userid, &user)
- if !ok || user.Options.Chats == 0 {
+ if !ok || user.Options.ChatCount == 0 {
return
}
options := user.Options
- options.Chats = 0
+ options.ChatCount = 0
j, err := jsonify(options)
if err == nil {
db := opendatabase()
@@ -643,6 +642,45 @@ func chatnewnone(userid int64) {
somenumberedusers.Clear(user.ID)
}
+func meplusone(tx *sql.Tx, userid int64) {
+ var user *WhatAbout
+ ok := somenumberedusers.Get(userid, &user)
+ if !ok {
+ return
+ }
+ options := user.Options
+ options.MeCount += 1
+ j, err := jsonify(options)
+ if err == nil {
+ _, err = tx.Exec("update users set options = ? where username = ?", j, user.Name)
+ }
+ if err != nil {
+ log.Printf("error plussing me: %s", err)
+ }
+ somenamedusers.Clear(user.Name)
+ somenumberedusers.Clear(user.ID)
+}
+
+func menewnone(userid int64) {
+ var user *WhatAbout
+ ok := somenumberedusers.Get(userid, &user)
+ if !ok || user.Options.MeCount == 0 {
+ return
+ }
+ options := user.Options
+ options.MeCount = 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 me: %s", err)
+ }
+ somenamedusers.Clear(user.Name)
+ somenumberedusers.Clear(user.ID)
+}
+
func loadchatter(userid int64) []*Chatter {
duedt := time.Now().Add(-3 * 24 * time.Hour).UTC().Format(dbtimeformat)
rows, err := stmtLoadChonks.Query(userid, duedt)
@@ -724,6 +762,9 @@ func savehonk(h *Honk) error {
err = saveextras(tx, h)
}
if err == nil {
+ if h.Whofore == 1 {
+ meplusone(tx, h.UserID)
+ }
err = tx.Commit()
} else {
tx.Rollback()
diff --git a/docs/changelog.txt b/docs/changelog.txt
index bb15a7d..22cf27d 100644
--- a/docs/changelog.txt
+++ b/docs/changelog.txt
@@ -2,9 +2,9 @@ changelog
=== next
-+ Images in the hooter.
++ Low key unread counters.
-+ Unread count for chatter.
++ Images in the hooter.
+ More flexible hashtag characters.
diff --git a/honk.go b/honk.go
index 929be9b..d2e4140 100644
--- a/honk.go
+++ b/honk.go
@@ -56,7 +56,8 @@ type UserOptions struct {
Avatar string `json:",omitempty"`
MapLink string `json:",omitempty"`
Reaction string `json:",omitempty"`
- Chats int
+ MeCount int64
+ ChatCount int64
}
type KeyInfo struct {
diff --git a/views/header.html b/views/header.html
index 4a85753..d88fc57 100644
--- a/views/header.html
+++ b/views/header.html
@@ -20,7 +20,7 @@