feat: retro Claude ekip konsolunu kur
This commit is contained in:
27
web/src/hooks/useLogs.js
Normal file
27
web/src/hooks/useLogs.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
export function useLogs(socket) {
|
||||
const [logs, setLogs] = useState([]);
|
||||
|
||||
useEffect(() => {
|
||||
const handleEntry = (entry) => setLogs((current) => [...current, entry]);
|
||||
const handleSnapshot = (entries) => setLogs(entries ?? []);
|
||||
|
||||
socket.on("log:entry", handleEntry);
|
||||
socket.on("log:snapshot", handleSnapshot);
|
||||
|
||||
return () => {
|
||||
socket.off("log:entry", handleEntry);
|
||||
socket.off("log:snapshot", handleSnapshot);
|
||||
};
|
||||
}, [socket]);
|
||||
|
||||
function clearLogs() {
|
||||
socket.emit("logs:clear", {}, () => {});
|
||||
}
|
||||
|
||||
return {
|
||||
logs,
|
||||
clearLogs
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user