feat: polls with live voting via WebSocket
- /poll command opens creation modal (2-10 options) - PollDisplay with vote bars, percentages, live WS updates - Backend: polls/poll_options/poll_votes tables, Create/Get/Vote endpoints - attachPolls enriches message list responses - POLL_UPDATE broadcast on vote for real-time sync
This commit is contained in:
@@ -188,6 +188,15 @@ export const useWebSocketStore = create<WebSocketState>((set, get) => ({
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'POLL_UPDATE': {
|
||||
const channelId = typeof payload.channel_id === 'string' ? payload.channel_id : '';
|
||||
const poll = isRecord(payload.poll) ? payload.poll : null;
|
||||
if (channelId && poll) {
|
||||
const updatePoll = useMessageStore.getState().updatePoll;
|
||||
updatePoll(channelId, poll as unknown as import('./message.ts').Poll);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'CHANNEL_CREATE': {
|
||||
if (isRecord(payload)) addChannel(payload as unknown as Channel);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user