A platform for community discussion. Free, open, simple.
DEV: Replace computed macros with getters in `PostStream` (#36758)
Sérgio Saquetim528786e6bea1
diff --git a/frontend/discourse/app/models/post-stream.js b/frontend/discourse/app/models/post-stream.jsindex 2d987e23978..be5432bc7d9 100644--- a/frontend/discourse/app/models/post-stream.js+++ b/frontend/discourse/app/models/post-stream.js@@ -1,7 +1,6 @@import { cached, tracked } from "@glimmer/tracking";import { get } from "@ember/object";import { dependentKeyCompat } from "@ember/object/compat";-import { and, equal, not, or } from "@ember/object/computed";import { schedule } from "@ember/runloop";import { service } from "@ember/service";import { isEmpty } from "@ember/utils";@@ -73,16 +72,48 @@ export default class PostStream extends RestModel {@trackedArray stream = [];@trackedArray userFilters = [];- @or("loadingAbove", "loadingBelow", "loadingFilter", "stagingPost") loading;- @not("loading") notLoading;- @equal("filter", "summary") summary;- @and("notLoading", "hasPosts", "lastPostNotLoaded") canAppendMore;- @and("notLoading", "hasPosts", "firstPostNotLoaded") canPrependMore;- @not("firstPostPresent") firstPostNotLoaded;- @not("loadedAllPosts") lastPostNotLoaded;-_identityMap = {};+ @dependentKeyCompat+ get loading() {+ return (+ this.loadingAbove ||+ this.loadingBelow ||+ this.loadingFilter ||+ this.stagingPost+ );+ }++ @dependentKeyCompat+ get notLoading() {+ return !this.loading;+ }++ @dependentKeyCompat+ get firstPostNotLoaded() {+ return !this.firstPostPresent;+ }++ @dependentKeyCompat+ get lastPostNotLoaded() {+ return !this.loadedAllPosts;+ }++ @dependentKeyCompat+ get canAppendMore() {+ return this.notLoading && this.hasPosts && this.lastPostNotLoaded;+ }++ @dependentKeyCompat+ get canPrependMore() {+ return this.notLoading && this.hasPosts && this.firstPostNotLoaded;+ }++ @dependentKeyCompat+ get summary() {+ return this.filter === "summary";+ }+@cached@dependentKeyCompatget postsWithPlaceholders() {