- Add WS events: dm_channel_created, dm_channel_closed, friend_removed, channel_created/updated/deleted, server_updated - Fix first-ever DM: broadcast dm_channel_created to recipient - Add DELETE /api/dm/:id for closing DMs with re-open support - Wire Close DM button in sidebar - Fix dm_message_created for unknown channels (safety net) - Broadcast friend_removed on friend deletion - Sound system: track realtimeMessageEvents separately from API loads, play notification for messages in all channels, not just current - Optimistic updates: send/edit/delete messages appear instantly with rollback on failure, temp message deduplication on WS echo - Channel CRUD broadcasts to all server members - Server update broadcast on PATCH - Server join registers user in connectionManager immediately - Reconnect: only reload current channel, preserve other channel caches - Activity panel, right panel, member list toggle components
60 lines
1.6 KiB
TypeScript
60 lines
1.6 KiB
TypeScript
import React from 'react';
|
|
import { Routes, Route, Navigate } from 'react-router-dom';
|
|
import { LoginPage } from './components/auth/LoginPage';
|
|
import { RegisterPage } from './components/auth/RegisterPage';
|
|
import { AppLayout } from './components/layout/AppLayout';
|
|
import { useAuthStore } from './stores/authStore';
|
|
|
|
function ProtectedRoute({ children }: { children: React.ReactNode }) {
|
|
const token = useAuthStore((s) => s.token);
|
|
if (!token) return <Navigate to="/login" replace />;
|
|
return <>{children}</>;
|
|
}
|
|
|
|
function AuthRedirect({ children }: { children: React.ReactNode }) {
|
|
const token = useAuthStore((s) => s.token);
|
|
if (token) return <Navigate to="/channels/@me" replace />;
|
|
return <>{children}</>;
|
|
}
|
|
|
|
export function App() {
|
|
return (
|
|
<Routes>
|
|
<Route
|
|
path="/login"
|
|
element={
|
|
<AuthRedirect>
|
|
<LoginPage />
|
|
</AuthRedirect>
|
|
}
|
|
/>
|
|
<Route
|
|
path="/register"
|
|
element={
|
|
<AuthRedirect>
|
|
<RegisterPage />
|
|
</AuthRedirect>
|
|
}
|
|
/>
|
|
<Route
|
|
path="/channels/:serverId/:channelId?"
|
|
element={
|
|
<ProtectedRoute>
|
|
<AppLayout />
|
|
</ProtectedRoute>
|
|
}
|
|
/>
|
|
<Route
|
|
path="/join/:inviteCode"
|
|
element={
|
|
<ProtectedRoute>
|
|
<AppLayout />
|
|
</ProtectedRoute>
|
|
}
|
|
/>
|
|
<Route path="/" element={<Navigate to="/channels/@me" replace />} />
|
|
<Route path="*" element={<Navigate to="/channels/@me" replace />} />
|
|
</Routes>
|
|
);
|
|
}
|