nheko
nheko copied to clipboard
Implement attachment captioning
Starting with Client-Server API v1.10 [0], the body field in messages of type m.image, m.audio, m.video and m.file can be used as the caption of the attachment. This is fact the way that Nheko rends captions on images, for example.
This commit introduces a field in the UploadHandles awaiting upload on the timeline's InputBar which holds a caption taken from the input text area. The decision is as follows:
- If text bar is empty or full of blanks, send all media with no caption
- If the text is an incomplete command, fail
- If there are no pending uploads, proceed as done previously (if there is no command recognized send the text, or try and execute the command and if it fails send the text)
- If there are pending uploads, only accept uploads if nothing resembling a command name is in the text area. That text becomes the caption for all pending media. Otherwise, try and execute the command, and, if it fails, send it as text.
While this workflow for captioning so far is a bit jank, it is the least effort implementation.
Links: [0]: https://spec.matrix.org/v1.10/client-server-api/#mimage
Do let me know if i missed anything important in the workflow of InputBar , i tried to get a feeling for what methods had to be called in what order to process the input text but there's always a chance i missed something important.