ea4da062c3
Reduce allocs in WsHubImpl.getUsers() Reduce allocs in wolContextRender() Use b.String() instead of string(b.Bytes()) in preparseWidget() Reduce boilerplate.
30 lines
698 B
Go
30 lines
698 B
Go
package common
|
|
|
|
import "github.com/Azareal/Gosora/common/phrases"
|
|
|
|
func wolContextRender(widget *Widget, hvars interface{}) (string, error) {
|
|
header := hvars.(*Header)
|
|
if header.Zone != "view_topic" {
|
|
return "", nil
|
|
}
|
|
var ucount int
|
|
var users []*User
|
|
topicMutex.RLock()
|
|
topic, ok := topicWatchers[header.ZoneID]
|
|
if ok {
|
|
ucount = len(topic)
|
|
if ucount < 30 {
|
|
users = make([]*User, len(topic))
|
|
i := 0
|
|
for wsUser, _ := range topic {
|
|
users[i] = wsUser.User
|
|
i++
|
|
}
|
|
}
|
|
}
|
|
topicMutex.RUnlock()
|
|
wol := &wolUsers{header, phrases.GetTmplPhrase("widget.online_view_topic_name"), users, ucount}
|
|
e := header.Theme.RunTmpl("widget_online", wol, header.Writer)
|
|
return "", e
|
|
}
|