fix(permissions): drop the membership request when stepping back

Back only cleared the selected user; it left the membership request in
flight and did not advance the request counter, so nothing invalidated
it. On rejection the guard still matched, and the error landed on the
user step — reporting "Could not load users." over a user list that had
loaded fine, with a Retry that re-ran the wrong request.

Back now invalidates the in-flight request and clears the error and
spinner it owns. The rejection path also checks the selected user, so it
matches the success path rather than relying on the counter alone.
This commit is contained in:
harsh mahajan committed 2026-08-21 10:03:08 +05:30
1 parent 5c99615902
commit c354538173
1 file changed
+7 -1
+7 -1
View File
@@ -57,6 +57,12 @@
user = null;
memberships = undefined;
membershipOffset = 0;
// Stepping back abandons the membership request. Leaving it live lets its rejection
// land on the user step and report the user list as the thing that failed.
latestRequest++;
loadError = '';
isLoading = false;
}
function reset() {
@@ -113,7 +119,7 @@
if (requestId !== latestRequest || user?.$id !== requestedUserId) return;
memberships = response;
} catch (error) {
if (requestId !== latestRequest) return;
if (requestId !== latestRequest || user?.$id !== requestedUserId) return;
loadError = error.message;
addNotification({ type: 'error', message: error.message });
} finally {