Reliably cancel an in-flight request
authorAlexander Ebert <ebert@woltlab.com>
Sun, 21 Apr 2024 13:33:14 +0000 (15:33 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 21 Apr 2024 13:33:14 +0000 (15:33 +0200)
commit5f09a02f2f3384abd74a28856c76a56e4cc7b687
tree1fb1032c232aacaa1cff985db50afce7cd19d582
parentf34efeaec533854927a147fe9d74f2ee6758f6c6
Reliably cancel an in-flight request

The `_previousXhr` property was not reliably set previously and the current in-flight was not visible unless a new request was dispatched.

The updated control flow in ca409b33e7550595d3ac2b50bb14b179237c13c9 effectively allowed for the `_previousXhr` property to be removed entirely. Working with `_xhr` directly allows to abort an in-flight request without dispatching a new request. This also fixes a third bug hidden in `_finalize()` that could have erased a later in-flight request in some cases.

See https://www.woltlab.com/community/thread/305578-halb-fehler-halb-wunsch/
ts/WoltLabSuite/Core/Ajax/Request.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/Request.js