From f82667f3b86202dafff3a2a4ea56aec74c80316d Mon Sep 17 00:00:00 2001 From: enahum Date: Thu, 27 Oct 2016 12:24:30 -0300 Subject: PLT-4430 improve slow channel switching (#4331) * PLT-4430 improve slow channel switching * Update client side unit tests * Convert getChannelsUnread to getMyChannelMembers and address other feedback * Pull channel members on websocket reconnect --- api/channel.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'api/channel.go') diff --git a/api/channel.go b/api/channel.go index bae2a5277..2232786fd 100644 --- a/api/channel.go +++ b/api/channel.go @@ -21,6 +21,7 @@ func InitChannel() { BaseRoutes.Channels.Handle("/", ApiUserRequired(getChannels)).Methods("GET") BaseRoutes.Channels.Handle("/more", ApiUserRequired(getMoreChannels)).Methods("GET") BaseRoutes.Channels.Handle("/counts", ApiUserRequired(getChannelCounts)).Methods("GET") + BaseRoutes.Channels.Handle("/members", ApiUserRequired(getMyChannelMembers)).Methods("GET") BaseRoutes.Channels.Handle("/create", ApiUserRequired(createChannel)).Methods("POST") BaseRoutes.Channels.Handle("/create_direct", ApiUserRequired(createDirectChannel)).Methods("POST") BaseRoutes.Channels.Handle("/update", ApiUserRequired(updateChannel)).Methods("POST") @@ -81,7 +82,7 @@ func createChannel(c *Context, w http.ResponseWriter, r *http.Request) { return } else { data := result.Data.(*model.ChannelList) - if int64(len(data.Channels)+1) > *utils.Cfg.TeamSettings.MaxChannelsPerTeam { + if int64(len(*data)+1) > *utils.Cfg.TeamSettings.MaxChannelsPerTeam { c.Err = model.NewLocAppError("createChannel", "api.channel.create_channel.max_channel_limit.app_error", map[string]interface{}{"MaxChannelsPerTeam": *utils.Cfg.TeamSettings.MaxChannelsPerTeam}, "") return } @@ -987,6 +988,16 @@ func getChannelMember(c *Context, w http.ResponseWriter, r *http.Request) { } } +func getMyChannelMembers(c *Context, w http.ResponseWriter, r *http.Request) { + if result := <-Srv.Store.Channel().GetMembersForUser(c.TeamId, c.Session.UserId); result.Err != nil { + c.Err = result.Err + return + } else { + data := result.Data.(*model.ChannelMembers) + w.Write([]byte(data.ToJson())) + } +} + func addMember(c *Context, w http.ResponseWriter, r *http.Request) { params := mux.Vars(r) id := params["channel_id"] -- cgit v1.2.3-1-g7c22