* Enable ESLint no-unused-vars * Use FastImage instead of Image * Update fast-image patch to support multiple cookies * Fix ESLint errors * Have jest run timers for post_textbox tests * Feedback review * Update snapshots
55 lines
No EOL
1.8 KiB
JavaScript
55 lines
No EOL
1.8 KiB
JavaScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import AsyncStorage from '@react-native-community/async-storage';
|
|
import {PureComponent} from 'react';
|
|
import {Dimensions} from 'react-native';
|
|
|
|
import {DeviceTypes} from '@constants';
|
|
import EventEmitter from '@mm-redux/utils/event_emitter';
|
|
|
|
import mattermostManaged from 'app/mattermost_managed';
|
|
|
|
export default class ImageViewPort extends PureComponent {
|
|
state = {};
|
|
|
|
componentDidMount() {
|
|
this.mounted = true;
|
|
this.handlePermanentSidebar();
|
|
this.handleDimensions();
|
|
EventEmitter.on(DeviceTypes.PERMANENT_SIDEBAR_SETTINGS, this.handlePermanentSidebar);
|
|
Dimensions.addEventListener('change', this.handleDimensions);
|
|
}
|
|
|
|
componentWillUnmount() {
|
|
this.mounted = false;
|
|
EventEmitter.off(DeviceTypes.PERMANENT_SIDEBAR_SETTINGS, this.handlePermanentSidebar);
|
|
Dimensions.removeEventListener('change', this.handleDimensions);
|
|
}
|
|
|
|
handleDimensions = () => {
|
|
if (this.mounted) {
|
|
if (DeviceTypes.IS_TABLET) {
|
|
mattermostManaged.isRunningInSplitView().then((result) => {
|
|
const isSplitView = Boolean(result.isSplitView);
|
|
this.setState({isSplitView});
|
|
});
|
|
}
|
|
}
|
|
};
|
|
|
|
handlePermanentSidebar = async () => {
|
|
if (DeviceTypes.IS_TABLET && this.mounted) {
|
|
const enabled = await AsyncStorage.getItem(DeviceTypes.PERMANENT_SIDEBAR_SETTINGS);
|
|
this.setState({permanentSidebar: enabled === 'true'});
|
|
}
|
|
};
|
|
|
|
hasPermanentSidebar = () => {
|
|
return DeviceTypes.IS_TABLET && !this.state?.isSplitView && this.state?.permanentSidebar;
|
|
};
|
|
|
|
render() {
|
|
return null;
|
|
}
|
|
} |