mirror of
https://github.com/discourse/discourse.git
synced 2026-08-09 12:38:21 -05:00
DEV: Replace computed macros with getters in PostStream (#36758)
Refactor `PostStream` by replacing Ember's computed macros (`@or`, `@and`, `@not`, `@equal`) with native getters and `@dependentKeyCompat`. This modernizes the codebase to align with current Ember conventions and improves readability and maintainability. No functional changes introduced.
This commit is contained in:
@@ -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
|
||||
@dependentKeyCompat
|
||||
get postsWithPlaceholders() {
|
||||
|
||||
Reference in New Issue
Block a user