import { echo } from './channels-config';
import { dispatch } from '@lib/redux/store';
import { updatedProfile } from '@lib/redux/actions/auth-actions';
import { getState } from '@lib/redux/store';


require('./channels-config');



export const subscribeToUserStateChannel = () => {
	const userState = getState()['userState'];
	echo.
		private(`user-state-channel.${userState?.awebkey}`)
		.listen('UserStateUpdated', res => {
			dispatch(updatedProfile({ data: res.userState }));
		});

};
