feat: anonymous
This commit is contained in:
parent
e465db6e0e
commit
df22c68672
|
@ -1,13 +1,10 @@
|
||||||
import './chat--leftFriends.scss';
|
import './chat--leftFriends.scss';
|
||||||
|
|
||||||
import classnames from 'classnames';
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {useParams} from 'react-router-dom';
|
|
||||||
|
|
||||||
import Channel from './channel';
|
import Channel from './channel';
|
||||||
|
|
||||||
export default function ChatLeftRooms() {
|
export default function ChatLeftRooms() {
|
||||||
const {type, name} = useParams();
|
|
||||||
const favorites = ['BabeHasHiccups'];
|
const favorites = ['BabeHasHiccups'];
|
||||||
const friends = ['BabeHasHiccups', 'mystifired'].filter((channel) => -1 === favorites.indexOf(channel));
|
const friends = ['BabeHasHiccups', 'mystifired'].filter((channel) => -1 === favorites.indexOf(channel));
|
||||||
const favoritesActions = [
|
const favoritesActions = [
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
import './chat--leftRooms.scss';
|
import './chat--leftRooms.scss';
|
||||||
|
|
||||||
import classnames from 'classnames';
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {useParams} from 'react-router-dom';
|
|
||||||
|
|
||||||
import Channel from './channel';
|
import Channel from './channel';
|
||||||
|
|
||||||
export default function ChatLeftRooms() {
|
export default function ChatLeftRooms() {
|
||||||
const {type, name} = useParams();
|
|
||||||
const favorites = ['reddichat'];
|
const favorites = ['reddichat'];
|
||||||
const recent = ['reddichat', 'anonymous'].filter((channel) => -1 === favorites.indexOf(channel));
|
const recent = ['reddichat', 'anonymous'].filter((channel) => -1 === favorites.indexOf(channel));
|
||||||
const favoritesActions = [
|
const favoritesActions = [
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
import './chat.scss';
|
import './chat.scss';
|
||||||
|
|
||||||
import React, {useEffect, useRef} from 'react';
|
import React, {useEffect, useRef} from 'react';
|
||||||
import {useHistory} from 'react-router-dom';
|
import {useSelector} from 'react-redux';
|
||||||
|
import {useHistory, useParams} from 'react-router-dom';
|
||||||
|
|
||||||
import hydration from '~/common/hydration';
|
import {userSelector} from '~/common/state/user';
|
||||||
|
|
||||||
import useBreakpoints from './hooks/useBreakpoints';
|
import useBreakpoints from './hooks/useBreakpoints';
|
||||||
import ChatCenter from './chat--center';
|
import ChatCenter from './chat--center';
|
||||||
|
@ -12,14 +13,17 @@ import ChatRight from './chat--right';
|
||||||
|
|
||||||
export default function Chat() {
|
export default function Chat() {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
const {type, name} = useParams();
|
||||||
const ref = useRef(null);
|
const ref = useRef(null);
|
||||||
const {tablet} = useBreakpoints();
|
const {tablet} = useBreakpoints();
|
||||||
|
const user = useSelector(userSelector);
|
||||||
|
const allowedUser = !user.isAnonymous || ('r' === type && 'anonymous' === name);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!hydration('user')) {
|
if (!allowedUser) {
|
||||||
history.goBack();
|
history.goBack();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!hydration('user')) {
|
if (!allowedUser) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
let origin;
|
let origin;
|
||||||
|
@ -81,9 +85,9 @@ export default function Chat() {
|
||||||
{...(tablet ? {} : onPointerEvents)}
|
{...(tablet ? {} : onPointerEvents)}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
>
|
>
|
||||||
<ChatLeft />
|
{!user.isAnonymous && <ChatLeft />}
|
||||||
<ChatCenter />
|
<ChatCenter />
|
||||||
<ChatRight />
|
{!user.isAnonymous && <ChatRight />}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,12 @@ export default function Home() {
|
||||||
reddit will simply confirm your reddichat login and send you back here.
|
reddit will simply confirm your reddichat login and send you back here.
|
||||||
Then you can chat!
|
Then you can chat!
|
||||||
</p>
|
</p>
|
||||||
|
<p className="home__anonymous">
|
||||||
|
If you are exceptionally brave, you may choose to
|
||||||
|
{' '}
|
||||||
|
<a href="/chat/r/anonymous">chat anonymously</a>
|
||||||
|
.
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -67,3 +67,11 @@
|
||||||
font-size: 2em;
|
font-size: 2em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.home__anonymous {
|
||||||
|
line-height: 1.5em;
|
||||||
|
text-align: center;
|
||||||
|
a {
|
||||||
|
color: lighten($color-active, 20%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import {
|
||||||
createSlice,
|
createSlice,
|
||||||
} from '@reduxjs/toolkit';
|
} from '@reduxjs/toolkit';
|
||||||
|
|
||||||
import hydration from '../hydration';
|
import hydration from './hydration';
|
||||||
|
|
||||||
export const userSelector = (state) => state.user;
|
export const userSelector = (state) => state.user;
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ const slice = createSlice({
|
||||||
name: 'user',
|
name: 'user',
|
||||||
initialState: hydration('user') || {
|
initialState: hydration('user') || {
|
||||||
friends: {},
|
friends: {},
|
||||||
|
isAnonymous: true,
|
||||||
redditUsername: 'anonymous',
|
redditUsername: 'anonymous',
|
||||||
},
|
},
|
||||||
reducers: {
|
reducers: {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user