Skip to content

Commit

Permalink
chat object type
Browse files Browse the repository at this point in the history
  • Loading branch information
danbastin committed Feb 25, 2025
1 parent 6732ce3 commit 98f8a53
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/app/_components/_sharedcomponents/Chat/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
Typography,
} from '@mui/material';
import { Send } from '@mui/icons-material';
import { IChatProps, IChatEntry } from './ChatTypes';
import { IChatProps, IChatEntry, IChatObject } from './ChatTypes';
import { useGame } from '@/app/_contexts/Game.context';

const Chat: React.FC<IChatProps> = ({
Expand All @@ -31,7 +31,7 @@ const Chat: React.FC<IChatProps> = ({
</Typography>
)
} else if (message[0].type === 'playerChat') {
const stringMessage = message.map((item: any) => typeof item === 'object' ? item.name : item).join('');
const stringMessage = message.map((item: IChatObject | string) => typeof item === 'object' ? item.name : item).join('');
return (
<Typography key={index} sx={styles.messageText}>
<Typography component="span" sx={{ color: connectedPlayer === message[0].id ? 'var(--initiative-blue)' : 'var(--initiative-red)' }}>
Expand All @@ -41,7 +41,7 @@ const Chat: React.FC<IChatProps> = ({
</Typography>
)
}
const stringMessage = message.map((item: any) => typeof item === 'object' ? item.name : item).join('');
const stringMessage = message.map((item: IChatObject | string) => typeof item === 'object' ? item.name : item).join('');
return (
<Typography key={index} sx={styles.messageText}>
{stringMessage}
Expand Down
6 changes: 6 additions & 0 deletions src/app/_components/_sharedcomponents/Chat/ChatTypes.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
export interface IChatObject {
name: string;
label: string;
uuid: string;
}

export interface IChatMessage {
name: string;
email: string;
Expand Down

0 comments on commit 98f8a53

Please sign in to comment.