Added window dimensions to redux, listener in gabsocial.js

• Added:
- window dimensions to redux, listener in gabsocial.js
This commit is contained in:
mgabdev
2021-01-08 00:15:19 -05:00
parent a8443700a2
commit 8744868190
3 changed files with 40 additions and 1 deletions

View File

@@ -19,6 +19,7 @@ import {
connectStatusUpdateStream,
connectChatMessagesStream,
} from '../actions/streaming'
import { saveWindowDimensions } from '../actions/settings'
import { getLocale } from '../locales'
import initialState from '../initial_state'
import { me, isFirstSession } from '../initial_state'
@@ -37,6 +38,7 @@ store.dispatch(hydrateAction)
store.dispatch(fetchCustomEmojis())
store.dispatch(fetchPromotions())
store.dispatch(fetchChatConversationUnreadCount())
store.dispatch(saveWindowDimensions())
const mapStateToProps = (state) => ({
accountCreatedAt: !!me ? state.getIn(['accounts', me, 'created_at']) : undefined,
@@ -64,6 +66,17 @@ class GabSocialMount extends React.PureComponent {
if (shouldShow) this.setState({ shouldShow })
}
this.handleResize()
window.addEventListener('resize', this.handleResize, false)
}
componentWillUnmount () {
window.removeEventListener('resize', this.handleResize, false)
}
handleResize = () => {
this.props.dispatch(saveWindowDimensions())
}
render () {