github.com/Azareal/Gosora@v0.0.0-20210729070923-553e66b59003/common/widget_wol_context.go (about)

     1  package common
     2  
     3  import "github.com/Azareal/Gosora/common/phrases"
     4  
     5  func wolContextRender(widget *Widget, hvars interface{}) (string, error) {
     6  	header := hvars.(*Header)
     7  	if header.Zone != "view_topic" {
     8  		return "", nil
     9  	}
    10  	var ucount int
    11  	var users []*User
    12  	topicMutex.RLock()
    13  	topic, ok := topicWatchers[header.ZoneID]
    14  	if ok {
    15  		ucount = len(topic)
    16  		if ucount < 30 {
    17  			users = make([]*User, len(topic))
    18  			i := 0
    19  			for wsUser, _ := range topic {
    20  				users[i] = wsUser.User
    21  				i++
    22  			}
    23  		}
    24  	}
    25  	topicMutex.RUnlock()
    26  	wol := &wolUsers{header, phrases.GetTmplPhrase("widget.online_view_topic_name"), users, ucount}
    27  	e := header.Theme.RunTmpl("widget_online", wol, header.Writer)
    28  	return "", e
    29  }