mirror of
https://github.com/discourse/discourse.git
synced 2025-04-11 03:41:42 +08:00
DEV: Convert UserStream model to native class syntax (#25629)
This commit was created with a combination of the ember-native-class-codemod and manual cleanup
This commit is contained in:
parent
d93debc634
commit
2af8f5708d
@ -6,15 +6,19 @@ import { emojiUnescape } from "discourse/lib/text";
|
|||||||
import { escapeExpression } from "discourse/lib/utilities";
|
import { escapeExpression } from "discourse/lib/utilities";
|
||||||
import RestModel from "discourse/models/rest";
|
import RestModel from "discourse/models/rest";
|
||||||
import UserAction from "discourse/models/user-action";
|
import UserAction from "discourse/models/user-action";
|
||||||
import discourseComputed, { on } from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
|
|
||||||
export default RestModel.extend({
|
export default class UserStream extends RestModel {
|
||||||
loaded: false,
|
loaded = false;
|
||||||
|
itemsLoaded = 0;
|
||||||
|
content = [];
|
||||||
|
|
||||||
@on("init")
|
@url(
|
||||||
_initialize() {
|
"itemsLoaded",
|
||||||
this.setProperties({ itemsLoaded: 0, content: [] });
|
"user.username_lower",
|
||||||
},
|
"/user_actions.json?offset=%@&username=%@"
|
||||||
|
)
|
||||||
|
baseUrl;
|
||||||
|
|
||||||
@discourseComputed("filter")
|
@discourseComputed("filter")
|
||||||
filterParam(filter) {
|
filterParam(filter) {
|
||||||
@ -27,13 +31,7 @@ export default RestModel.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return filter;
|
return filter;
|
||||||
},
|
}
|
||||||
|
|
||||||
baseUrl: url(
|
|
||||||
"itemsLoaded",
|
|
||||||
"user.username_lower",
|
|
||||||
"/user_actions.json?offset=%@&username=%@"
|
|
||||||
),
|
|
||||||
|
|
||||||
filterBy(opts) {
|
filterBy(opts) {
|
||||||
this.setProperties(
|
this.setProperties(
|
||||||
@ -48,7 +46,7 @@ export default RestModel.extend({
|
|||||||
);
|
);
|
||||||
|
|
||||||
return this.findItems();
|
return this.findItems();
|
||||||
},
|
}
|
||||||
|
|
||||||
@discourseComputed("baseUrl", "filterParam", "actingUsername")
|
@discourseComputed("baseUrl", "filterParam", "actingUsername")
|
||||||
nextFindUrl() {
|
nextFindUrl() {
|
||||||
@ -62,17 +60,17 @@ export default RestModel.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return findUrl;
|
return findUrl;
|
||||||
},
|
}
|
||||||
|
|
||||||
@discourseComputed("loaded", "content.[]")
|
@discourseComputed("loaded", "content.[]")
|
||||||
noContent(loaded, content) {
|
noContent(loaded, content) {
|
||||||
return loaded && content.length === 0;
|
return loaded && content.length === 0;
|
||||||
},
|
}
|
||||||
|
|
||||||
@discourseComputed("nextFindUrl", "lastLoadedUrl")
|
@discourseComputed("nextFindUrl", "lastLoadedUrl")
|
||||||
canLoadMore() {
|
canLoadMore() {
|
||||||
return this.nextFindUrl !== this.lastLoadedUrl;
|
return this.nextFindUrl !== this.lastLoadedUrl;
|
||||||
},
|
}
|
||||||
|
|
||||||
remove(userAction) {
|
remove(userAction) {
|
||||||
// 1) remove the user action from the child groups
|
// 1) remove the user action from the child groups
|
||||||
@ -93,7 +91,7 @@ export default RestModel.extend({
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.setProperties({ content, itemsLoaded: content.length });
|
this.setProperties({ content, itemsLoaded: content.length });
|
||||||
},
|
}
|
||||||
|
|
||||||
findItems() {
|
findItems() {
|
||||||
if (!this.canLoadMore) {
|
if (!this.canLoadMore) {
|
||||||
@ -130,5 +128,5 @@ export default RestModel.extend({
|
|||||||
lastLoadedUrl: findUrl,
|
lastLoadedUrl: findUrl,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user