emojy: indicate if an emojy is on the server

This commit is contained in:
Chris Sexton 2022-06-06 10:47:11 -04:00
parent e8c7e1e07e
commit 61cdb66546
2 changed files with 19 additions and 4 deletions

View File

@ -86,10 +86,20 @@ type EmojyCount struct {
Emojy string `json:"emojy"`
URL string `json:"url"`
Count int `json:"count"`
OnServer bool `json:"onServer"`
}
func invertEmojyList(emojy map[string]string) map[string]string {
out := map[string]string{}
for k, v := range emojy {
out[v] = k
}
return out
}
func (p *EmojyPlugin) allCounts() (map[string][]EmojyCount, error) {
out := map[string][]EmojyCount{}
onServerList := invertEmojyList(p.b.DefaultConnector().GetEmojiList())
q := `select emojy, count(observed) as count from emojyLog group by emojy order by count desc`
result := []EmojyCount{}
err := p.db.Select(&result, q)
@ -97,8 +107,8 @@ func (p *EmojyPlugin) allCounts() (map[string][]EmojyCount, error) {
return nil, err
}
for _, e := range result {
_, e.OnServer = onServerList[e.Emojy]
if isEmoji(e.Emojy) {
out["emoji"] = append(out["emoji"], e)
} else if ok, fname, _ := p.isKnownEmojy(e.Emojy); ok {
e.URL = fname

View File

@ -39,6 +39,11 @@
<ul>
<li v-for="emojy in category" key="emojy">
{{emojy.count}} -
<span v-if="name != 'emoji'">
<span v-if="emojy.onServer"></span>
<span v-else></span>
-
</span>
<img v-if="emojy.url" :src="emojy.url" :alt="emojy.name" class="img-thumbnail" style="max-width: 64px; max-height: 64px" />
<span v-else>{{emojy.emojy}}</span>
</li>