diff --git a/database/conference.go b/database/conference.go
index 07a9161..3ee8056 100644
--- a/database/conference.go
+++ b/database/conference.go
@@ -302,6 +302,16 @@ func (c *Conference) TouchPost(ctx context.Context, tx *sqlx.Tx, u *User, lastPo
return cs, nil
}
+// UnreadMessages returns the total number of unread messages in a conference for a user.
+func (c *Conference) UnreadMessages(ctx context.Context, u *User) (int32, error) {
+ row := amdb.QueryRowContext(ctx, `SELECT SUM(t.top_message - IFNULL(s.last_message,-1))
+ FROM topics t LEFT JOIN topicsettings s ON t.topicid = s.topicid AND s.uid = ?
+ WHERE t.confid = ? AND t.archived = 0 AND (s.hidden IS NULL OR s.hidden = 0)`, u.Uid, c.ConfId)
+ var rc int32
+ err := row.Scan(&rc)
+ return rc, err
+}
+
/* AmGetConference returns a conference given its ID.
* Parameters:
* ctx - Standard Go context value.
diff --git a/docs/MISSINGFUNCS.md b/docs/MISSINGFUNCS.md
index d7fdf2a..e42d904 100644
--- a/docs/MISSINGFUNCS.md
+++ b/docs/MISSINGFUNCS.md
@@ -42,7 +42,7 @@
- Post Publish
- Manage Communities on communities sidebox
- ~~Conference Hotlist sidebox~~
-- "New" flag on Conference Hotlist sidebox
+- ~~"New" flag on Conference Hotlist sidebox~~
- Manage on Conference Hotlist sidebox
- Sidebox configuration
- Topics view:
diff --git a/top.go b/top.go
index 36ce6aa..8bf4823 100644
--- a/top.go
+++ b/top.go
@@ -133,13 +133,20 @@ func buildFeaturedConferences(ctxt ui.AmContext, uid int32, out *RenderedSidebox
lk := fmt.Sprintf("/comm/%s/conf/%s", comm.Alias, alias[0])
out.Items[i].Link = &lk
out.Items[i].Flags = make(map[string]bool)
- // TODO: add "New" indicator
+ out.Items[i].Flags["new"] = false
+ if !user.IsAnon {
+ nnew, err := conf.UnreadMessages(ctxt.Ctx(), user)
+ if err == nil {
+ out.Items[i].Flags["new"] = (nnew > 0)
+ }
+ }
}
out.Flags = make(map[string]bool)
out.Flags["canManage"] = !(user.IsAnon)
out.TemplateName = "sb_ftrconf.jet"
}
}
+ _ = in
return err
}
diff --git a/ui/views/sb_ftrconf.jet b/ui/views/sb_ftrconf.jet
index 02b1b4b..e325606 100644
--- a/ui/views/sb_ftrconf.jet
+++ b/ui/views/sb_ftrconf.jet
@@ -22,6 +22,7 @@
{{ item.Text }}
({{ item.Text2 }})
+ {{ if item.Flags["new"] }}🔔{{ end }}
{{ end }}
{{ else }}