* 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 удалений

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

@@ -2020,6 +2020,82 @@ func (s SqlChannelStore) GetChannelMembersTimezones(channelId string) ([]model.S
return dbMembersTimezone, nil
}
func (s SqlChannelStore) GetChannelsWithUnreadsAndWithMentions(ctx context.Context, channelIDs []string, userID string, userNotifyProps model.StringMap) ([]string, []string, map[string]int64, error) {
query := s.getQueryBuilder().Select(
"Channels.Id",
"Channels.Type",
"Channels.TotalMsgCount",
"Channels.LastPostAt",
"ChannelMembers.MsgCount",
"ChannelMembers.MentionCount",
"ChannelMembers.NotifyProps",
"ChannelMembers.LastViewedAt",
).
From("ChannelMembers").
InnerJoin("Channels ON ChannelMembers.ChannelId = Channels.Id").
Where(sq.Eq{
"ChannelMembers.ChannelId": channelIDs,
"ChannelMembers.UserId": userID,
})
queryString, args, err := query.ToSql()
if err != nil {
return nil, nil, nil, errors.Wrap(err, "channel_tosql")
}
var channels []struct {
Id string
Type string
TotalMsgCount int
LastPostAt int64
MsgCount int
MentionCount int
NotifyProps model.StringMap
LastViewedAt int64
}
err = s.GetReplicaX().Select(&channels, queryString, args...)
if err != nil {
return nil, nil, nil, errors.Wrap(err, "failed to find channels with unreads and with mentions data")
}
channelsWithUnreads := []string{}
channelsWithMentions := []string{}
readTimes := map[string]int64{}
for i := range channels {
channel := channels[i]
hasMentions := (channel.MentionCount > 0)
hasUnreads := (channel.TotalMsgCount-channel.MsgCount > 0) || hasMentions
if hasUnreads {
channelsWithUnreads = append(channelsWithUnreads, channel.Id)
}
notify := channel.NotifyProps[model.PushNotifyProp]
if notify == model.ChannelNotifyDefault {
notify = userNotifyProps[model.PushNotifyProp]
}
if notify == model.UserNotifyAll || channel.Type == string(model.ChannelTypeDirect) {
if hasUnreads {
channelsWithMentions = append(channelsWithMentions, channel.Id)
}
} else if notify == model.UserNotifyMention {
if hasMentions {
channelsWithMentions = append(channelsWithMentions, channel.Id)
}
}
if channel.LastPostAt > channel.LastViewedAt {
readTimes[channel.Id] = channel.LastPostAt
} else {
readTimes[channel.Id] = channel.LastViewedAt
}
}
return channelsWithUnreads, channelsWithMentions, readTimes, nil
}
func (s SqlChannelStore) GetMember(ctx context.Context, channelID string, userID string) (*model.ChannelMember, error) {
selectSQL, args, err := s.channelMembersForTeamWithSchemeSelectQuery.
Where(sq.Eq{
@@ -2512,6 +2588,10 @@ func (s SqlChannelStore) UpdateLastViewedAt(channelIds []string, userId string)
TotalMsgCountRoot int64
}{}
if len(channelIds) == 0 {
return map[string]int64{}, nil
}
// We use the question placeholder format for both databases, because
// we replace that with the dollar format later on.
// It's needed to support the prefix CTE query. See: https://github.com/Masterminds/squirrel/issues/285.