fix: unmount application view when ephemeral identifier changes

This commit is contained in:
Mo
2022-02-04 12:00:03 -06:00
parent cc2169152e
commit b549cc38bf
23 changed files with 98 additions and 101 deletions

View File

@@ -4,7 +4,6 @@ import { Component } from 'preact';
import { ApplicationView } from './ApplicationView';
type State = {
applications: WebApplication[];
activeApplication?: WebApplication;
};
@@ -15,36 +14,28 @@ type Props = {
export class ApplicationGroupView extends Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = {
applications: [],
};
props.mainApplicationGroup.addApplicationChangeObserver(() => {
this.setState({
activeApplication: props.mainApplicationGroup
.primaryApplication as WebApplication,
applications:
props.mainApplicationGroup.getApplications() as WebApplication[],
});
const activeApplication = props.mainApplicationGroup
.primaryApplication as WebApplication;
this.setState({ activeApplication });
});
props.mainApplicationGroup.initialize();
}
render() {
return (
<>
{this.state.applications.map((application) => {
if (application === this.state.activeApplication) {
return (
<div id={application.identifier}>
<ApplicationView
key={application.identifier}
mainApplicationGroup={this.props.mainApplicationGroup}
application={application}
/>
</div>
);
}
})}
{this.state.activeApplication && (
<div id={this.state.activeApplication.identifier}>
<ApplicationView
key={this.state.activeApplication.ephemeralIdentifier}
mainApplicationGroup={this.props.mainApplicationGroup}
application={this.state.activeApplication}
/>
</div>
)}
</>
);
}

View File

@@ -122,8 +122,8 @@ export class ChallengeModal extends PureComponent<Props, State> {
confirmButtonStyle: 'danger',
})
) {
await this.application.signOut();
this.dismiss();
this.application.signOut();
}
};
@@ -334,7 +334,7 @@ export class ChallengeModal extends PureComponent<Props, State> {
<div className="sk-panel-footer">
{this.state.forgotPasscode ? (
<>
<p className="sk-panel-row sk-p">
<p className="sk-panel-row sk-p text-center">
{this.state.hasAccount
? 'If you forgot your application passcode, your ' +
'only option is to clear your local data from this ' +