DEV: Convert user-posts-stream to native class syntax (#27278)

This is the final model in Discourse core to be converted
This commit is contained in:
David Taylor 2024-06-03 15:03:50 +01:00 committed by GitHub
parent adeda6c6a5
commit a64f021f49
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,8 +5,11 @@ import { url } from "discourse/lib/computed";
import UserAction from "discourse/models/user-action";
import { on } from "discourse-common/utils/decorators";
export default EmberObject.extend({
loaded: false,
export default class UserPostsStream extends EmberObject {
loaded = false;
@url("user.username_lower", "filter", "itemsLoaded", "/posts/%@/%@?offset=%@")
url;
@on("init")
_initialize() {
@ -15,14 +18,7 @@ export default EmberObject.extend({
canLoadMore: true,
content: [],
});
},
url: url(
"user.username_lower",
"filter",
"itemsLoaded",
"/posts/%@/%@?offset=%@"
),
}
filterBy(opts) {
if (this.loaded && this.filter === opts.filter) {
@ -41,7 +37,7 @@ export default EmberObject.extend({
);
return this.findItems();
},
}
findItems() {
if (this.loading || !this.canLoadMore) {
@ -63,5 +59,5 @@ export default EmberObject.extend({
}
})
.finally(() => this.set("loading", false));
},
});
}
}