discourse/spec/fabricators/topic_user_fabricator.rb
Martin Brennan c6c633e041
FIX: Issues with incorrect unread and private message topic tracking state (#16474)
This commit fixes two issues at play. The first was introduced
in f6c852b (or maybe not introduced
but rather revealed). When a user posted a new message in a topic,
they received the unread topic tracking state MessageBus message,
and the Unread (X) indicator was incremented by one, because with the
aforementioned perf commit we "guess" the correct last read post
for the user, because we no longer calculate individual users' read
status there. This meant that every time a user posted in a topic
they tracked, the unread indicator was incremented. To get around
this, we can just exclude the user who created the post from the
target users of the unread state message.

The second issue was related to the private message topic tracking
state, and was somewhat similar. Whenever a user created a new private
message, the New (X) indicator was incremented, and could not be
cleared until the page was refreshed. To solve this, we just don't
update the topic state for the user when the new_topic tracking state
message comes through if the user who created the topic is the
same as the current user.

cf. https://meta.discourse.org/t/bottom-of-topic-shows-there-is-1-unread-remaining-when-there-are-actually-0-unread-topics-remaining/220817
2022-04-19 11:37:01 +10:00

23 lines
581 B
Ruby

# frozen_string_literal: true
Fabricator(:topic_user) do
user
topic
end
Fabricator(:topic_user_tracking, from: :topic_user) do
notification_level { NotificationLevels.topic_levels[:tracking] }
end
Fabricator(:topic_user_watching, from: :topic_user) do
notification_level { NotificationLevels.topic_levels[:watching] }
end
Fabricator(:topic_user_regular, from: :topic_user) do
notification_level { NotificationLevels.topic_levels[:regular] }
end
Fabricator(:topic_user_muted, from: :topic_user) do
notification_level { NotificationLevels.topic_levels[:muted] }
end