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 {Link} from 'react-router-dom';
|
||||
|
||||
import {userSelector} from '~/common/state/user';
|
||||
import {favoriteChannelsSelector, userSelector} from '~/common/state/user';
|
||||
|
||||
export default function Home() {
|
||||
const dispatch = useDispatch();
|
||||
const favorites = useSelector(favoriteChannelsSelector);
|
||||
const user = useSelector(userSelector);
|
||||
useEffect(() => {
|
||||
if (user.id) {
|
||||
dispatch(replace('/chat'));
|
||||
let path;
|
||||
if (favorites.length > 0) {
|
||||
path = `/chat/r/${favorites[0]}`;
|
||||
}
|
||||
else if (user.id) {
|
||||
path = '/chat';
|
||||
}
|
||||
dispatch(replace(path));
|
||||
});
|
||||
return (
|
||||
<div className="home">
|
||||
|
|
Loading…
Reference in New Issue
Block a user