diff --git a/apps/www/src/client/App.tsx b/apps/www/src/client/App.tsx index 8f75d19..e4ab1a6 100644 --- a/apps/www/src/client/App.tsx +++ b/apps/www/src/client/App.tsx @@ -1709,15 +1709,13 @@ function RoomDetail({ return ( <>
-
- {/* 512 rather than the list's 256: this one is displayed large. Both are sizes - the img worker allows, so each is a cached variant. */} - - onRoomChange({ ...room, ImageName: imageName })} - /> -
+ {/* 512 rather than the list's 256: this one is displayed large. Both are sizes + the img worker allows, so each is a cached variant. */} + onRoomChange({ ...room, ImageName: imageName })} + />

^{room.Name}

@@ -2005,71 +2003,68 @@ function BlobUpload({ const IMAGE_TYPES = new Set(['image/jpeg', 'image/png']) /** - * Replace a room's thumbnail with a picture from disk. + * The room's thumbnail, which is also the control that replaces it: clicking the picture + * opens the file picker, and the picked file uploads straight away. * * Same two steps as the scene-data upload, with a different `FileType`: the bytes go to * `storage` under the Image type, and the key it hands back is put to the room's * `…/image` route as `imageName`. In game the only way to set this is to take a photo in * the room, so this is how an owner gets a picture they made elsewhere onto the room. * - * Unlike the scene-data form there is no publish step: the image is live the moment the - * route answers, for everyone browsing rooms. The hero above redraws from the new + * There is no submit step because there is no publish step: the image is live the moment + * the route answers, for everyone browsing rooms. The picture redraws from the new * `ImageName` straight away — `img` caches by key and the key is new, so nothing stale * can be served. */ function RoomImageUpload({ roomId, + src, onImageChange, }: { roomId: number + src: string onImageChange: (imageName: string) => void }) { - const [file, setFile] = useState(null) - const input = useRef(null) const { pending, error, done, run } = useAction() return ( -
{ - e.preventDefault() - if (!file) return - void run(async () => { - if (!IMAGE_TYPES.has(file.type)) { - throw new Error('Choose a JPEG or PNG image.') - } - const imageName = await uploadToStorage(file, FILE_TYPE_IMAGE) - await setRoomImage(roomId, imageName) - onImageChange(imageName) - setFile(null) - if (input.current) input.current.value = '' - return 'Image replaced — it shows in game now.' - }) - }} - > -

- Replace image -

-

- A JPEG or PNG, landscape (3:2) like a photo taken in game. It goes live as soon as it - uploads. -

-