Skip to content

Commit

Permalink
refactor: account menu controller [skip e2e]
Browse files Browse the repository at this point in the history
  • Loading branch information
amanharwara committed Aug 10, 2023
1 parent 0802476 commit 5910a52
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@ import AccountMenu, { AccountMenuProps } from '../AccountMenu/AccountMenu'
import Icon from '../Icon/Icon'
import Popover from '../Popover/Popover'
import StyledTooltip from '../StyledTooltip/StyledTooltip'
import { observer } from 'mobx-react-lite'
import { AccountMenuController } from '@/Controllers/AccountMenu/AccountMenuController'

type Props = AccountMenuProps & {
isOpen: boolean
controller: AccountMenuController
hasError: boolean
toggleMenu: () => void
user: unknown
}

const AccountMenuButton = ({ hasError, isOpen, mainApplicationGroup, onClickOutside, toggleMenu, user }: Props) => {
const AccountMenuButton = ({ hasError, controller, mainApplicationGroup, onClickOutside, toggleMenu, user }: Props) => {
const buttonRef = useRef<HTMLButtonElement>(null)
const { show: isOpen } = controller

return (
<>
Expand Down Expand Up @@ -46,4 +49,4 @@ const AccountMenuButton = ({ hasError, isOpen, mainApplicationGroup, onClickOuts
)
}

export default AccountMenuButton
export default observer(AccountMenuButton)
10 changes: 1 addition & 9 deletions packages/web/src/javascripts/Components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ type State = {
showBetaWarning: boolean
showSyncResolution: boolean
newUpdateAvailable: boolean
showAccountMenu: boolean
offline: boolean
hasError: boolean
arbitraryStatusMessage?: string
Expand All @@ -62,7 +61,6 @@ class Footer extends AbstractComponent<Props, State> {
showBetaWarning: false,
showSyncResolution: false,
newUpdateAvailable: false,
showAccountMenu: false,
}

this.webEventListenerDestroyer = props.application.addWebEventObserver((event, data) => {
Expand Down Expand Up @@ -119,12 +117,6 @@ class Footer extends AbstractComponent<Props, State> {
arbitraryStatusMessage: message,
})
})

this.autorun(() => {
this.setState({
showAccountMenu: this.application.accountMenuController.show,
})
})
}

reloadUpgradeStatus() {
Expand Down Expand Up @@ -347,7 +339,7 @@ class Footer extends AbstractComponent<Props, State> {
<div className="sk-app-bar-item relative z-footer-bar-item ml-0 select-none">
<AccountMenuButton
hasError={this.state.hasError}
isOpen={this.state.showAccountMenu}
controller={this.application.accountMenuController}
mainApplicationGroup={this.props.applicationGroup}
onClickOutside={this.clickOutsideAccountMenu}
toggleMenu={this.accountMenuClickHandler}
Expand Down

0 comments on commit 5910a52

Please sign in to comment.