feat: direct client to first fave
This commit is contained in:
parent
81ad40520a
commit
7fb8026e28
|
@ -5,15 +5,21 @@ import React, {useEffect} from 'react';
|
||||||
import {useDispatch, useSelector} from 'react-redux';
|
import {useDispatch, useSelector} from 'react-redux';
|
||||||
import {Link} from 'react-router-dom';
|
import {Link} from 'react-router-dom';
|
||||||
|
|
||||||
import {userSelector} from '~/common/state/user';
|
import {favoriteChannelsSelector, userSelector} from '~/common/state/user';
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
const favorites = useSelector(favoriteChannelsSelector);
|
||||||
const user = useSelector(userSelector);
|
const user = useSelector(userSelector);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (user.id) {
|
let path;
|
||||||
dispatch(replace('/chat'));
|
if (favorites.length > 0) {
|
||||||
|
path = `/chat/r/${favorites[0]}`;
|
||||||
}
|
}
|
||||||
|
else if (user.id) {
|
||||||
|
path = '/chat';
|
||||||
|
}
|
||||||
|
dispatch(replace(path));
|
||||||
});
|
});
|
||||||
return (
|
return (
|
||||||
<div className="home">
|
<div className="home">
|
||||||
|
|
Loading…
Reference in New Issue
Block a user