v0.8.8: bubble for Android 0.7.5 — the composer is always the small size; smoother scrolling past photos

Android: the composer used to shrink only with the keyboard up; now it is always that size (small text, tight padding, 60 dp buttons), and the keyboard only takes a line off the text box and the subtitle. Checked on the Rabbit with the dev app, at rest and typing.

Desktop: the chat and Get info show a smaller copy of each still picture (720 px long edge, made once into <dataDir>/thumbs) instead of decoding a phone's 4000 px photo every time a row scrolls in. Full size, Save and Copy still use the original; GIFs and pictures already that small are served as they are. Pictures decode off the main thread.
This commit is contained in:
2026-11-13 12:01:56 -08:00
parent a3017bdd50
commit dd994c5bc3
9 changed files with 62 additions and 25 deletions
+27
View File
@@ -9,6 +9,9 @@ import { extFor, guessMime } from '@shared/mime'
import type { MediaRef } from '@shared/types'
import type { MessageDb, NewMessage } from './db'
// Long edge of a thumbnail: twice the chat's largest picture box, for HiDPI.
const THUMB_EDGE = 720
export class MediaStore {
private inflight = new Map<string, Promise<MediaRef | undefined>>()
@@ -23,6 +26,30 @@ export class MediaStore {
return path.join(this.dir, path.basename(file))
}
// A smaller copy of a still picture for the chat and Get info, made once
// and kept in <dataDir>/thumbs (outside media/, so it never goes to the
// Rabbit or into backups as if it were an attachment). The chat shows
// pictures at most 300x360, so a phone's 4000 px photo was being decoded
// whole, again and again as rows scrolled in and out. Undefined = use the
// original: already small, animated (GIF), or a format nativeImage can't read.
async thumb(ref: MediaRef): Promise<string | undefined> {
if (!ref.file) return undefined
const mime = ref.mime ?? guessMime(ref.file) ?? ''
if (!mime.startsWith('image/') || mime === 'image/gif') return undefined
const png = mime === 'image/png' || mime === 'image/webp' // may be see-through
const out = path.join(this.dir, '..', 'thumbs', `${path.basename(ref.file)}.${THUMB_EDGE}.${png ? 'png' : 'jpg'}`)
if (fs.existsSync(out)) return out
const img = nativeImage.createFromPath(this.filePath(ref.file))
if (img.isEmpty()) return undefined
const { width, height } = img.getSize()
if (Math.max(width, height) <= THUMB_EDGE) return undefined
const scale = THUMB_EDGE / Math.max(width, height)
const small = img.resize({ width: Math.round(width * scale), height: Math.round(height * scale), quality: 'good' })
await fs.promises.mkdir(path.dirname(out), { recursive: true })
await fs.promises.writeFile(out, png ? small.toPNG() : small.toJPEG(85))
return out
}
save(data: Uint8Array, mime: string): string {
const file = `${crypto.createHash('sha1').update(data).digest('hex')}.${extFor(mime)}`
fs.mkdirSync(this.dir, { recursive: true })