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