Working supabase structure

This commit is contained in:
2025-12-23 15:24:59 +01:00
parent b629b9a6e2
commit a39c4fa26d
10 changed files with 52 additions and 260 deletions
+5 -8
View File
@@ -8,6 +8,7 @@ import { get, Response } from "@/lib/request";
import { Channel, Server } from "@/types/types";
import Cookies from "js-cookie";
import { toast } from "sonner";
import { getProfileById } from "@/actions/get-profile";
export default function useApp(): App {
const node = useRef<WebSocket | null>(null);
@@ -58,17 +59,13 @@ export default function useApp(): App {
getUserById: async (id: string) => {
if (profiles[id] !== undefined) return profiles[id];
const onResponse = (res: Response<UserProfile>) => {
try {
const user = await getProfileById(id);
setProfiles((prev) => {
prev[id] = res.data as UserProfile;
prev[id] = user;
return prev;
});
};
try {
const user = await get(`/api/profile/?id=${id}`, onResponse);
onResponse(user);
return user.data;
return user;
} catch {
return null;
}