"new" flag on conference hotlist sidebox works (it's a bell)
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
<a href="{{ item.Link }}" class="text-blue-700 hover:text-blue-900 font-bold">{{ item.Text }}</a>
|
||||
<span class="text-black"> ({{ item.Text2 }})</span>
|
||||
</div>
|
||||
{{ if item.Flags["new"] }}<span class="ml-1" title="There are new messages in this conference">🔔</span>{{ end }}
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
|
||||
Reference in New Issue
Block a user