Skip to content

Commit

Permalink
"style: Clean up whitespace and update socket message handling"
Browse files Browse the repository at this point in the history
  • Loading branch information
xDeFc0nx committed Jan 17, 2025
1 parent 1e1400f commit b7f37e8
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 10 deletions.
6 changes: 4 additions & 2 deletions client/biome.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@


{
"$schema": "https://biomejs.dev/schemas/1.8.0/schema.json",
"organizeImports": {
Expand Down Expand Up @@ -26,5 +28,5 @@
"rules": {
"recommended": true
}
}
}
},
2 changes: 0 additions & 2 deletions client/src/components/nav-user.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export function NavUser({
className="data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground"
>
<Avatar className="h-8 w-8 rounded-lg">
<AvatarImage src={user.avatar} alt={user.FirstName} />
<AvatarFallback className="rounded-lg">CN</AvatarFallback>
</Avatar>
<div className="grid flex-1 text-left text-sm leading-tight">
Expand All @@ -89,7 +88,6 @@ export function NavUser({
<DropdownMenuLabel className="p-0 font-normal">
<div className="flex items-center gap-2 px-1 py-1.5 text-left text-sm">
<Avatar className="h-8 w-8 rounded-lg">
<AvatarImage src={user.avatar} alt={user.FirstName} />
<AvatarFallback className="rounded-lg">CN</AvatarFallback>
</Avatar>
<div className="grid flex-1 text-left text-sm leading-tight">
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/ui/theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function ThemeChanger() {
}, []);

return (
<div className="absolute top-4 right-4">
<div className="absolute top-4 left-4">
<Button
variant="ghost"
size="icon"
Expand Down
8 changes: 4 additions & 4 deletions client/src/lib/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ export class WebSocketClient {

this.socket.onmessage = (event) => {
this.messageHandlers.forEach((handler) => handler(event.data));
const message = JSON.parse(event.data);
console.log(message)
if (message === "ping") {
if (this.socket.readyState === WebSocket.OPEN) {
const response = JSON.parse(event.data);
console.log(response)
if (response.message === "pong") {
if (this.socket.readyState === WebSocket.OPEN) {
this.socket.send(JSON.stringify({ Action: "pong" }));
}else {
console.error("Socket is not open. Cannot send pong.");
Expand Down
16 changes: 15 additions & 1 deletion client/src/pages/(secure)/settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,28 @@ export default function Index() {
ID: userData?.ID,
} );

}

socket.onMessage((msg)=>{

const response = JSON.parse(msg)

if (response.userData){


setUserData({
...userData,
FirstName: values.FirstName,
LastName: values.LastName,
Email: values.Email,
Country: values.Country,
});
}
if (response.Error){
toast.error(response.Error)

}
}
)}
} catch (error) {
console.error("Form submission error", error);
toast.error("Failed to submit the form. Please try again.");
Expand Down

0 comments on commit b7f37e8

Please sign in to comment.