diff --git a/.prettierrc b/.prettierrc index cb8ee2671..c9cb3989c 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,6 +1,6 @@ { "singleQuote": true, "trailingComma": "all", - "printWidth": 100, + "printWidth": 120, "semi": false } diff --git a/app/assets/javascripts/Components/AccountMenu/WorkspaceSwitcher/WorkspaceMenuItem.tsx b/app/assets/javascripts/Components/AccountMenu/WorkspaceSwitcher/WorkspaceMenuItem.tsx index 38951fe7d..2e0bdb9a7 100644 --- a/app/assets/javascripts/Components/AccountMenu/WorkspaceSwitcher/WorkspaceMenuItem.tsx +++ b/app/assets/javascripts/Components/AccountMenu/WorkspaceSwitcher/WorkspaceMenuItem.tsx @@ -64,7 +64,8 @@ export const WorkspaceMenuItem: FunctionComponent = ({
diff --git a/app/assets/javascripts/Components/AccountMenu/WorkspaceSwitcher/WorkspaceSwitcherMenu.tsx b/app/assets/javascripts/Components/AccountMenu/WorkspaceSwitcher/WorkspaceSwitcherMenu.tsx index 677c2b20c..d59224cdd 100644 --- a/app/assets/javascripts/Components/AccountMenu/WorkspaceSwitcher/WorkspaceSwitcherMenu.tsx +++ b/app/assets/javascripts/Components/AccountMenu/WorkspaceSwitcher/WorkspaceSwitcherMenu.tsx @@ -1,9 +1,9 @@ import { ApplicationGroup } from '@/UIModels/ApplicationGroup' import { AppState } from '@/UIModels/AppState' -import { ApplicationDescriptor } from '@standardnotes/snjs' +import { ApplicationDescriptor, ButtonType } from '@standardnotes/snjs' import { observer } from 'mobx-react-lite' import { FunctionComponent } from 'preact' -import { useEffect, useState } from 'preact/hooks' +import { useCallback, useEffect, useState } from 'preact/hooks' import { Icon } from '@/Components/Icon' import { Menu } from '@/Components/Menu/Menu' import { MenuItem, MenuItemSeparator, MenuItemType } from '@/Components/Menu/MenuItem' @@ -18,9 +18,7 @@ type Props = { export const WorkspaceSwitcherMenu: FunctionComponent = observer( ({ mainApplicationGroup, appState, isOpen, hideWorkspaceOptions = false }) => { - const [applicationDescriptors, setApplicationDescriptors] = useState( - [], - ) + const [applicationDescriptors, setApplicationDescriptors] = useState([]) useEffect(() => { const removeAppGroupObserver = mainApplicationGroup.addApplicationChangeObserver(() => { @@ -33,6 +31,19 @@ export const WorkspaceSwitcherMenu: FunctionComponent = observer( } }, [mainApplicationGroup]) + const signoutAll = useCallback(async () => { + const confirmed = await appState.application.alertService.confirm( + 'Are you sure you want to sign out of all workspaces on this device?', + undefined, + 'Sign out all', + ButtonType.Danger, + ) + if (!confirmed) { + return + } + mainApplicationGroup.signOutAllWorkspaces().catch(console.error) + }, [mainApplicationGroup, appState.application.alertService]) + return ( {applicationDescriptors.map((descriptor) => ( @@ -43,23 +54,29 @@ export const WorkspaceSwitcherMenu: FunctionComponent = observer( appState.accountMenu.setSigningOut(true) }} onClick={() => { - mainApplicationGroup.loadApplicationForDescriptor(descriptor).catch(console.error) + mainApplicationGroup.loadApplicationForDescriptor(descriptor) }} - renameDescriptor={(label: string) => - mainApplicationGroup.renameDescriptor(descriptor, label) - } + renameDescriptor={(label: string) => mainApplicationGroup.renameDescriptor(descriptor, label)} /> ))} + { - mainApplicationGroup.addNewApplication().catch(console.error) + mainApplicationGroup.addNewApplication() }} > Add another workspace + + {!hideWorkspaceOptions && ( + + + Sign out all workspaces + + )} ) }, diff --git a/app/assets/javascripts/Components/ApplicationView/index.tsx b/app/assets/javascripts/Components/ApplicationView/index.tsx index af0eb42ac..e1379234d 100644 --- a/app/assets/javascripts/Components/ApplicationView/index.tsx +++ b/app/assets/javascripts/Components/ApplicationView/index.tsx @@ -55,7 +55,8 @@ export class ApplicationView extends PureComponent { override componentDidMount(): void { super.componentDidMount() - this.loadApplication().catch(console.error) + + void this.loadApplication() } async loadApplication() { @@ -180,16 +181,10 @@ export class ApplicationView extends PureComponent { )} {renderAppContents && ( <> -