feat: implement live-sync for tasks, workspace note sharing, and document locking system
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 53s
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 53s
This commit is contained in:
1 parent
dccf1a91e3
commit
84e0b6a4bd
10 files changed
+1773
-110
No files matched your search
+39
-1
@@ -14,7 +14,14 @@ import {
|
||||
HelpCircle,
|
||||
} from 'lucide-react';
|
||||
import { AuthStatus, DashboardStats, SharedList, Thought, User } from './lib/types';
|
||||
import { api, clearToken, getToken, triggerHaptic } from './lib/api';
|
||||
import {
|
||||
api,
|
||||
clearToken,
|
||||
getToken,
|
||||
triggerHaptic,
|
||||
connectWebSocket,
|
||||
disconnectWebSocket,
|
||||
} from './lib/api';
|
||||
import {
|
||||
AVAILABLE_THEMES,
|
||||
initThemeOnBoot,
|
||||
@@ -193,6 +200,35 @@ export const App: React.FC = () => {
|
||||
};
|
||||
}, []);
|
||||
|
||||
// WebSocket Connection Management
|
||||
useEffect(() => {
|
||||
if (user && getToken()) {
|
||||
connectWebSocket();
|
||||
} else {
|
||||
disconnectWebSocket();
|
||||
}
|
||||
}, [user]);
|
||||
|
||||
// Refresh stats on task/doc real-time events
|
||||
useEffect(() => {
|
||||
const handleWs = (e: any) => {
|
||||
const msg = e.detail;
|
||||
if (!msg) return;
|
||||
if (
|
||||
typeof msg.event === 'string' &&
|
||||
(msg.event.startsWith('TASK_') || msg.event.startsWith('DOC_'))
|
||||
) {
|
||||
api.getMe().then((res) => {
|
||||
setStats(res.stats);
|
||||
}).catch(() => {});
|
||||
}
|
||||
};
|
||||
window.addEventListener('mindsift:ws', handleWs);
|
||||
return () => {
|
||||
window.removeEventListener('mindsift:ws', handleWs);
|
||||
};
|
||||
}, []);
|
||||
|
||||
// Close profile dropdown on outside click
|
||||
useEffect(() => {
|
||||
const handleClickOutside = (e: MouseEvent) => {
|
||||
@@ -239,6 +275,7 @@ export const App: React.FC = () => {
|
||||
|
||||
const handleLogout = async () => {
|
||||
triggerHaptic(20);
|
||||
disconnectWebSocket();
|
||||
clearToken();
|
||||
setUser(null);
|
||||
setShowProfileMenu(false);
|
||||
@@ -551,6 +588,7 @@ export const App: React.FC = () => {
|
||||
|
||||
{activeTab === 'workspace' && (
|
||||
<WorkspaceView
|
||||
currentUser={user}
|
||||
initialDocId={selectedDocId}
|
||||
onStatsChange={refreshAll}
|
||||
/>
|
||||
|
||||
Reference in new issue
Block a user