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:
@@ -1038,10 +1038,13 @@ async function dispatchUiMessage (platform, msg, hooks = {}) {
|
||||
pushState()
|
||||
return true
|
||||
}
|
||||
if (t === 'vote-dm-poll') {
|
||||
const out = await platform.voteDmPoll(msg.messageId, msg.optionIndex, msg.voted)
|
||||
send({ type: 'dm-poll-voted', messageId: msg.messageId, optionIndex: msg.optionIndex, result: out })
|
||||
if (t === 'vote-dm-poll' || t === 'vote-poll') {
|
||||
const out = await platform.votePoll(msg.messageId, msg.optionIndex, msg.voted)
|
||||
send({ type: 'poll-voted', messageId: msg.messageId, optionIndex: msg.optionIndex, result: out })
|
||||
pushState()
|
||||
if (platform.activeChannelId) {
|
||||
send({ type: 'composer-focus-channel', channelId: platform.activeChannelId })
|
||||
}
|
||||
return true
|
||||
}
|
||||
if (t === 'edit-dm-poll') {
|
||||
@@ -1053,10 +1056,13 @@ async function dispatchUiMessage (platform, msg, hooks = {}) {
|
||||
pushState()
|
||||
return true
|
||||
}
|
||||
if (t === 'close-dm-poll') {
|
||||
const out = await platform.closeDmPoll(msg.messageId)
|
||||
send({ type: 'dm-poll-closed', messageId: msg.messageId, result: out })
|
||||
if (t === 'close-dm-poll' || t === 'close-poll') {
|
||||
const out = await platform.closePoll(msg.messageId)
|
||||
send({ type: 'poll-closed', messageId: msg.messageId, result: out })
|
||||
pushState()
|
||||
if (platform.activeChannelId) {
|
||||
send({ type: 'composer-focus-channel', channelId: platform.activeChannelId })
|
||||
}
|
||||
return true
|
||||
}
|
||||
if (t === 'delete-dm-poll') {
|
||||
@@ -1065,47 +1071,64 @@ async function dispatchUiMessage (platform, msg, hooks = {}) {
|
||||
pushState()
|
||||
return true
|
||||
}
|
||||
if (t === 'create-dm-scheduled-message') {
|
||||
const out = await platform.createDmScheduledMessage({
|
||||
if (t === 'create-dm-scheduled-message' || t === 'create-scheduled-message') {
|
||||
const out = await platform.scheduleMessage({
|
||||
content: msg.content,
|
||||
sendAt: msg.sendAt,
|
||||
timezone: msg.timezone,
|
||||
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()
|
||||
if (platform.activeChannelId) {
|
||||
send({ type: 'composer-focus-channel', channelId: platform.activeChannelId })
|
||||
}
|
||||
return true
|
||||
}
|
||||
if (t === 'list-dm-scheduled-messages') {
|
||||
const out = await platform.listDmScheduledMessages({
|
||||
if (t === 'list-dm-scheduled-messages' || t === 'list-scheduled-messages') {
|
||||
const out = await platform.listScheduledMessages({
|
||||
channelId: msg.channelId || null,
|
||||
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()
|
||||
return true
|
||||
}
|
||||
if (t === 'update-dm-scheduled-message') {
|
||||
const out = await platform.updateDmScheduledMessage(msg.scheduleId, {
|
||||
if (t === 'update-dm-scheduled-message' || t === 'update-scheduled-message') {
|
||||
const out = await platform.updateScheduledMessage(msg.scheduleId, {
|
||||
content: msg.content,
|
||||
sendAt: msg.sendAt,
|
||||
timezone: msg.timezone,
|
||||
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()
|
||||
if (platform.activeChannelId) {
|
||||
send({ type: 'composer-focus-channel', channelId: platform.activeChannelId })
|
||||
}
|
||||
return true
|
||||
}
|
||||
if (t === 'cancel-dm-scheduled-message') {
|
||||
const out = await platform.cancelDmScheduledMessage(msg.scheduleId)
|
||||
send({ type: 'dm-scheduled-message-cancelled', result: out })
|
||||
if (t === 'cancel-dm-scheduled-message' || t === 'cancel-scheduled-message') {
|
||||
const out = await platform.cancelScheduledMessage(msg.scheduleId)
|
||||
send({ type: 'scheduled-message-cancelled', result: out })
|
||||
if (platform.mode === 'dm') send({ type: 'dm-scheduled-message-cancelled', result: out })
|
||||
pushState()
|
||||
if (platform.activeChannelId) {
|
||||
send({ type: 'composer-focus-channel', channelId: platform.activeChannelId })
|
||||
}
|
||||
return true
|
||||
}
|
||||
if (t === 'send-now-dm-scheduled-message') {
|
||||
const out = await platform.sendNowDmScheduledMessage(msg.scheduleId)
|
||||
send({ type: 'dm-scheduled-message-sent', result: out })
|
||||
if (t === 'send-now-dm-scheduled-message' || t === 'send-now-scheduled-message') {
|
||||
const out = await platform.sendNowScheduledMessage(msg.scheduleId)
|
||||
send({ type: 'scheduled-message-sent', result: out })
|
||||
if (platform.mode === 'dm') send({ type: 'dm-scheduled-message-sent', result: out })
|
||||
pushState()
|
||||
if (platform.activeChannelId) {
|
||||
send({ type: 'composer-focus-channel', channelId: platform.activeChannelId })
|
||||
}
|
||||
return true
|
||||
}
|
||||
if (t === 'stage-voice-note') {
|
||||
|
||||
Reference in New Issue
Block a user