Skip to content

Commit 0e242c5

Browse files
committed
Minor Fixes
1 parent 5d872dc commit 0e242c5

File tree

7 files changed

+20
-20
lines changed

7 files changed

+20
-20
lines changed

code/client/src/services/communication/socket/socketCommunication.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export interface SocketCommunication {
1515
disconnect: ConnectionType;
1616
}
1717

18-
const socket = io(SERVER_URL);
18+
const socket = io(SERVER_URL, { autoConnect: false });
1919
const OPERATION_DELAY = 100;
2020
const operationEmitter = new OperationEmitter(socket, OPERATION_DELAY);
2121

code/client/src/ui/contexts/auth/AuthContext.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ export function AuthProvider({ children }: AuthProviderProps) {
5151
try {
5252
return await action();
5353
} catch (e) {
54-
console.log(e);
5554
publishError(e as Error);
5655
}
5756
};
@@ -67,11 +66,9 @@ export function AuthProvider({ children }: AuthProviderProps) {
6766

6867
const login = (email: string, password: string) =>
6968
handleAsyncAction(async () => {
70-
return signInWithEmailAndPassword(auth, email, password)
71-
.catch(() => {
72-
throw new Error('Invalid credentials');
73-
})
74-
.then(console.log);
69+
return signInWithEmailAndPassword(auth, email, password).catch(() => {
70+
throw new Error('Invalid credentials');
71+
});
7572
});
7673

7774
const logout = () => handleAsyncAction(() => signOut(auth));

code/client/src/ui/contexts/workspace/WorkspaceContext.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@ export function WorkspaceProvider({ children }: { children: React.ReactNode }) {
4242
setWorkspace(workspace);
4343
setResources(resources);
4444
}
45+
socket.connect();
4546
socket.emit('joinWorkspace', wid);
4647
fetchWorkspace().catch(publishError);
4748
return () => {
4849
socket.emit('leaveWorkspace');
50+
socket.disconnect();
4951
};
5052
// eslint-disable-next-line react-hooks/exhaustive-deps
5153
}, [wid, services, socket, publishError]);

code/client/src/ui/pages/auth/login/Login.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ function Login() {
2222

2323
useEffect(() => {
2424
if (currentUser) {
25-
console.log('currentUser', currentUser);
2625
navigate('/');
2726
}
2827
}, [currentUser, navigate]);
@@ -35,12 +34,8 @@ function Login() {
3534
const data = new FormData(e.currentTarget);
3635
const email = data.get('email') as string;
3736
const password = data.get('password') as string;
38-
console.log('login', email, password);
39-
const result = await login(email, password);
40-
console.log('result', result);
41-
// navigate('/');
37+
await login(email, password);
4238
} catch (e) {
43-
console.error(e);
4439
publishError(Error('Failed to login'));
4540
}
4641

code/client/src/ui/pages/auth/signup/Signup.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ function Signup() {
2222

2323
try {
2424
const data = new FormData(e.currentTarget);
25+
const username = data.get('username') as string;
2526
const email = data.get('email') as string;
2627
const password = data.get('password') as string;
2728
const confirmPassword = data.get('confirmPassword') as string;
2829
if (password !== confirmPassword) {
2930
publishError(Error('Passwords do not match'));
3031
return;
3132
}
32-
const result = await signup(email, password);
33-
console.log('result', result);
33+
await signup(username, email, password);
3434
navigate('/login');
3535
} catch (e) {
3636
console.error(e);

code/client/src/ui/pages/workspaces/Workspaces.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,22 @@ import { MdDelete } from 'react-icons/md';
77
import { useEffect, useState } from 'react';
88
import { sortWorkspaces } from '@domain/workspaces/utils';
99
import './Workspaces.scss';
10+
import { useCommunication } from '@ui/contexts/communication/useCommunication';
1011

1112
function Workspaces() {
1213
const { workspaces, operations } = useWorkspaces();
1314
const { publishError } = useError();
1415
const [selected, setSelected] = useState<string[]>([]);
1516
const [rows, setRows] = useState(workspaces);
17+
const { socket } = useCommunication();
1618

1719
useEffect(() => {
20+
socket.connect();
1821
setRows(workspaces);
19-
}, [workspaces]);
22+
return () => {
23+
socket.disconnect();
24+
};
25+
}, [socket, workspaces]);
2026

2127
return (
2228
<div className="workspaces">

code/server/src/databases/postgres/PostgresUsersDB.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ import { NotFoundError } from '@domain/errors/errors';
66

77
export class PostgresUsersDB implements UsersRepository {
88
async createUser(id: string, data: UserData): Promise<void> {
9-
await sql`insert into users ${sql({ id, ...data })}`;
9+
await sql`insert into "user" ${sql({ id, ...data })}`;
1010
}
1111

1212
async getUser(id: string): Promise<UserData> {
13-
const results: UserData[] = await sql`select * from users where id = ${id}`;
13+
const results: UserData[] = await sql`select * from "user" where id = ${id}`;
1414
if (isEmpty(results)) throw new NotFoundError('User not found');
1515
return results[0];
1616
}
1717

1818
async updateUser(id: string, newProps: Partial<UserData>): Promise<void> {
1919
const results = await sql`
20-
update users
20+
update "user"
2121
set ${sql(newProps)}
2222
where id = ${id}
2323
returning id
@@ -27,7 +27,7 @@ export class PostgresUsersDB implements UsersRepository {
2727

2828
async deleteUser(id: string): Promise<void> {
2929
const results = await sql`
30-
delete from users
30+
delete from "user"
3131
where id = ${id}
3232
returning id
3333
`;

0 commit comments

Comments
 (0)