diff --git a/src/app/api/slack/interactive/route.ts b/src/app/api/slack/interactive/route.ts index 9f9fd31..c7158a5 100644 --- a/src/app/api/slack/interactive/route.ts +++ b/src/app/api/slack/interactive/route.ts @@ -61,7 +61,12 @@ export async function POST(req: NextRequest) { if (payload.type !== "block_actions") return new NextResponse(null, { status: 200 }); const action = payload.actions?.[0]; - const [idStr, verb, arg] = String(action?.value ?? "").split(":"); + // A button carries `value`; a select carries it on the chosen option. The + // ratings moved to a select because four buttons became four full-width rows + // on Slack mobile, so both shapes have to resolve or rating silently stops + // working while sharing still does. + const rawValue = action?.value ?? action?.selected_option?.value ?? ""; + const [idStr, verb, arg] = String(rawValue).split(":"); const transactionId = Number(idStr); if (!Number.isInteger(transactionId)) { return NextResponse.json({ text: "Could not tell which order that was." }); diff --git a/src/lib/slack-blocks.ts b/src/lib/slack-blocks.ts index a37ab85..7578aa2 100644 --- a/src/lib/slack-blocks.ts +++ b/src/lib/slack-blocks.ts @@ -69,16 +69,25 @@ export function nudgeBlocks(s: NudgeState) { }, ], }, + // A select, not four buttons. Slack's mobile client gives every button in + // an actions block its own full-width row, so four ratings became four + // stacked bars and the card filled the screen. One select is one row and + // still one decision; the extra tap to open it is the price of a nudge you + // can read at a glance. { type: "actions", block_id: "rate", - elements: RATINGS.map((r) => ({ - type: "button", - action_id: `rate_${r}`, - text: { type: "plain_text", text: RATING_LABEL[r] }, - style: r === "never" ? "danger" : undefined, - value: `${s.transactionId}:rate:${r}`, - })), + elements: [ + { + type: "static_select", + action_id: "rate", + placeholder: { type: "plain_text", text: "How was it?" }, + options: RATINGS.map((r) => ({ + text: { type: "plain_text", text: RATING_LABEL[r] }, + value: `${s.transactionId}:rate:${r}`, + })), + }, + ], }, { type: "context",