mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-08 05:43:04 +00:00
Merge pull request #2257 from PR0M3TH3AN/claude/fix-logout-button-fxhy2
Deduplicate concurrent auth logout calls
This commit is contained in:
1 file changed
+16
-4
@@ -834,10 +834,6 @@ export function createAuthSessionCoordinator(deps) {
|
||||
const detail = await this.authService.logout();
|
||||
|
||||
if (detail && typeof detail === "object") {
|
||||
if (detail.__handled === true) {
|
||||
return detail;
|
||||
}
|
||||
|
||||
try {
|
||||
detail.__handled = true;
|
||||
} catch (error) {
|
||||
@@ -850,6 +846,22 @@ export function createAuthSessionCoordinator(deps) {
|
||||
},
|
||||
|
||||
async handleAuthLogout(detail = {}) {
|
||||
// Deduplicate concurrent calls — the auth:logout event listener may
|
||||
// fire-and-forget this method while requestLogout() also awaits it.
|
||||
// Return the in-flight promise so both callers resolve together.
|
||||
if (this._pendingLogoutPromise) {
|
||||
return this._pendingLogoutPromise;
|
||||
}
|
||||
|
||||
this._pendingLogoutPromise = this._executeAuthLogout(detail);
|
||||
try {
|
||||
return await this._pendingLogoutPromise;
|
||||
} finally {
|
||||
this._pendingLogoutPromise = null;
|
||||
}
|
||||
},
|
||||
|
||||
async _executeAuthLogout(detail = {}) {
|
||||
if (detail && typeof detail === "object") {
|
||||
try {
|
||||
detail.__handled = true;
|
||||
|
||||
Reference in new issue
Block a user