mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 14:13:21 +00:00
Don't use unnecessary promises
This commit is contained in:
parent
8865529b39
commit
759e360a1d
@ -163,18 +163,16 @@
|
|||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
this.update = Alpine.debounce(async () => {
|
this.update = Alpine.debounce(async () => {
|
||||||
await Promise.all(this.to_change).then(async (data) => {
|
{# Create the whole url before changing everything all at once #}
|
||||||
{# Create the whole url before changing everything all at once #}
|
let first = this.to_change.shift();
|
||||||
let first = data.shift();
|
let url = update_query_string(first.param, first.value, History.NONE);
|
||||||
let url = update_query_string(first[0], first[1], History.NONE);
|
this.to_change.forEach((value) => {
|
||||||
data.forEach((data) => {
|
url = update_query_string(value.param, value.value, History.NONE, url);
|
||||||
url = update_query_string(data[0], data[1], History.NONE, url);
|
|
||||||
})
|
|
||||||
update_query_string(first[0], first[1], this.pushstate, url);
|
|
||||||
await this.fetch_data(); {# reload data on form change #}
|
|
||||||
this.to_change = [];
|
|
||||||
this.pushstate = History.PUSH;
|
|
||||||
})
|
})
|
||||||
|
update_query_string(first.param, first.value, this.pushstate, url);
|
||||||
|
await this.fetch_data(); {# reload data on form change #}
|
||||||
|
this.to_change = [];
|
||||||
|
this.pushstate = History.PUSH;
|
||||||
}, 50);
|
}, 50);
|
||||||
|
|
||||||
let search_params = ["search", "department", "credit_type", "semester"];
|
let search_params = ["search", "department", "credit_type", "semester"];
|
||||||
@ -193,10 +191,7 @@
|
|||||||
});
|
});
|
||||||
search_params.concat(pagination_params).forEach((param) => {
|
search_params.concat(pagination_params).forEach((param) => {
|
||||||
this.$watch(param, async (value) => {
|
this.$watch(param, async (value) => {
|
||||||
this.to_change.push(new Promise((resolve) => {
|
this.to_change.push({ param: param, value: value })
|
||||||
resolve([param, value]);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
this.update();
|
this.update();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user