fix: show warning on mobile webview before app quits (#1598)
This commit is contained in:
@@ -45,7 +45,9 @@ const WorkspaceSwitcherMenu: FunctionComponent<Props> = ({
|
||||
|
||||
const signoutAll = useCallback(async () => {
|
||||
const confirmed = await viewControllerManager.application.alertService.confirm(
|
||||
'Are you sure you want to sign out of all workspaces on this device?',
|
||||
`Are you sure you want to sign out of all workspaces on this device?${
|
||||
viewControllerManager.application.isNativeMobileWeb() && '<b> Your app will quit after sign out completes.</b>'
|
||||
}`,
|
||||
undefined,
|
||||
'Sign out all',
|
||||
ButtonType.Danger,
|
||||
@@ -60,6 +62,47 @@ const WorkspaceSwitcherMenu: FunctionComponent<Props> = ({
|
||||
viewControllerManager.accountMenuController.setSigningOut(true)
|
||||
}, [viewControllerManager])
|
||||
|
||||
const activateWorkspace = useCallback(
|
||||
async (descriptor: ApplicationDescriptor) => {
|
||||
if (viewControllerManager.application.isNativeMobileWeb()) {
|
||||
const confirmed = await viewControllerManager.application.alertService.confirm(
|
||||
'<b>The app needs to be restarted to activate the workspace</b>',
|
||||
undefined,
|
||||
'Quit app and activate workspace',
|
||||
ButtonType.Danger,
|
||||
)
|
||||
|
||||
if (confirmed) {
|
||||
void mainApplicationGroup.unloadCurrentAndActivateDescriptor(descriptor)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
void mainApplicationGroup.unloadCurrentAndActivateDescriptor(descriptor)
|
||||
},
|
||||
[mainApplicationGroup, viewControllerManager.application],
|
||||
)
|
||||
|
||||
const addAnotherWorkspace = useCallback(async () => {
|
||||
if (viewControllerManager.application.isNativeMobileWeb()) {
|
||||
const confirmed = await viewControllerManager.application.alertService.confirm(
|
||||
'<b>The app needs to be restarted to add another workspace</b>',
|
||||
undefined,
|
||||
'Quit app and add new workspace',
|
||||
ButtonType.Danger,
|
||||
)
|
||||
|
||||
if (confirmed) {
|
||||
void mainApplicationGroup.unloadCurrentAndCreateNewDescriptor()
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
void mainApplicationGroup.unloadCurrentAndCreateNewDescriptor()
|
||||
}, [mainApplicationGroup, viewControllerManager.application])
|
||||
|
||||
return (
|
||||
<Menu a11yLabel="Workspace switcher menu" className="px-0 focus:shadow-none" isOpen={isOpen}>
|
||||
{applicationDescriptors.map((descriptor) => (
|
||||
@@ -68,18 +111,13 @@ const WorkspaceSwitcherMenu: FunctionComponent<Props> = ({
|
||||
descriptor={descriptor}
|
||||
hideOptions={hideWorkspaceOptions}
|
||||
onDelete={destroyWorkspace}
|
||||
onClick={() => void mainApplicationGroup.unloadCurrentAndActivateDescriptor(descriptor)}
|
||||
onClick={() => activateWorkspace(descriptor)}
|
||||
renameDescriptor={(label: string) => mainApplicationGroup.renameDescriptor(descriptor, label)}
|
||||
/>
|
||||
))}
|
||||
<MenuItemSeparator />
|
||||
|
||||
<MenuItem
|
||||
type={MenuItemType.IconButton}
|
||||
onClick={() => {
|
||||
void mainApplicationGroup.unloadCurrentAndCreateNewDescriptor()
|
||||
}}
|
||||
>
|
||||
<MenuItem type={MenuItemType.IconButton} onClick={addAnotherWorkspace}>
|
||||
<Icon type="user-add" className="mr-2 text-neutral" />
|
||||
Add another workspace
|
||||
</MenuItem>
|
||||
|
||||
@@ -41,7 +41,15 @@ const ConfirmSignoutModal: FunctionComponent<Props> = ({ application, viewContro
|
||||
<AlertDialogLabel className="sk-h3 sk-panel-section-title">Sign out workspace?</AlertDialogLabel>
|
||||
<AlertDialogDescription className="sk-panel-row">
|
||||
<div>
|
||||
<p className="text-foreground">{STRING_SIGN_OUT_CONFIRMATION}</p>
|
||||
<p className="text-foreground">
|
||||
{STRING_SIGN_OUT_CONFIRMATION}
|
||||
{application.isNativeMobileWeb() && (
|
||||
<div className="font-bold">
|
||||
<br />
|
||||
Your app will quit after sign out completes.
|
||||
</div>
|
||||
)}
|
||||
</p>
|
||||
{showWorkspaceWarning && (
|
||||
<>
|
||||
<br />
|
||||
|
||||
Reference in New Issue
Block a user