* Mark category as read

* Fix lint and test

* Fix tests

* Fix test and remove wrong aria

* Address server issues and add mark as read for unreads

* Missing changes

* Fix tests

* fix tests

* Add confirmation popup to mark as read category

* Always use viewMultipleChannels and other fixes

* Remove unneeded code

* Fix test

* Address feedback

* Address feedback

* Fix tests

* Fix test

* Fix tests

* Update aria-haspopup depending on the number of channels to mark as viewed

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Daniel Espino García
2023-08-14 10:01:02 +02:00
коммит произвёл GitHub
родитель c1c07ba1bb
Коммит e9b3afecc2
60 изменённых файлов: 1151 добавлений и 1557 удалений

Просмотреть файл

@@ -24,6 +24,7 @@ func (api *API) InitChannel() {
api.BaseRoutes.Channels.Handle("/group/search", api.APISessionRequiredDisableWhenBusy(searchGroupChannels)).Methods("POST")
api.BaseRoutes.Channels.Handle("/group", api.APISessionRequired(createGroupChannel)).Methods("POST")
api.BaseRoutes.Channels.Handle("/members/{user_id:[A-Za-z0-9]+}/view", api.APISessionRequired(viewChannel)).Methods("POST")
api.BaseRoutes.Channels.Handle("/members/{user_id:[A-Za-z0-9]+}/mark_read", api.APISessionRequired(readMultipleChannels)).Methods("POST")
api.BaseRoutes.Channels.Handle("/{channel_id:[A-Za-z0-9]+}/scheme", api.APISessionRequired(updateChannelScheme)).Methods("PUT")
api.BaseRoutes.Channels.Handle("/stats/member_count", api.APISessionRequired(getChannelsMemberCount)).Methods("POST")
@@ -1537,6 +1538,32 @@ func viewChannel(c *Context, w http.ResponseWriter, r *http.Request) {
}
}
func readMultipleChannels(c *Context, w http.ResponseWriter, r *http.Request) {
c.RequireUserId()
var channelIDs []string
err := json.NewDecoder(r.Body).Decode(&channelIDs)
if err != nil || len(channelIDs) == 0 {
c.SetInvalidParamWithErr("channel_ids", err)
return
}
times, appErr := c.App.MarkChannelsAsViewed(c.AppContext, channelIDs, c.Params.UserId, c.AppContext.Session().Id, true, c.App.IsCRTEnabledForUser(c.AppContext, c.Params.UserId))
if appErr != nil {
c.Err = appErr
return
}
resp := &model.ChannelViewResponse{
Status: "OK",
LastViewedAtTimes: times,
}
if err := json.NewEncoder(w).Encode(resp); err != nil {
c.Logger.Warn("Error while writing response", mlog.Err(err))
}
}
func updateChannelMemberRoles(c *Context, w http.ResponseWriter, r *http.Request) {
c.RequireChannelId().RequireUserId()
if c.Err != nil {

Просмотреть файл

@@ -2478,9 +2478,10 @@ func TestViewChannel(t *testing.T) {
CheckBadRequestStatus(t, resp)
view.ChannelId = "correctlysizedjunkdddfdfdf"
_, resp, err = client.ViewChannel(context.Background(), th.BasicUser.Id, view)
require.Error(t, err)
CheckBadRequestStatus(t, resp)
viewResult, _, err := client.ViewChannel(context.Background(), th.BasicUser.Id, view)
require.NoError(t, err)
require.Len(t, viewResult.LastViewedAtTimes, 0)
view.ChannelId = th.BasicChannel.Id
member, _, err := client.GetChannelMember(context.Background(), th.BasicChannel.Id, th.BasicUser.Id, "")