-
- {children.map((child) => {
- if (!child.props) {
- return undefined;
- }
- const { label } = child.props;
-
- return (
- setActiveTab(tab)}
- />
- );
- })}
-
-
- {children.map((child) => {
- if (!child.props || child.props.label !== activeTab) {
- return undefined;
- }
- return child.props.children;
- })}
-
+ return (
+
setActiveTab(tab)}
+ />
+ );
+ })}
+
+
+ {children.map((child) => {
+ if (!child.props || child.props.label !== activeTab) {
+ return undefined;
+ }
+ return child.props.children;
+ })}
- );
-};
+
+);
export default Tabs;
diff --git a/src/components/windows/Chat.jsx b/src/components/windows/Chat.jsx
index 78ecf2a..1a9a2de 100644
--- a/src/components/windows/Chat.jsx
+++ b/src/components/windows/Chat.jsx
@@ -55,7 +55,7 @@ const Chat = ({
const {
chatChannel = 1,
inputMessage = '',
- } = useSelector((state) => state.windows.args[windowId]);
+ } = useSelector((state) => state.windows.args[windowId] || {});
const { stayScrolled } = useStayScrolled(listRef, {
initialScroll: Infinity,
@@ -101,7 +101,7 @@ const Chat = ({
if (!inptMsg) return;
// send message via websocket
SocketClient.sendChatMessage(inptMsg, chatChannel);
- dispatch(setChatInputMessage(''));
+ setChatInputMessage('');
}
/*
@@ -196,9 +196,7 @@ const Chat = ({
}}
id={`chtipt-${windowId}`}
value={inputMessage}
- onChange={(e) => dispatch(
- setChatInputMessage(e.target.value),
- )}
+ onChange={(e) => setChatInputMessage(e.target.value)}
autoComplete="off"
maxLength="200"
type="text"
diff --git a/src/components/windows/UserArea.jsx b/src/components/windows/UserArea.jsx
index 3a7b224..f3125c6 100644
--- a/src/components/windows/UserArea.jsx
+++ b/src/components/windows/UserArea.jsx
@@ -2,11 +2,14 @@
*
*/
-import React, { Suspense } from 'react';
+import React, { Suspense, useCallback } from 'react';
import { useSelector, useDispatch } from 'react-redux';
import { t } from 'ttag';
-import { fetchStats } from '../../store/actions';
+import {
+ fetchStats,
+ setWindowArgs,
+} from '../../store/actions';
import useInterval from '../hooks/interval';
import LogInArea from '../LogInArea';
import Tabs from '../Tabs';
@@ -22,8 +25,17 @@ const UserArea = ({ windowId }) => {
const name = useSelector((state) => state.user.name);
const userlvl = useSelector((state) => state.user.userlvl);
const lastStatsFetch = useSelector((state) => state.ranks.lastFetch);
+ const {
+ activeTab = t`Profile`,
+ } = useSelector((state) => state.windows.args[windowId] || {});
const dispatch = useDispatch();
+ const setActiveTab = useCallback((label) => {
+ dispatch(setWindowArgs(windowId, {
+ activeTab: label,
+ }));
+ }, [dispatch]);
+
useInterval(() => {
if (Date.now() - 300000 > lastStatsFetch) {
dispatch(fetchStats());
@@ -32,7 +44,7 @@ const UserArea = ({ windowId }) => {
return (