FIX: Make select all and below skip small actions. (#7425)

This commit is contained in:
Dan Ungureanu
2019-05-06 16:22:11 +03:00
committed by GitHub
parent a40dcbde9b
commit 33e06dd796
2 changed files with 44 additions and 5 deletions

View File

@@ -173,11 +173,32 @@ export default Ember.Controller.extend(bufferedProperty("model"), {
},
_updateSelectedPostIds(postIds) {
this.get("selectedPostIds").pushObjects(postIds);
const smallActionsPostIds = this._smallActionPostIds();
this.get("selectedPostIds").pushObjects(
postIds.filter(postId => !smallActionsPostIds.has(postId))
);
this.set("selectedPostIds", [...new Set(this.get("selectedPostIds"))]);
this._forceRefreshPostStream();
},
_smallActionPostIds() {
const smallActionsPostIds = new Set();
const posts = this.get("model.postStream.posts");
if (posts) {
const small_action = this.site.get("post_types.small_action");
const whisper = this.site.get("post_types.whisper");
posts.forEach(post => {
if (
post.post_type === small_action ||
(!post.cooked && post.post_type === whisper)
) {
smallActionsPostIds.add(post.id);
}
});
}
return smallActionsPostIds;
},
_loadPostIds(post) {
if (this.get("loadingPostIds")) return;
@@ -664,7 +685,12 @@ export default Ember.Controller.extend(bufferedProperty("model"), {
},
selectAll() {
this.set("selectedPostIds", [...this.get("model.postStream.stream")]);
const smallActionsPostIds = this._smallActionPostIds();
this.set("selectedPostIds", [
...this.get("model.postStream.stream").filter(
postId => !smallActionsPostIds.has(postId)
)
]);
this._forceRefreshPostStream();
},