FIX: topic tracking stage error when no tags (#18901)

When topic Tag is tracked and payload doesn't contain tags, it was throwing an error.
This commit is contained in:
Krzysztof Kotlarek 2022-11-08 10:16:05 +11:00 committed by GitHub
parent 4116094e54
commit ff21651d64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -207,7 +207,7 @@ const TopicTrackingState = EmberObject.extend({
}
}
if (filterTag && !data.payload.tags.includes(filterTag)) {
if (filterTag && !data.payload.tags?.includes(filterTag)) {
return;
}

View File

@ -104,6 +104,16 @@ discourseModule("Unit | Model | topic-tracking-state", function (hooks) {
0,
"pending tag new counts"
);
// Ensure it is not throwing an error when filterTag is set and message payload is missing tags
trackingState.trackIncoming("tag/test/l/latest");
trackingState.notifyIncoming({
message_type: "new_topic",
topic_id: 4,
payload: { category_id: 2 },
});
const testTagCount = trackingState.countTags(["test"]);
assert.strictEqual(testTagCount["test"].unreadCount, 0);
});
test("tag counts - with total", function (assert) {