-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Currently, the updateOrder method in the salesService looks as follows:
async updateOrder(order: Order, shift: number | null = null): Promise<Order> {
if (order._o === null && shift !== null) {
order = await this.newOrder(shift, order);
return order;
}
const result: AxiosResponse<_Order> = await this.apiService.put(
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
`/admin/sales/orders/${order._o.pk}/`,
// eslint-disable-next-line @typescript-eslint/ban-types
order.getAPIData() as {}
);
order.updateFromAPI(result.data);
return order;
}When there is a bad network, it can be possible that a new request is sent to the apiService while the old one has not yet been finished. This can result in orders suddenly changing. We should prevent such behavior and cancel the order.updateFromAPI(result.data); line when a newer request has been sent. So on sending an update, cancel any previous update.
Metadata
Metadata
Assignees
Labels
No labels