You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 3abc1d4
Browse filesBrowse the repository at this point in the historyBrowse files
feat(chat): send, store and open photo messages (#1681)
* feat(chat): send, store and open photo messages
The transport and storage half of chat photos, ported from
code-ios-app#959. Nothing in the app calls it yet; the UI follows in a
stacked PR.
- Encoding: photos are downscaled and encoded as JPEG down a quality
ladder of 0.9, 0.8, 0.7, 0.6 until they fit the blob policy, with EXIF
orientation baked in and a BlurHash for the placeholder. The
chat_media.json vectors are the iOS file, byte for byte.
- Encrypted chats: the blob is sealed with the shared-core ChatCipher,
uploaded with the `chat` field, and sent as EncryptedContent. A photo
that can't be opened loads as ChatPhotoUnavailable.
- Sending: one message per photo, each retried on its own. Finalization
polls GetBlobs every 2s, at most 30 times, counted only while the app
is in the foreground.
- Storage: pending uploads live in Room (schema 43) with the JPEG in
filesDir, so a send resumes after the app is killed.
- Loading: a Coil fetcher keyed `chat-media-<blobId>`, registered in
FlipcashApp.
- Fixes found on the way: captions were never sent, because `caption`
inside the builder's `apply` resolved to the builder's own field; and
a sent message disappeared when the stream delivered its stored copy
before the send returned, because clearing the pending row deleted by
its client id.
* fix(chat): keep a sent photo's progress bar up until its row is drawn
A photo that finished uploading while it sat in the composer confirms
within about 100 ms of the tap. Room hasn't drawn the pending row by
then, so the bubble's first frame already reads Sent and the bar never
shows. On the Seeker the new bubble landed as Delivered with no bar in
any frame.
The Sent stage now waits until 800 ms after the row was inserted. The
message is still confirmed in the database at once; only the bar's
phase waits, and a later post in the same batch isn't held up.
* fix(services): give blob storage calls a 15s deadline
BlobStorageApi queued every call with wait-for-ready and no deadline, so a
photo sent while the phone was offline never left "Sending": the reserve call
waited for a channel that could not resolve its host, and the upload's
retries and the bubble's "Not sent" never ran. Unary blob calls now fail
after 15s, the same deadline iOS puts on them (CallOptions.unaryDefault).
* fix(chat): upload a failed photo again when it is sent
A photo whose upload failed before the send (offline, say) went straight
to a failed row, because the send only waited on the existing upload.
The send now restarts a retryable failure, so the row shows Sending until
the upload settles.
0 commit comments