mirror of
https://github.com/discourse/discourse.git
synced 2025-03-23 18:25:41 +08:00
DEV: Clarify site-setting category-list concurrency protection (#25614)
This commit is contained in:
parent
2af8f5708d
commit
250ce25ca3
@ -21,14 +21,22 @@ export default class CategoryList extends Component {
|
||||
return this.args.value.split("|").filter(Boolean);
|
||||
}
|
||||
|
||||
async updateSelectedCategories() {
|
||||
await this.pendingCategoriesRequest;
|
||||
this.selectedCategories = await Category.asyncFindByIds(this.categoryIds);
|
||||
async updateSelectedCategories(previousRequest) {
|
||||
const categories = await Category.asyncFindByIds(this.categoryIds);
|
||||
|
||||
// This is to prevent a race. We want to ensure that the update to
|
||||
// selectedCategories for this request happens after the update for the
|
||||
// previous request.
|
||||
await previousRequest;
|
||||
|
||||
this.selectedCategories = categories;
|
||||
}
|
||||
|
||||
@action
|
||||
valueChanged() {
|
||||
this.pendingCategoriesRequest = this.updateSelectedCategories();
|
||||
const previousRequest = this.pendingCategoriesRequest;
|
||||
this.pendingCategoriesRequest =
|
||||
this.updateSelectedCategories(previousRequest);
|
||||
}
|
||||
|
||||
@action
|
||||
|
Loading…
x
Reference in New Issue
Block a user