Improve code

This commit is contained in:
2025-09-05 19:39:40 +03:00
Unverified
parent e50e94327d
commit 5ceca6778b
3 changed files with 67 additions and 18 deletions
+61 -11
View File
@@ -2,9 +2,9 @@
"version": "2.0.0", "version": "2.0.0",
"tasks": [ "tasks": [
{ {
"label": "Run", "label": "Backend",
"type": "shell", "type": "npm",
"command": "npm run dev", "script": "backend:run",
"options": { "options": {
"cwd": "${workspaceFolder}" "cwd": "${workspaceFolder}"
}, },
@@ -16,23 +16,73 @@
}, },
"group": { "group": {
"kind": "build" "kind": "build"
},
"isBackground": true
},
{
"label": "Frontend (Web)",
"type": "npm",
"script": "frontend:dev",
"options": {
"cwd": "${workspaceFolder}"
},
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
},
"group": {
"kind": "build",
},
"isBackground": true
},
{
"label": "Frontend (Electron)",
"type": "npm",
"script": "frontend:electron:dev",
"options": {
"cwd": "${workspaceFolder}"
},
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
},
"group": {
"kind": "build"
},
"isBackground": true
},
{
"label": "Web",
"dependsOn": ["Backend", "Frontend (Web)"],
"dependsOrder": "parallel",
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
} }
}, },
{ {
"label": "Run (Electron)", "label": "Electron",
"type": "shell", "dependsOn": ["Backend", "Frontend (Electron)"],
"command": "npm run dev:electron", "dependsOrder": "parallel",
"options": { "group": {
"cwd": "${workspaceFolder}" "kind": "build"
}, },
"presentation": { "presentation": {
"echo": true, "echo": true,
"reveal": "always", "reveal": "always",
"focus": false, "focus": false,
"panel": "shared" "panel": "shared"
},
"group": {
"kind": "build"
} }
} }
] ]
+1 -2
View File
@@ -2,7 +2,7 @@ import { useEffect, useCallback, useRef } from "react";
import { useAppState } from "../state"; import { useAppState } from "../state";
import { request, websocket } from "../../websocket"; import { request, websocket } from "../../websocket";
import { API_BASE_URL } from "../../core/config"; import { API_BASE_URL } from "../../core/config";
import type { Message, WebSocketMessage, User } from "../../core/types"; import type { Message, WebSocketMessage } from "../../core/types";
import { getAuthHeaders } from "../../auth/api"; import { getAuthHeaders } from "../../auth/api";
export function useChat() { export function useChat() {
@@ -87,7 +87,6 @@ export function useChat() {
break; break;
case 'newMessage': case 'newMessage':
if (response.data) { if (response.data) {
const isAuthor = response.data.username === user.currentUser?.username;
addMessage(response.data); addMessage(response.data);
} }
break; break;
+1 -1
View File
@@ -1,5 +1,5 @@
import { create } from "zustand"; import { create } from "zustand";
import type { Message, User, UserProfile, WebSocketMessage } from "../core/types"; import type { Message, User, WebSocketMessage } from "../core/types";
import { request } from "../websocket"; import { request } from "../websocket";
type Page = "login" | "register" | "chat" type Page = "login" | "register" | "chat"