mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
MM-34895: LastViewed should be updated correctly for new thread membership (#17673)
Summary Update LastViewed correctly for new thread membership Ticket Link https://mattermost.atlassian.net/browse/MM-34895
This commit is contained in:
@@ -5766,8 +5766,8 @@ func TestMaintainUnreadRepliesInThread(t *testing.T) {
|
||||
// replying to the thread clears reply count, so it should be 0
|
||||
checkThreadListReplies(t, th, th.Client, th.BasicUser.Id, 0, 1, nil)
|
||||
|
||||
// the other user should have 2 replies
|
||||
checkThreadListReplies(t, th, th.SystemAdminClient, th.SystemAdminUser.Id, 2, 1, nil)
|
||||
// the other user should have 1 reply - the reply from the regular user
|
||||
checkThreadListReplies(t, th, th.SystemAdminClient, th.SystemAdminUser.Id, 1, 1, nil)
|
||||
|
||||
// mark all as read for user
|
||||
resp := th.Client.UpdateThreadsReadForUser(th.BasicUser.Id, th.BasicTeam.Id)
|
||||
|
||||
@@ -521,11 +521,15 @@ func (s *SqlThreadStore) MaintainMembership(userId, postId string, following, in
|
||||
if incrementMentions {
|
||||
mentions = 1
|
||||
}
|
||||
var lastViewed int64
|
||||
if updateViewedTimestamp {
|
||||
lastViewed = now
|
||||
}
|
||||
membership, err = s.SaveMembership(&model.ThreadMembership{
|
||||
PostId: postId,
|
||||
UserId: userId,
|
||||
Following: following,
|
||||
LastViewed: 0,
|
||||
LastViewed: lastViewed,
|
||||
LastUpdated: now,
|
||||
UnreadMentions: int64(mentions),
|
||||
})
|
||||
|
||||
@@ -297,11 +297,9 @@ func testThreadStorePopulation(t *testing.T, ss store.Store) {
|
||||
t.Run("Thread membership 'viewed' timestamp is updated properly", func(t *testing.T) {
|
||||
newPosts := makeSomePosts()
|
||||
|
||||
_, e := ss.Thread().MaintainMembership(newPosts[0].UserId, newPosts[0].Id, true, false, true, false, false)
|
||||
tm, e := ss.Thread().MaintainMembership(newPosts[0].UserId, newPosts[0].Id, true, false, true, false, false)
|
||||
require.NoError(t, e)
|
||||
m, err1 := ss.Thread().GetMembershipForUser(newPosts[0].UserId, newPosts[0].Id)
|
||||
require.NoError(t, err1)
|
||||
require.Equal(t, int64(0), m.LastViewed)
|
||||
require.Equal(t, int64(0), tm.LastViewed)
|
||||
|
||||
_, e = ss.Thread().MaintainMembership(newPosts[0].UserId, newPosts[0].Id, true, false, true, true, false)
|
||||
require.NoError(t, e)
|
||||
@@ -310,6 +308,13 @@ func testThreadStorePopulation(t *testing.T, ss store.Store) {
|
||||
require.Greater(t, m2.LastViewed, int64(0))
|
||||
})
|
||||
|
||||
t.Run("Thread membership 'viewed' timestamp is updated properly for new membership", func(t *testing.T) {
|
||||
newPosts := makeSomePosts()
|
||||
tm, e := ss.Thread().MaintainMembership(newPosts[0].UserId, newPosts[0].Id, true, false, false, true, false)
|
||||
require.NoError(t, e)
|
||||
require.NotEqual(t, int64(0), tm.LastViewed)
|
||||
})
|
||||
|
||||
t.Run("Thread last updated is changed when channel is updated after UpdateLastViewedAtPost for mark unread", func(t *testing.T) {
|
||||
newPosts := makeSomePosts()
|
||||
_, e := ss.Thread().MaintainMembership(newPosts[0].UserId, newPosts[0].Id, true, false, true, false, false)
|
||||
|
||||
Reference in New Issue
Block a user