mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-09 06:55:03 +00:00
40 lines
1.0 KiB
JavaScript
40 lines
1.0 KiB
JavaScript
import React, { useEffect } from 'react';
|
|
import useTelemetry from './useTelemetry';
|
|
import useIpcEvents from './useIpcEvents';
|
|
import useCollectionNextAction from './useCollectionNextAction';
|
|
import { useDispatch } from 'react-redux';
|
|
import { refreshScreenWidth } from 'providers/ReduxStore/slices/app';
|
|
import StyledWrapper from './StyledWrapper';
|
|
|
|
export const AppContext = React.createContext();
|
|
|
|
export const AppProvider = (props) => {
|
|
useTelemetry();
|
|
useIpcEvents();
|
|
useCollectionNextAction();
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
useEffect(() => {
|
|
dispatch(refreshScreenWidth());
|
|
}, []);
|
|
|
|
useEffect(() => {
|
|
const handleResize = () => {
|
|
dispatch(refreshScreenWidth());
|
|
};
|
|
|
|
window.addEventListener('resize', handleResize);
|
|
|
|
return () => window.removeEventListener('resize', handleResize);
|
|
}, []);
|
|
|
|
return (
|
|
<AppContext.Provider {...props} value="appProvider">
|
|
<StyledWrapper>{props.children}</StyledWrapper>
|
|
</AppContext.Provider>
|
|
);
|
|
};
|
|
|
|
export default AppProvider;
|