mirror of
https://github.com/discourse/discourse.git
synced 2025-03-27 00:55:36 +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 RestModel from "discourse/models/rest";
|
||||
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({
|
||||
loaded: false,
|
||||
export default class UserStream extends RestModel {
|
||||
loaded = false;
|
||||
itemsLoaded = 0;
|
||||
content = [];
|
||||
|
||||
@on("init")
|
||||
_initialize() {
|
||||
this.setProperties({ itemsLoaded: 0, content: [] });
|
||||
},
|
||||
@url(
|
||||
"itemsLoaded",
|
||||
"user.username_lower",
|
||||
"/user_actions.json?offset=%@&username=%@"
|
||||
)
|
||||
baseUrl;
|
||||
|
||||
@discourseComputed("filter")
|
||||
filterParam(filter) {
|
||||
@ -27,13 +31,7 @@ export default RestModel.extend({
|
||||
}
|
||||
|
||||
return filter;
|
||||
},
|
||||
|
||||
baseUrl: url(
|
||||
"itemsLoaded",
|
||||
"user.username_lower",
|
||||
"/user_actions.json?offset=%@&username=%@"
|
||||
),
|
||||
}
|
||||
|
||||
filterBy(opts) {
|
||||
this.setProperties(
|
||||
@ -48,7 +46,7 @@ export default RestModel.extend({
|
||||
);
|
||||
|
||||
return this.findItems();
|
||||
},
|
||||
}
|
||||
|
||||
@discourseComputed("baseUrl", "filterParam", "actingUsername")
|
||||
nextFindUrl() {
|
||||
@ -62,17 +60,17 @@ export default RestModel.extend({
|
||||
}
|
||||
|
||||
return findUrl;
|
||||
},
|
||||
}
|
||||
|
||||
@discourseComputed("loaded", "content.[]")
|
||||
noContent(loaded, content) {
|
||||
return loaded && content.length === 0;
|
||||
},
|
||||
}
|
||||
|
||||
@discourseComputed("nextFindUrl", "lastLoadedUrl")
|
||||
canLoadMore() {
|
||||
return this.nextFindUrl !== this.lastLoadedUrl;
|
||||
},
|
||||
}
|
||||
|
||||
remove(userAction) {
|
||||
// 1) remove the user action from the child groups
|
||||
@ -93,7 +91,7 @@ export default RestModel.extend({
|
||||
});
|
||||
|
||||
this.setProperties({ content, itemsLoaded: content.length });
|
||||
},
|
||||
}
|
||||
|
||||
findItems() {
|
||||
if (!this.canLoadMore) {
|
||||
@ -130,5 +128,5 @@ export default RestModel.extend({
|
||||
lastLoadedUrl: findUrl,
|
||||
})
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user