Skip to content

Commit c7cf5fb

Browse files
committed
remove receipt logic
1 parent 1f20faf commit c7cf5fb

File tree

1 file changed

+2
-24
lines changed

1 file changed

+2
-24
lines changed

frontend/src/utils/AuthService.ts

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,7 @@ type AuthResponseEventDetail = {
3737
auth: AuthState;
3838
};
3939

40-
export type AuthReceivedEventDetail = {
41-
name: "auth_received";
42-
};
43-
44-
export type AuthEventDetail =
45-
| AuthRequestEventDetail
46-
| AuthResponseEventDetail
47-
| AuthReceivedEventDetail;
40+
export type AuthEventDetail = AuthRequestEventDetail | AuthResponseEventDetail;
4841

4942
export interface AuthEventMap {
5043
"btrix-need-login": CustomEvent<NeedLoginEventDetail>;
@@ -189,7 +182,7 @@ export default class AuthService {
189182
const authState =
190183
AuthService.getCurrentTabAuth() || (await this.getSharedSessionAuth());
191184

192-
if (authState) {
185+
if (!this.authState && authState) {
193186
this.saveLogin(authState);
194187
}
195188

@@ -219,12 +212,6 @@ export default class AuthService {
219212
const cb = ({ data }: MessageEvent<AuthEventDetail>) => {
220213
if (data.name === "responding_auth") {
221214
this.broadcastChannel?.removeEventListener("message", cb);
222-
223-
// Confirm receipt
224-
this.broadcastChannel?.postMessage({
225-
name: "auth_received",
226-
} satisfies AuthReceivedEventDetail);
227-
228215
resolve(data.auth);
229216
}
230217
};
@@ -329,19 +316,10 @@ export default class AuthService {
329316
AuthService.storage.removeItem();
330317
}
331318

332-
/**
333-
* Listens to broadcast channel events until confirmaion is received
334-
* that the newest window or tab is logged. Once the request is met
335-
* this broadcast channel is closed to prevent having too many
336-
* destinations, which may slow down postMessage performance.
337-
*/
338319
private startSharingSession() {
339320
this.broadcastChannel?.addEventListener(
340321
"message",
341322
({ data }: MessageEvent<AuthEventDetail>) => {
342-
if (data.name === "auth_received") {
343-
this.stopSharingSession();
344-
}
345323
if (data.name === "requesting_auth") {
346324
const auth = AuthService.getCurrentTabAuth();
347325

0 commit comments

Comments
 (0)