feat(ui-flow): unified poll and schedule IPC with composer focus (Phase 674)

Route vote-poll/close-poll and scheduled message handlers to platform APIs;
emit legacy DM events for backward compat and composer-focus-channel after
poll/schedule actions.
This commit is contained in:
Raven Scott
2026-06-02 22:18:44 -04:00
parent dfba4a33c6
commit b091f27517
+44 -21
View File
@@ -1038,10 +1038,13 @@ async function dispatchUiMessage (platform, msg, hooks = {}) {
pushState() pushState()
return true return true
} }
if (t === 'vote-dm-poll') { if (t === 'vote-dm-poll' || t === 'vote-poll') {
const out = await platform.voteDmPoll(msg.messageId, msg.optionIndex, msg.voted) const out = await platform.votePoll(msg.messageId, msg.optionIndex, msg.voted)
send({ type: 'dm-poll-voted', messageId: msg.messageId, optionIndex: msg.optionIndex, result: out }) send({ type: 'poll-voted', messageId: msg.messageId, optionIndex: msg.optionIndex, result: out })
pushState() pushState()
if (platform.activeChannelId) {
send({ type: 'composer-focus-channel', channelId: platform.activeChannelId })
}
return true return true
} }
if (t === 'edit-dm-poll') { if (t === 'edit-dm-poll') {
@@ -1053,10 +1056,13 @@ async function dispatchUiMessage (platform, msg, hooks = {}) {
pushState() pushState()
return true return true
} }
if (t === 'close-dm-poll') { if (t === 'close-dm-poll' || t === 'close-poll') {
const out = await platform.closeDmPoll(msg.messageId) const out = await platform.closePoll(msg.messageId)
send({ type: 'dm-poll-closed', messageId: msg.messageId, result: out }) send({ type: 'poll-closed', messageId: msg.messageId, result: out })
pushState() pushState()
if (platform.activeChannelId) {
send({ type: 'composer-focus-channel', channelId: platform.activeChannelId })
}
return true return true
} }
if (t === 'delete-dm-poll') { if (t === 'delete-dm-poll') {
@@ -1065,47 +1071,64 @@ async function dispatchUiMessage (platform, msg, hooks = {}) {
pushState() pushState()
return true return true
} }
if (t === 'create-dm-scheduled-message') { if (t === 'create-dm-scheduled-message' || t === 'create-scheduled-message') {
const out = await platform.createDmScheduledMessage({ const out = await platform.scheduleMessage({
content: msg.content, content: msg.content,
sendAt: msg.sendAt, sendAt: msg.sendAt,
timezone: msg.timezone, timezone: msg.timezone,
recurrence: msg.recurrence recurrence: msg.recurrence
}) })
send({ type: 'dm-scheduled-message-created', result: out }) send({ type: 'scheduled-message-created', result: out })
if (platform.mode === 'dm') send({ type: 'dm-scheduled-message-created', result: out })
pushState() pushState()
if (platform.activeChannelId) {
send({ type: 'composer-focus-channel', channelId: platform.activeChannelId })
}
return true return true
} }
if (t === 'list-dm-scheduled-messages') { if (t === 'list-dm-scheduled-messages' || t === 'list-scheduled-messages') {
const out = await platform.listDmScheduledMessages({ const out = await platform.listScheduledMessages({
channelId: msg.channelId || null, channelId: msg.channelId || null,
includeSent: !!msg.includeSent includeSent: !!msg.includeSent
}) })
send({ type: 'dm-scheduled-messages', items: out }) send({ type: 'scheduled-messages', items: out })
if (platform.mode === 'dm') send({ type: 'dm-scheduled-messages', items: out })
pushState() pushState()
return true return true
} }
if (t === 'update-dm-scheduled-message') { if (t === 'update-dm-scheduled-message' || t === 'update-scheduled-message') {
const out = await platform.updateDmScheduledMessage(msg.scheduleId, { const out = await platform.updateScheduledMessage(msg.scheduleId, {
content: msg.content, content: msg.content,
sendAt: msg.sendAt, sendAt: msg.sendAt,
timezone: msg.timezone, timezone: msg.timezone,
recurrence: msg.recurrence recurrence: msg.recurrence
}) })
send({ type: 'dm-scheduled-message-updated', result: out }) send({ type: 'scheduled-message-updated', result: out })
if (platform.mode === 'dm') send({ type: 'dm-scheduled-message-updated', result: out })
pushState() pushState()
if (platform.activeChannelId) {
send({ type: 'composer-focus-channel', channelId: platform.activeChannelId })
}
return true return true
} }
if (t === 'cancel-dm-scheduled-message') { if (t === 'cancel-dm-scheduled-message' || t === 'cancel-scheduled-message') {
const out = await platform.cancelDmScheduledMessage(msg.scheduleId) const out = await platform.cancelScheduledMessage(msg.scheduleId)
send({ type: 'dm-scheduled-message-cancelled', result: out }) send({ type: 'scheduled-message-cancelled', result: out })
if (platform.mode === 'dm') send({ type: 'dm-scheduled-message-cancelled', result: out })
pushState() pushState()
if (platform.activeChannelId) {
send({ type: 'composer-focus-channel', channelId: platform.activeChannelId })
}
return true return true
} }
if (t === 'send-now-dm-scheduled-message') { if (t === 'send-now-dm-scheduled-message' || t === 'send-now-scheduled-message') {
const out = await platform.sendNowDmScheduledMessage(msg.scheduleId) const out = await platform.sendNowScheduledMessage(msg.scheduleId)
send({ type: 'dm-scheduled-message-sent', result: out }) send({ type: 'scheduled-message-sent', result: out })
if (platform.mode === 'dm') send({ type: 'dm-scheduled-message-sent', result: out })
pushState() pushState()
if (platform.activeChannelId) {
send({ type: 'composer-focus-channel', channelId: platform.activeChannelId })
}
return true return true
} }
if (t === 'stage-voice-note') { if (t === 'stage-voice-note') {