fix: room case-insensitivity

This commit is contained in:
cha0s 2020-07-24 07:49:27 -05:00
parent d20466d10f
commit fd1de29781
2 changed files with 9 additions and 3 deletions

View File

@ -25,6 +25,7 @@
.channels__joinText { .channels__joinText {
flex-grow: 1; flex-grow: 1;
padding-left: 0.25em; padding-left: 0.25em;
text-transform: lowercase;
width: 0%; width: 0%;
&:focus { &:focus {
font-size: 1.5em; font-size: 1.5em;

View File

@ -1,6 +1,6 @@
import './chat.scss'; import './chat.scss';
import {goBack, replace} from 'connected-react-router'; import {goBack, push, replace} from 'connected-react-router';
import React, {useEffect, useRef} from 'react'; import React, {useEffect, useRef} from 'react';
import {useSelector, useDispatch} from 'react-redux'; import {useSelector, useDispatch} from 'react-redux';
@ -28,12 +28,17 @@ export default function Chat() {
useEffect(() => { useEffect(() => {
if (!allowedUser) { if (!allowedUser) {
dispatch(historyLength > 1 ? goBack() : replace('/')); dispatch(historyLength > 1 ? goBack() : replace('/'));
return;
}
if (channel !== channel.toLowerCase()) {
dispatch(push(`/chat${channel.toLowerCase()}`));
return;
} }
if (!hasChannel && validateChannel(channel)) { if (!hasChannel && validateChannel(channel)) {
dispatch(submitJoin({channel, id: user.id})); dispatch(submitJoin({channel: channel.toLowerCase(), id: user.id}));
} }
}); });
if (!allowedUser) { if (!allowedUser || !hasChannel) {
return null; return null;
} }
let origin; let origin;