Ingest live 3proxy traffic from access logs
This commit is contained in:
30
src/App.tsx
30
src/App.tsx
@@ -640,30 +640,38 @@ export default function App() {
|
||||
}
|
||||
|
||||
let cancelled = false;
|
||||
let intervalId: number | null = null;
|
||||
|
||||
const refreshSnapshot = async () => {
|
||||
try {
|
||||
const payload = await requestSnapshot(() =>
|
||||
fetch('/api/state', {
|
||||
headers: buildAuthHeaders(session.token),
|
||||
}),
|
||||
);
|
||||
|
||||
void requestSnapshot(() =>
|
||||
fetch('/api/state', {
|
||||
headers: buildAuthHeaders(session.token),
|
||||
}),
|
||||
)
|
||||
.then((payload) => {
|
||||
if (!cancelled && payload) {
|
||||
setSnapshot(payload);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
} catch (error) {
|
||||
if (error instanceof SessionExpiredError) {
|
||||
if (!cancelled) {
|
||||
resetSession();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Keep fallback snapshot for local UI and tests when backend is not running.
|
||||
});
|
||||
void refreshSnapshot();
|
||||
intervalId = window.setInterval(() => {
|
||||
void refreshSnapshot();
|
||||
}, 5000);
|
||||
|
||||
return () => {
|
||||
cancelled = true;
|
||||
if (intervalId !== null) {
|
||||
window.clearInterval(intervalId);
|
||||
}
|
||||
};
|
||||
}, [session]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user