Fix infinite spinner when trying to restore Send state (#2449)

Clear state when re-opening popup
This commit is contained in:
Thomas Rittson 2022-03-18 09:01:22 +10:00 committed by GitHub
parent 7b08fc34ee
commit ae83a693f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 7 deletions

View File

@ -41,7 +41,11 @@ export class AppComponent implements OnInit {
private platformUtilsService: PlatformUtilsService
) {}
ngOnInit() {
async ngOnInit() {
// Component states must not persist between closing and reopening the popup, otherwise they become dead objects
// Clear them aggressively to make sure this doesn't occur
await this.clearComponentStates();
this.stateService.activeAccount.subscribe((userId) => {
this.activeUserId = userId;
});
@ -125,10 +129,7 @@ export class AppComponent implements OnInit {
(window as any).previousPopupUrl != null &&
(window as any).previousPopupUrl.startsWith("/tabs/")
) {
await this.stateService.setBrowserGroupingComponentState(null);
await this.stateService.setBrowserCipherComponentState(null);
await this.stateService.setBrowserSendComponentState(null);
await this.stateService.setBrowserSendTypeComponentState(null);
await this.clearComponentStates();
}
if (url.startsWith("/tabs/")) {
await this.stateService.setAddEditCipherInfo(null);
@ -250,4 +251,13 @@ export class AppComponent implements OnInit {
confirmed: confirmed.value,
});
}
private async clearComponentStates() {
await Promise.all([
this.stateService.setBrowserGroupingComponentState(null),
this.stateService.setBrowserCipherComponentState(null),
this.stateService.setBrowserSendComponentState(null),
this.stateService.setBrowserSendTypeComponentState(null),
]);
}
}

View File

@ -14,8 +14,7 @@ import { SyncService } from "jslib-common/abstractions/sync.service";
import { SendType } from "jslib-common/enums/sendType";
import { SendView } from "jslib-common/models/view/sendView";
import { BrowserSendComponentState } from "src/models/browserSendComponentState";
import { BrowserSendComponentState } from "../../models/browserSendComponentState";
import { StateService } from "../../services/abstractions/state.service";
import { PopupUtilsService } from "../services/popup-utils.service";