-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extract shell state into separate context #1824
Extract shell state into separate context #1824
Conversation
src/state/shell/index.tsx
Outdated
minimalShellMode, | ||
setMinimalShellMode: _setMinimalShellMode, | ||
isDrawerOpen, | ||
setIsDrawerOpen: _setIsDrawerOpen, | ||
isDrawerSwipeDisabled, | ||
setIsDrawerSwipeDisabled: _setIsDrawerSwipeDisabled, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could create callbacks for each of these too
@@ -38,7 +38,7 @@ export const FeedPage = observer(function FeedPageImpl({ | |||
const store = useStores() | |||
const pal = usePalette('default') | |||
const {isDesktop} = useWebMediaQueries() | |||
const [onMainScroll, isScrolledDown, resetMainScroll] = useOnMainScroll(store) | |||
const [onMainScroll, isScrolledDown, resetMainScroll] = useOnMainScroll() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer need to pass in the root store
let listener = {remove() {}} | ||
if (isAndroid) { | ||
listener = BackHandler.addEventListener('hardwareBackPress', () => { | ||
setIsDrawerOpen(false) | ||
return store.shell.closeAnyActiveElement() | ||
}) | ||
} | ||
return () => { | ||
listener() | ||
listener.remove() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needed to use useShellState
, so refactored this logic up a level into the component 👍
src/view/shell/index.web.tsx
Outdated
setIsDrawerOpen(false) | ||
store.shell.closeAnyActiveElement() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to do this here instead of in a centralized closeAnyActiveElement
. We will migrate this later on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah looks great
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the last comment — we need to separate setters from the state. Two contexts.
@@ -38,7 +39,7 @@ export function useMinimalShellMode() { | |||
|
|||
React.useEffect(() => { | |||
return autorun(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The autorun
here doesn't make sense anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets go
Pulls out drawer handling and minimal shell mode into its own React context provider and methods.
Couple notes: