mirror of
https://github.com/djdevin/recflare.git
synced 2026-09-09 23:21:30 -07:00
fix custom loading screens, add private endpoint for match into instance
This commit is contained in:
+19
-12
@@ -1752,24 +1752,31 @@ const app = new Hono<App>()
|
||||
}
|
||||
)
|
||||
|
||||
// Add a load screen to a room (`LoadScreens[]` — the images shown while the room
|
||||
// loads). Auth-gated (401) and owner/co-owner-only (403). Body is the `imageName`
|
||||
// form field plus optional `title`/`subtitle`. Appends one
|
||||
// `{ ImageName, Title, Subtitle }` to the existing list and returns the updated
|
||||
// room in the `{ success, error, value }` envelope.
|
||||
// Set a room's load screen (`LoadScreens[]` — the image shown while the room loads).
|
||||
// Auth-gated (401) and owner/co-owner-only (403). Body is the `imageName` form field
|
||||
// plus optional `title`/`subtitle`. REPLACES the list with the single posted
|
||||
// `{ ImageName, Title, Subtitle }` and returns the updated room in the
|
||||
// `{ success, error, value }` envelope.
|
||||
//
|
||||
// The field is an array because the client's parser wants one, but the client only
|
||||
// ever renders (and only ever posts) a single screen — appending left the old screen
|
||||
// in slot 0 and the new one unreachable behind it, so setting a load screen appeared
|
||||
// to do nothing. Kept as an array so multi-screen support can land without a
|
||||
// migration.
|
||||
.put(
|
||||
'/rooms/:roomId{[0-9]+}/loadscreen',
|
||||
describeRoute({
|
||||
tags: ['Room settings'],
|
||||
summary: 'Add a load screen to a room',
|
||||
summary: 'Set a room’s load screen',
|
||||
description: [
|
||||
'APPENDS one `{ ImageName, Title, Subtitle }` to the room’s `LoadScreens` — the images',
|
||||
'shown while the room loads. There is no remove or replace counterpart. Owner or',
|
||||
'co-owner only (403 otherwise).',
|
||||
'REPLACES the room’s `LoadScreens` with the single posted `{ ImageName, Title,',
|
||||
'Subtitle }` — the image shown while the room loads. The field is an array (the',
|
||||
'client’s parser expects one) but the client only supports a single screen, so this',
|
||||
'never appends. Owner or co-owner only (403 otherwise).',
|
||||
].join(' '),
|
||||
security: AUTHED,
|
||||
parameters: [roomIdParam],
|
||||
requestBody: form(LoadScreenRequest, 'The load screen to append'),
|
||||
requestBody: form(LoadScreenRequest, 'The load screen to set'),
|
||||
responses: {
|
||||
200: json(RoomEnvelope, 'The updated room, or a rejection with `success: false`'),
|
||||
401: UNAUTHORIZED_RESPONSE,
|
||||
@@ -1793,8 +1800,8 @@ const app = new Hono<App>()
|
||||
const title = typeof body.title === 'string' ? body.title : ''
|
||||
const subtitle = typeof body.subtitle === 'string' ? body.subtitle : ''
|
||||
|
||||
const existing = Array.isArray(room.LoadScreens) ? (room.LoadScreens as unknown[]) : []
|
||||
const loadScreens = [...existing, { ImageName: imageName, Title: title, Subtitle: subtitle }]
|
||||
// The posted screen becomes the whole list — the client shows one load screen.
|
||||
const loadScreens = [{ ImageName: imageName, Title: title, Subtitle: subtitle }]
|
||||
const updated = await updateRoomFields(c.env.DB, roomId, room, { LoadScreens: loadScreens })
|
||||
await pushRoomUpdate(c, accountId, updated)
|
||||
return roomEnvelope(c, updated)
|
||||
|
||||
Reference in New Issue
Block a user