forked from Ivasoft/mattermost-mobile
* Push notifications entry point * Process android notification natively only if RN is not initialized * Database changes to store local channel viewed_at * EphemeralStore wait until screen removed * Move schedule session notification to utility * Fix channel remote & local actions + added actions for markChannelAsViewed & fetchMyChannel * Add fetchMyTeam remote action * Add dismissAllModalsAndPopToScreen to navigation * Improve post list component & add app state to re-trigger queries * Improve WS implementation * Handle push notification events * Fix postsInChannel since handler * Handle in-app notifications * Post list to listen to column changes * Track selected bottom tab in ephemeral store * add useIsTablet hook * in-app notifications on tablets
45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {useEffect, useState} from 'react';
|
|
import {AppState, NativeModules, useWindowDimensions} from 'react-native';
|
|
|
|
import {Device} from '@constants';
|
|
|
|
const {MattermostManaged} = NativeModules;
|
|
const isRunningInSplitView = MattermostManaged.isRunningInSplitView;
|
|
|
|
export function useSplitView() {
|
|
const [isSplitView, setIsSplitView] = useState(false);
|
|
const dimensions = useWindowDimensions();
|
|
|
|
useEffect(() => {
|
|
if (Device.IS_TABLET) {
|
|
isRunningInSplitView().then((result: {isSplitView: boolean}) => {
|
|
setIsSplitView(result.isSplitView);
|
|
});
|
|
}
|
|
}, [dimensions]);
|
|
|
|
return isSplitView;
|
|
}
|
|
|
|
export function useAppState() {
|
|
const [appState, setAppState] = useState(AppState.currentState);
|
|
|
|
useEffect(() => {
|
|
const listener = AppState.addEventListener('change', (nextState) => {
|
|
setAppState(nextState);
|
|
});
|
|
|
|
return () => listener.remove();
|
|
}, [appState]);
|
|
|
|
return appState;
|
|
}
|
|
|
|
export function useIsTablet() {
|
|
const isSplitView = useSplitView();
|
|
return Device.IS_TABLET && !isSplitView;
|
|
}
|