Esempio n. 1
0
// UpdateUserlist updates the userlist contents
func UpdateUserlist() {
	chanData := data.GetChannel(GetActiveNetwork(), GetActiveChannel())
	if chanData == nil || len(chanData.Userlist) == 0 {
		if !IsUserlistHidden() {
			ToggleUserlist(false)
		}
		jq("#open-user-list").AddClass("hidden-medium-down")
		jq("#open-settings").RemoveClass("hidden-medium-down")
		return
	}

	if IsUserlistHidden() && !WasUserlistHiddenManually() {
		ToggleUserlist(false)
	}
	userlistObj := jq("#userlist-list")
	userlistObj.SetText("")
	for i, user := range chanData.Userlist {
		templates.AppendObj("userlist-entry", userlistObj, map[string]interface{}{
			"Network":     GetActiveNetwork(),
			"Name":        chanData.UserlistPlain[i],
			"DisplayName": user,
		})
	}

	templates.AppendObj("userlist-invite", userlistObj, nil)
	jq("#open-user-list").RemoveClass("hidden-medium-down")
	jq("#open-settings").AddClass("hidden-medium-down")
}
Esempio n. 2
0
// NotifyMessage shows necessary notifications
func NotifyMessage(network, channel, sender, message string, highlight bool) {
	message = util.RemoveFormatChars(message)

	notifs := data.NotificationAll
	ch := data.GetChannel(network, channel)
	if ch != nil {
		notifs = ch.Notifications
	}

	hide := GetChannel(network, channel).HasClass("hidden")
	if (notifs == data.NotificationAll || (notifs == data.NotificationHighlights && highlight)) && !js.Global.Get("document").Call("hasFocus").Bool() {
		SendNotification(network, channel, sender, message)
		if hide {
			ChannelHasNewMessages(network, channel)
		}
	}

	if !hide {
		ScrollDown()
	}
}