FIX: Show correct avatar in post stream bar (#11481)

Also fixes the displayed count of posts when filtered by user.
This commit is contained in:
Penar Musaraj
2020-12-14 15:24:15 -05:00
committed by GitHub
parent b45a30c40f
commit 0e210df79a
3 changed files with 10 additions and 5 deletions

View File

@ -41,6 +41,7 @@ export default MountWidget.extend({
return this.getProperties( return this.getProperties(
"posts", "posts",
"canCreatePost", "canCreatePost",
"filteredPostsCount",
"multiSelect", "multiSelect",
"gaps", "gaps",
"selectedQuery", "selectedQuery",

View File

@ -200,6 +200,7 @@
canCreatePost=model.details.can_create_post canCreatePost=model.details.can_create_post
multiSelect=multiSelect multiSelect=multiSelect
selectedPostsCount=selectedPostsCount selectedPostsCount=selectedPostsCount
filteredPostsCount=model.postStream.filteredPostsCount
selectedQuery=selectedQuery selectedQuery=selectedQuery
gaps=model.postStream.gaps gaps=model.postStream.gaps
showReadIndicator=model.show_read_indicator showReadIndicator=model.show_read_indicator

View File

@ -119,22 +119,24 @@ createWidget("posts-filtered-notice", {
this.attach("filter-show-all", attrs), this.attach("filter-show-all", attrs),
]; ];
} else if (filters.username_filters) { } else if (filters.username_filters) {
const firstUserPost = attrs.posts[1],
userPostsCount = parseInt(attrs.filteredPostsCount, 10) - 1;
return [ return [
h( h(
"span.filtered-replies-viewing", "span.filtered-replies-viewing",
I18n.t("post.filtered_replies.viewing_posts_by", { I18n.t("post.filtered_replies.viewing_posts_by", {
post_count: attrs.posts.length, post_count: userPostsCount,
}) })
), ),
h( h(
"span.filtered-avatar", "span.filtered-avatar",
avatarFor.call(this, "small", { avatarFor.call(this, "small", {
template: attrs.posts[0].avatar_template, template: firstUserPost.avatar_template,
username: attrs.posts[0].username, username: firstUserPost.username,
url: attrs.posts[0].usernameUrl, url: firstUserPost.usernameUrl,
}) })
), ),
this.attach("poster-name", attrs.posts[0]), this.attach("poster-name", firstUserPost),
this.attach("filter-show-all", attrs), this.attach("filter-show-all", attrs),
]; ];
} }
@ -282,6 +284,7 @@ export default createWidget("post-stream", {
this.attach("posts-filtered-notice", { this.attach("posts-filtered-notice", {
posts: postArray, posts: postArray,
streamFilters: attrs.streamFilters, streamFilters: attrs.streamFilters,
filteredPostsCount: attrs.filteredPostsCount,
}) })
); );
} }