mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
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:
parent
adeda6c6a5
commit
a64f021f49
@ -5,8 +5,11 @@ import { url } from "discourse/lib/computed";
|
|||||||
import UserAction from "discourse/models/user-action";
|
import UserAction from "discourse/models/user-action";
|
||||||
import { on } from "discourse-common/utils/decorators";
|
import { on } from "discourse-common/utils/decorators";
|
||||||
|
|
||||||
export default EmberObject.extend({
|
export default class UserPostsStream extends EmberObject {
|
||||||
loaded: false,
|
loaded = false;
|
||||||
|
|
||||||
|
@url("user.username_lower", "filter", "itemsLoaded", "/posts/%@/%@?offset=%@")
|
||||||
|
url;
|
||||||
|
|
||||||
@on("init")
|
@on("init")
|
||||||
_initialize() {
|
_initialize() {
|
||||||
@ -15,14 +18,7 @@ export default EmberObject.extend({
|
|||||||
canLoadMore: true,
|
canLoadMore: true,
|
||||||
content: [],
|
content: [],
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
url: url(
|
|
||||||
"user.username_lower",
|
|
||||||
"filter",
|
|
||||||
"itemsLoaded",
|
|
||||||
"/posts/%@/%@?offset=%@"
|
|
||||||
),
|
|
||||||
|
|
||||||
filterBy(opts) {
|
filterBy(opts) {
|
||||||
if (this.loaded && this.filter === opts.filter) {
|
if (this.loaded && this.filter === opts.filter) {
|
||||||
@ -41,7 +37,7 @@ export default EmberObject.extend({
|
|||||||
);
|
);
|
||||||
|
|
||||||
return this.findItems();
|
return this.findItems();
|
||||||
},
|
}
|
||||||
|
|
||||||
findItems() {
|
findItems() {
|
||||||
if (this.loading || !this.canLoadMore) {
|
if (this.loading || !this.canLoadMore) {
|
||||||
@ -63,5 +59,5 @@ export default EmberObject.extend({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.finally(() => this.set("loading", false));
|
.finally(() => this.set("loading", false));
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user