Skip to content

Commit a87e528

Browse files
committed
Fix layout
1 parent 83f1619 commit a87e528

File tree

9 files changed

+61
-10
lines changed

9 files changed

+61
-10
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ jobs:
9292
key: app-build-${{ github.head_ref }}.${{ github.sha }}
9393

9494
- name: Configure AWS Credentials
95-
uses: aws-actions/configure-aws-credentials@v1
95+
uses: aws-actions/configure-aws-credentials@v4
9696
with:
9797
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
9898
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

src/components/Chat/components/Message/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ function Message({ message, user, selectUser }: Props) {
4848
</MsgAvatar>
4949
<MsgText sx={{ justifyContent: me ? 'flex-end' : 'inherit' }}>
5050
<UserText>
51-
<Typography color="secondary">{text}</Typography>
51+
<Typography color="secondary" sx={{ wordBreak: 'break-word' }}>
52+
{text}
53+
</Typography>
5254
<Box>
5355
<TextDate>
5456
{status === 'sent' && me ? <DoneIcon sx={icon} /> : null}

src/components/Chat/components/Message/styles.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const UserText = styled(Box)(({ theme }: { theme: Theme }) => ({
3434
[theme.breakpoints.down('sm')]: {
3535
margin: '0 1em',
3636
minWidth: '50%',
37-
maxWidth: '70%',
37+
maxWidth: '100%',
3838
},
3939
}));
4040

src/components/Chat/components/UserInGroup/index.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { memo } from 'react';
22
import Avatar from '@mui/material/Avatar';
3+
import { Typography } from '@mui/material';
34
import Badge from '@mui/material/Badge';
45
import Grid from '@mui/material/Grid';
56

@@ -9,9 +10,13 @@ import { getAvatarUrl } from 'utils/avatars';
910

1011
import { Box, TimeAgo, UserName, UserStatus, Btn } from './styles';
1112

12-
type Props = { user: UserData; selectUser: (user?: UserData) => void };
13+
type Props = {
14+
user: UserData;
15+
selectUser: (user?: UserData) => void;
16+
currentUser: boolean;
17+
};
1318

14-
function UserInGroup({ user, selectUser }: Props) {
19+
function UserInGroup({ user, selectUser, currentUser }: Props) {
1520
const { name, status, online, connectedDate, avatar } = user;
1621
const parsedDate = connectedDate ? new Date(connectedDate) : new Date();
1722

@@ -30,7 +35,14 @@ function UserInGroup({ user, selectUser }: Props) {
3035
</Badge>
3136
</Grid>
3237
<Grid item xs={0} sm={8}>
33-
<UserName>{name}</UserName>
38+
<UserName>
39+
{name}
40+
{currentUser ? (
41+
<Typography component="span" color="gray" marginLeft={1}>
42+
(you)
43+
</Typography>
44+
) : null}
45+
</UserName>
3446
<UserStatus color="secondary">{status}</UserStatus>
3547
</Grid>
3648
<Grid item xs={0} sm={2}>

src/components/Chat/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,12 @@ function Chat() {
100100
<Content>
101101
<Users>
102102
{users?.map((u) => (
103-
<UserInGroup user={u} key={u.id} selectUser={showUserHandler} />
103+
<UserInGroup
104+
user={u}
105+
key={u.id}
106+
selectUser={showUserHandler}
107+
currentUser={user?.id === u.id}
108+
/>
104109
))}
105110
<UsersSkeleton show={!users?.length} />
106111
</Users>

src/components/Chat/styles.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ export const Logo = styled(Box)(({ theme }: { theme: Theme }) => ({
126126
backgroundRepeat: 'no-repeat',
127127
marginRight: '1em',
128128
borderRadius: '7px',
129-
boxShadow: `0 0px 0.4em 0em inset ${theme.palette.border.dark}`,
129+
boxShadow: `0 2px 0.1em 0em ${theme.palette.border.dark}`,
130+
backgroundColor: 'white',
130131
}));
131132

132133
export const Title = styled(Typography)(({ theme }: { theme: Theme }) => ({

src/hooks/useChat.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,19 @@ const useChat = (currentUser: UserData | null, scrollBottom?: () => void) => {
4848
);
4949
setMessages(updatedMessages);
5050
scrollBottom?.();
51+
// const otherMsgs = updatedMessages.filter(({ me }) => !me);
52+
// const lastMsg = otherMsgs[otherMsgs.length - 1];
53+
54+
// if (lastMsg) {
55+
// const sender = users.find(({ id }) => id === lastMsg.userId);
56+
57+
// if (sender) {
58+
// showNotification(`New message from ${sender.name}`, {
59+
// body: lastMsg.text,
60+
// icon: '/images/logo.webp',
61+
// });
62+
// }
63+
// }
5164
});
5265
} else {
5366
setMessages([]);

src/utils/showNotification.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* eslint-disable @typescript-eslint/no-unused-vars */
2+
export default function showNotification(
3+
title: string,
4+
options: NotificationOptions
5+
): void {
6+
if (!('Notification' in window)) {
7+
return;
8+
}
9+
10+
if (Notification.permission === 'granted') {
11+
const notification = new Notification(title, options);
12+
} else if (Notification.permission !== 'denied') {
13+
Notification.requestPermission().then((permission) => {
14+
if (permission === 'granted') {
15+
const notification = new Notification(title, options);
16+
}
17+
});
18+
}
19+
}

src/utils/timeAgo.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import TimeAgo from 'javascript-time-ago';
22

3-
// English.
43
import en from 'javascript-time-ago/locale/en';
54

65
TimeAgo.addDefaultLocale(en);
76

8-
// Create formatter (English).
7+
// Create formatter
98
const timeAgo = new TimeAgo('en-US');
109

1110
export default function getTimeAgo(date: Date, short = true): string {

0 commit comments

Comments
 (0)