mirror of https://github.com/velour/catbase.git
emojy: indicate if an emojy is on the server
This commit is contained in:
parent
e8c7e1e07e
commit
61cdb66546
|
@ -83,13 +83,23 @@ type EmojyEntry struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type EmojyCount struct {
|
type EmojyCount struct {
|
||||||
Emojy string `json:"emojy"`
|
Emojy string `json:"emojy"`
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
Count int `json:"count"`
|
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) {
|
func (p *EmojyPlugin) allCounts() (map[string][]EmojyCount, error) {
|
||||||
out := map[string][]EmojyCount{}
|
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`
|
q := `select emojy, count(observed) as count from emojyLog group by emojy order by count desc`
|
||||||
result := []EmojyCount{}
|
result := []EmojyCount{}
|
||||||
err := p.db.Select(&result, q)
|
err := p.db.Select(&result, q)
|
||||||
|
@ -97,8 +107,8 @@ func (p *EmojyPlugin) allCounts() (map[string][]EmojyCount, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, e := range result {
|
for _, e := range result {
|
||||||
|
_, e.OnServer = onServerList[e.Emojy]
|
||||||
if isEmoji(e.Emojy) {
|
if isEmoji(e.Emojy) {
|
||||||
|
|
||||||
out["emoji"] = append(out["emoji"], e)
|
out["emoji"] = append(out["emoji"], e)
|
||||||
} else if ok, fname, _ := p.isKnownEmojy(e.Emojy); ok {
|
} else if ok, fname, _ := p.isKnownEmojy(e.Emojy); ok {
|
||||||
e.URL = fname
|
e.URL = fname
|
||||||
|
|
|
@ -39,6 +39,11 @@
|
||||||
<ul>
|
<ul>
|
||||||
<li v-for="emojy in category" key="emojy">
|
<li v-for="emojy in category" key="emojy">
|
||||||
{{emojy.count}} -
|
{{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" />
|
<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>
|
<span v-else>{{emojy.emojy}}</span>
|
||||||
</li>
|
</li>
|
||||||
|
|
Loading…
Reference in New Issue