REFACTOR: Remove `Discourse.SiteSettings` from topic tracking state
This commit is contained in:
parent
f6c40075e5
commit
531793e98f
|
@ -27,14 +27,14 @@ function isUnseen(topic) {
|
||||||
return !topic.is_seen;
|
return !topic.is_seen;
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasMutedTags(topicTagIds, mutedTagIds) {
|
function hasMutedTags(topicTagIds, mutedTagIds, siteSettings) {
|
||||||
if (!mutedTagIds || !topicTagIds) {
|
if (!mutedTagIds || !topicTagIds) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
(Discourse.SiteSettings.remove_muted_tags_from_latest === "always" &&
|
(siteSettings.remove_muted_tags_from_latest === "always" &&
|
||||||
topicTagIds.any(tagId => mutedTagIds.includes(tagId))) ||
|
topicTagIds.any(tagId => mutedTagIds.includes(tagId))) ||
|
||||||
(Discourse.SiteSettings.remove_muted_tags_from_latest === "only_muted" &&
|
(siteSettings.remove_muted_tags_from_latest === "only_muted" &&
|
||||||
topicTagIds.every(tagId => mutedTagIds.includes(tagId)))
|
topicTagIds.every(tagId => mutedTagIds.includes(tagId)))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,13 @@ const TopicTrackingState = EmberObject.extend({
|
||||||
|
|
||||||
if (["new_topic", "latest"].includes(data.message_type)) {
|
if (["new_topic", "latest"].includes(data.message_type)) {
|
||||||
const mutedTagIds = User.currentProp("muted_tag_ids");
|
const mutedTagIds = User.currentProp("muted_tag_ids");
|
||||||
if (hasMutedTags(data.payload.topic_tag_ids, mutedTagIds)) {
|
if (
|
||||||
|
hasMutedTags(
|
||||||
|
data.payload.topic_tag_ids,
|
||||||
|
mutedTagIds,
|
||||||
|
this.siteSettings
|
||||||
|
)
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,7 @@ export default {
|
||||||
|
|
||||||
const topicTrackingState = TopicTrackingState.create({
|
const topicTrackingState = TopicTrackingState.create({
|
||||||
messageBus: MessageBus,
|
messageBus: MessageBus,
|
||||||
|
siteSettings,
|
||||||
currentUser
|
currentUser
|
||||||
});
|
});
|
||||||
app.register("topic-tracking-state:main", topicTrackingState, {
|
app.register("topic-tracking-state:main", topicTrackingState, {
|
||||||
|
|
Loading…
Reference in New Issue