v0.8.0: bubble for Android 0.7.3 — Get info for everyone, with the chat's photos; no more "MMS Received"

Desktop:
- Click a chat's picture or name (or right-click it in the list → Get info…)
  for any chat, not only groups. One person: their picture, name, number
  (and its label), which of your numbers you're texting from, Add to
  contacts… if they aren't one. The number no longer sits in the header.
- Get info lists every photo and video in the chat as thumbnails, oldest
  first like the chat, scrolled to the newest. Each opens full size.
- The full-size view steps through the chat's photos with ← and → (or the
  side buttons) and says "n of N · date", from Get info or from the chat.
  Its glyphs were light gray on the white buttons; now the usual glyph color.

Both: voip.ms puts "MMS Received" as the text of a received picture that
came without words. Nobody wrote it, so it's dropped as messages come in,
and once from the ones already stored (only on messages with pictures, so
someone typing "MMS received" still shows).

Tried in a sandbox with made-up chats and generated pictures, driven over
DevTools: the header, Get info for a person and a group, thumbnails,
←/→ through 14 pictures, Esc closing the picture then the dialog, and the
v11 migration clearing a stored "MMS Received".
This commit is contained in:
2026-11-12 15:01:56 -08:00
parent 50ff68b6ee
commit 1106de26f2
15 changed files with 401 additions and 87 deletions
@@ -90,6 +90,12 @@ final class Store {
if (!hasColumn("read_state", "name_ts")) db.execSQL("ALTER TABLE read_state ADD COLUMN name_ts INTEGER"); if (!hasColumn("read_state", "name_ts")) db.execSQL("ALTER TABLE read_state ADD COLUMN name_ts INTEGER");
if (!hasColumn("read_state", "unread_ts")) db.execSQL("ALTER TABLE read_state ADD COLUMN unread_ts INTEGER"); if (!hasColumn("read_state", "unread_ts")) db.execSQL("ALTER TABLE read_state ADD COLUMN unread_ts INTEGER");
if (!hasColumn("read_state", "archived_ts")) db.execSQL("ALTER TABLE read_state ADD COLUMN archived_ts INTEGER"); if (!hasColumn("read_state", "archived_ts")) db.execSQL("ALTER TABLE read_state ADD COLUMN archived_ts INTEGER");
// voip.ms gives a received picture with no words the text "MMS Received";
// nobody wrote it, so it goes (once, for what came in before).
if (get("mms_received_stripped") == null) {
db.execSQL("UPDATE messages SET body = '' WHERE media_json IS NOT NULL AND lower(trim(body)) = 'mms received'");
set("mms_received_stripped", "1");
}
if (get("unread_floor") == null) set("unread_floor", String.valueOf(System.currentTimeMillis())); if (get("unread_floor") == null) set("unread_floor", String.valueOf(System.currentTimeMillis()));
} }
@@ -126,6 +126,8 @@ final class VoipMs {
JSONArray refs = new JSONArray(); JSONArray refs = new JSONArray();
for (String u : urls) refs.put(new JSONObject().put("url", u)); for (String u : urls) refs.put(new JSONObject().put("url", u));
m.mediaJson = refs.toString(); m.mediaJson = refs.toString();
// voip.ms's own stand-in text for a picture with no words, not the sender's.
if (m.body.trim().equalsIgnoreCase("MMS Received")) m.body = "";
} else if (Phone.charCount(m.body) > Phone.SMS_TEXT_LIMIT) { } else if (Phone.charCount(m.body) > Phone.SMS_TEXT_LIMIT) {
m.kind = "mms"; m.kind = "mms";
} }
+2 -2
View File
@@ -26,8 +26,8 @@ import sys
import zipfile import zipfile
from pathlib import Path from pathlib import Path
VERSION_NAME = "0.7.2" VERSION_NAME = "0.7.3"
VERSION_CODE = 10 VERSION_CODE = 11
PACKAGE = "me.teafry.voipmessages" PACKAGE = "me.teafry.voipmessages"
DEV_PACKAGE = PACKAGE + ".dev" DEV_PACKAGE = PACKAGE + ".dev"
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "voipms-desktop", "name": "voipms-desktop",
"productName": "bubble", "productName": "bubble",
"version": "0.7.2", "version": "0.8.0",
"description": "Signal-style desktop SMS client for voip.ms", "description": "Signal-style desktop SMS client for voip.ms",
"author": "trav <trav@teafry.me>", "author": "trav <trav@teafry.me>",
"private": true, "private": true,
Binary file not shown.
+1 -1
View File
@@ -1 +1 @@
{"version_name": "0.7.2", "version_code": 10, "package": "me.teafry.voipmessages"} {"version_name": "0.7.3", "version_code": 11, "package": "me.teafry.voipmessages"}
+5 -1
View File
@@ -6,7 +6,7 @@ import type { Conversation, Direction, MediaRef, Message, MessageKind, MessageSt
import { SNIPPET_END, SNIPPET_START } from '@shared/types' import { SNIPPET_END, SNIPPET_START } from '@shared/types'
import { fixVoipDst } from './voipms' import { fixVoipDst } from './voipms'
const SCHEMA_VERSION = 10 const SCHEMA_VERSION = 11
export interface ReadState { export interface ReadState {
did: string did: string
@@ -166,6 +166,10 @@ export class MessageDb {
// v10: when read/unread and archived last changed, so they merge with the Rabbit too. // v10: when read/unread and archived last changed, so they merge with the Rabbit too.
if (!rsCols.some((c) => c.name === 'unread_ts')) this.db.exec(`ALTER TABLE read_state ADD COLUMN unread_ts INTEGER`) if (!rsCols.some((c) => c.name === 'unread_ts')) this.db.exec(`ALTER TABLE read_state ADD COLUMN unread_ts INTEGER`)
if (!rsCols.some((c) => c.name === 'archived_ts')) this.db.exec(`ALTER TABLE read_state ADD COLUMN archived_ts INTEGER`) if (!rsCols.some((c) => c.name === 'archived_ts')) this.db.exec(`ALTER TABLE read_state ADD COLUMN archived_ts INTEGER`)
// v11: voip.ms gives a received picture with no words the text "MMS
// Received"; nobody wrote it, so it goes.
if (version >= 1 && version < 11)
this.db.exec(`UPDATE messages SET body = '' WHERE media_json IS NOT NULL AND lower(trim(body)) = 'mms received'`)
this.db.pragma(`user_version = ${SCHEMA_VERSION}`) this.db.pragma(`user_version = ${SCHEMA_VERSION}`)
} }
+4
View File
@@ -18,6 +18,8 @@ function parseYmd(s: string): number {
return Date.parse(s + 'T00:00:00Z') return Date.parse(s + 'T00:00:00Z')
} }
export const isMmsPlaceholder = (body: string): boolean => body.trim().toLowerCase() === 'mms received'
export function toNewMessage(r: RawSms): NewMessage { export function toNewMessage(r: RawSms): NewMessage {
const m: NewMessage = { const m: NewMessage = {
id: Number(r.id), id: Number(r.id),
@@ -34,6 +36,8 @@ export function toNewMessage(r: RawSms): NewMessage {
if (urls.length) { if (urls.length) {
m.kind = 'mms' m.kind = 'mms'
m.media = urls.map((url) => ({ url })) m.media = urls.map((url) => ({ url }))
// voip.ms's own stand-in text for a picture with no words, not the sender's.
if (isMmsPlaceholder(m.body)) m.body = ''
} else if (charCount(m.body) > SMS_TEXT_LIMIT) { } else if (charCount(m.body) > SMS_TEXT_LIMIT) {
m.kind = 'mms' m.kind = 'mms'
} }
+36 -15
View File
@@ -7,7 +7,7 @@ import { chatsWith, convName, dayLabel, sameDay, senderName, senderShortName } f
import { Avatar } from './Avatar' import { Avatar } from './Avatar'
import { Composer, type ComposerHandle } from './Composer' import { Composer, type ComposerHandle } from './Composer'
import { CloseIcon, DownIcon, SearchIcon, UpIcon } from './Icons' import { CloseIcon, DownIcon, SearchIcon, UpIcon } from './Icons'
import { Lightbox } from './Lightbox' import { conversationMedia, Lightbox } from './Lightbox'
import { MessageBubble } from './MessageBubble' import { MessageBubble } from './MessageBubble'
import { DEFAULT_QUICK_REACTIONS, reactionText, sameEmoji, type Reaction } from '@shared/reactions' import { DEFAULT_QUICK_REACTIONS, reactionText, sameEmoji, type Reaction } from '@shared/reactions'
import { foldConversation, type Version } from '@shared/edits' import { foldConversation, type Version } from '@shared/edits'
@@ -95,6 +95,7 @@ export function ChatView({ conv, contact, contactMap, conversations, onOpen, nam
const [hits, setHits] = useState<SearchHit[]>([]) const [hits, setHits] = useState<SearchHit[]>([])
const [hitIdx, setHitIdx] = useState(0) const [hitIdx, setHitIdx] = useState(0)
const [lightbox, setLightbox] = useState<{ id: number; index: number }>() const [lightbox, setLightbox] = useState<{ id: number; index: number }>()
const media = useMemo(() => conversationMedia(messages ?? []), [messages])
const [dragging, setDragging] = useState(false) const [dragging, setDragging] = useState(false)
const virtuoso = useRef<VirtuosoHandle>(null) const virtuoso = useRef<VirtuosoHandle>(null)
const searchInput = useRef<HTMLInputElement>(null) const searchInput = useRef<HTMLInputElement>(null)
@@ -281,22 +282,36 @@ export function ChatView({ conv, contact, contactMap, conversations, onOpen, nam
setHeaderMenu({ x: e.clientX, y: e.clientY }) setHeaderMenu({ x: e.clientX, y: e.clientY })
}} }}
> >
<Avatar number={conv.contact} contact={contact} size={36} /> {/* A clickable picture (#clickable): finger, tooltip, Tab, Enter/Space. */}
<div <div
className={`chat-title${group ? ' clickable' : ''}`} className="chat-avatar"
onClick={group ? onInfo : undefined} role="button"
title={group ? 'Get info' : undefined} tabIndex={0}
title="Get info"
aria-label="Get info"
onClick={onInfo}
onKeyDown={(e) => {
if (e.key !== 'Enter' && e.key !== ' ') return
e.preventDefault()
onInfo()
}}
> >
<Avatar number={conv.contact} contact={contact} size={36} />
</div>
{/* The number lives in Get info, not here. */}
<div className="chat-title clickable" onClick={onInfo} title="Get info">
<div className="chat-name">{name}</div> <div className="chat-name">{name}</div>
<div className="chat-sub"> {(group || smsDids.length > 1) && (
{group ? `${members.length} people` : contact ? formatNumber(conv.contact) : ''} <div className="chat-sub">
{smsDids.length > 1 && ( {group && `${members.length} people`}
<span className="chat-via"> {smsDids.length > 1 && (
{contact || group ? ' · ' : ''} <span className="chat-via">
<Via did={conv.did} gvNumber={gvNumber} /> {group ? ' · ' : ''}
</span> <Via did={conv.did} gvNumber={gvNumber} />
)} </span>
</div> )}
</div>
)}
</div> </div>
<button className="icon-btn" title="Search in chat (Ctrl+Shift+F)" onClick={openSearch}> <button className="icon-btn" title="Search in chat (Ctrl+Shift+F)" onClick={openSearch}>
<SearchIcon /> <SearchIcon />
@@ -392,7 +407,13 @@ export function ChatView({ conv, contact, contactMap, conversations, onOpen, nam
<Composer ref={composer} conv={conv} isNew={isNew} smsDids={smsDids} gvNumber={gvNumber} onChangeDid={onChangeDid} /> <Composer ref={composer} conv={conv} isNew={isNew} smsDids={smsDids} gvNumber={gvNumber} onChangeDid={onChangeDid} />
{dragging && <div className="drop-hint">Drop to attach</div>} {dragging && <div className="drop-hint">Drop to attach</div>}
{lightbox && <Lightbox {...lightbox} onClose={() => setLightbox(undefined)} />} {lightbox && (
<Lightbox
items={media}
start={Math.max(0, media.findIndex((x) => x.id === lightbox.id && x.index === lightbox.index))}
onClose={() => setLightbox(undefined)}
/>
)}
{reactionList && ( {reactionList && (
<ContextMenu <ContextMenu
x={reactionList.x} x={reactionList.x}
+154 -51
View File
@@ -1,12 +1,14 @@
import { useEffect, useState } from 'react' import { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'
import { formatNumber, groupMembers } from '@shared/phone' import { formatNumber, groupMembers, isGroup } from '@shared/phone'
import type { ContactInfo } from '@shared/types' import type { ContactInfo, Message } from '@shared/types'
import type { ConvKey } from '../App' import type { ConvKey } from '../App'
import { convName, displayName } from '../format' import { convName, displayName } from '../format'
import { Avatar } from './Avatar' import { Avatar } from './Avatar'
import { CloseIcon } from './Icons' import { CloseIcon } from './Icons'
import { Via } from './Via' import { Via } from './Via'
import { useAddContact } from './AddContact' import { useAddContact } from './AddContact'
import { conversationMedia, Lightbox, type MediaItem } from './Lightbox'
import { mediaSrc } from './MessageBubble'
interface Props { interface Props {
conv: ConvKey conv: ConvKey
@@ -16,16 +18,85 @@ interface Props {
onClose: () => void onClose: () => void
} }
// "Get info" for a group chat: who's in it, and a name of your own for it // Every picture and video in the chat as thumbnails, oldest first like the
// (kept on this computer only). // chat itself, scrolled to the newest. Each opens full size; ← → step through.
function MediaGrid({ conv }: { conv: ConvKey }) {
const [messages, setMessages] = useState<Message[]>()
const [open, setOpen] = useState<number>()
const [broken, setBroken] = useState<Set<string>>(new Set())
const grid = useRef<HTMLDivElement>(null)
useEffect(() => {
let cancelled = false
void window.api.getMessages(conv.did, conv.contact).then((m) => !cancelled && setMessages(m))
return () => {
cancelled = true
}
}, [conv.did, conv.contact])
const items = useMemo(() => conversationMedia(messages ?? []), [messages])
useLayoutEffect(() => {
if (grid.current) grid.current.scrollTop = grid.current.scrollHeight
}, [items])
if (!messages) return null
const key = (it: MediaItem): string => `${it.id}:${it.index}`
return (
<section>
<h3>
Media{items.length ? <span className="muted"> · {items.length}</span> : null}
</h3>
{items.length ? (
<div className="media-grid" ref={grid}>
{items.map((it, i) => (
<div
key={key(it)}
className="media-thumb"
role="button"
tabIndex={0}
title={`Open (${new Date(it.ts).toLocaleDateString(undefined, { dateStyle: 'medium' })})`}
aria-label="Open"
onClick={() => setOpen(i)}
onKeyDown={(e) => {
if (e.key !== 'Enter' && e.key !== ' ') return
e.preventDefault()
setOpen(i)
}}
>
{broken.has(key(it)) ? (
<span className="media-thumb-missing">Unavailable</span>
) : it.video ? (
<>
<video src={`${mediaSrc(it.id, it.index)}#t=0.1`} preload="metadata" muted onError={() => setBroken((b) => new Set(b).add(key(it)))} />
<span className="media-thumb-play" aria-hidden>
▶
</span>
</>
) : (
<img src={mediaSrc(it.id, it.index)} alt="" loading="lazy" draggable={false} onError={() => setBroken((b) => new Set(b).add(key(it)))} />
)}
</div>
))}
</div>
) : (
<p className="muted small">No photos or videos in this chat yet.</p>
)}
{open !== undefined && <Lightbox items={items} start={open} onClose={() => setOpen(undefined)} />}
</section>
)
}
// "Get info": for one person, their number and the photos you've traded; for
// a group, who's in it and a name of your own for it (kept on this computer only).
export function ConversationInfo({ conv, name, contactMap, gvNumber, onClose }: Props) { export function ConversationInfo({ conv, name, contactMap, gvNumber, onClose }: Props) {
const [draft, setDraft] = useState(name ?? '') const [draft, setDraft] = useState(name ?? '')
const group = isGroup(conv.contact)
const members = groupMembers(conv.contact) const members = groupMembers(conv.contact)
const membersName = convName(conv.contact, contactMap) const membersName = convName(conv.contact, contactMap)
const dirty = draft.trim() !== (name ?? '') const dirty = group && draft.trim() !== (name ?? '')
const addContact = useAddContact() const addContact = useAddContact()
const person = group ? undefined : contactMap.get(conv.contact)
useEffect(() => { useEffect(() => {
// The lightbox takes its own Escape first (and stops it there).
const onKey = (e: KeyboardEvent): void => { const onKey = (e: KeyboardEvent): void => {
if (e.key === 'Escape') onClose() if (e.key === 'Escape') onClose()
} }
@@ -39,66 +110,98 @@ export function ConversationInfo({ conv, name, contactMap, gvNumber, onClose }:
return ( return (
<div className="modal-backdrop" onMouseDown={(e) => e.target === e.currentTarget && onClose()}> <div className="modal-backdrop" onMouseDown={(e) => e.target === e.currentTarget && onClose()}>
<div className="modal conv-info" role="dialog" aria-label="Chat info"> <div className="modal conv-info" role="dialog" aria-label={group ? 'Chat info' : 'Contact info'}>
<header> <header>
<h2>Chat info</h2> <h2>{group ? 'Chat info' : 'Contact info'}</h2>
<button className="icon-btn" onClick={onClose} title="Close"> <button className="icon-btn" onClick={onClose} title="Close">
<CloseIcon /> <CloseIcon />
</button> </button>
</header> </header>
<section className="conv-info-top"> <section className="conv-info-top">
<Avatar number={conv.contact} size={72} /> <Avatar number={conv.contact} contact={person} size={group ? 72 : 96} />
<div className="conv-info-title">{convName(conv.contact, contactMap, name)}</div> <div className="conv-info-title">{convName(conv.contact, contactMap, name)}</div>
<div className="muted small"> {group ? (
{members.length} people · <Via did={conv.did} gvNumber={gvNumber} /> <div className="muted small">
</div> {members.length} people · <Via did={conv.did} gvNumber={gvNumber} />
</div>
) : (
<>
{/* Without a contact the name already is the number. */}
{person && (
<div className="conv-info-number">
{formatNumber(conv.contact)}
{person.label ? <span className="muted"> · {person.label}</span> : null}
</div>
)}
<div className="muted small">
<Via did={conv.did} gvNumber={gvNumber} />
</div>
{!person && (
<button className="member-add" onClick={() => addContact(conv.contact)}>
Add to contacts…
</button>
)}
</>
)}
</section> </section>
<section> {group && (
<h3>Name</h3> <section>
<input <h3>Name</h3>
className="conv-name-input" <input
value={draft} className="conv-name-input"
placeholder={membersName} value={draft}
autoFocus placeholder={membersName}
onChange={(e) => setDraft(e.target.value)} autoFocus
onKeyDown={(e) => e.key === 'Enter' && dirty && save()} onChange={(e) => setDraft(e.target.value)}
/> onKeyDown={(e) => e.key === 'Enter' && dirty && save()}
<p className="muted small">Only you see this name; it stays on this computer. Leave it empty to show the members' names.</p> />
</section> <p className="muted small">Only you see this name; it stays on this computer. Leave it empty to show the members' names.</p>
</section>
)}
<section> {group && (
<h3>Members</h3> <section>
{members.map((n) => { <h3>Members</h3>
const c = contactMap.get(n) {members.map((n) => {
return ( const c = contactMap.get(n)
<div key={n} className="member"> return (
<Avatar number={n} contact={c} size={36} /> <div key={n} className="member">
<div className="member-main"> <Avatar number={n} contact={c} size={36} />
<div>{displayName(n, c)}</div> <div className="member-main">
{c && ( <div>{displayName(n, c)}</div>
<div className="muted small"> {c && (
{formatNumber(n)} <div className="muted small">
{c.label ? ` · ${c.label}` : ''} {formatNumber(n)}
</div> {c.label ? ` · ${c.label}` : ''}
</div>
)}
</div>
{!c && (
<button className="member-add" onClick={() => addContact(n)}>
Add to contacts…
</button>
)} )}
</div> </div>
{!c && ( )
<button className="member-add" onClick={() => addContact(n)}> })}
Add to contacts… </section>
</button> )}
)}
</div> <MediaGrid conv={conv} />
)
})}
</section>
<footer> <footer>
<button onClick={onClose}>{dirty ? 'Cancel' : 'Close'}</button> {group ? (
<button className="primary" disabled={!dirty} onClick={save}> <>
Save <button onClick={onClose}>{dirty ? 'Cancel' : 'Close'}</button>
</button> <button className="primary" disabled={!dirty} onClick={save}>
Save
</button>
</>
) : (
<button onClick={onClose}>Close</button>
)}
</footer> </footer>
</div> </div>
</div> </div>
@@ -37,7 +37,7 @@ export function ConversationList({ conversations, contactMap, selected, multiDid
if (!conversations.length) return <div className="list-empty">{emptyText}</div> if (!conversations.length) return <div className="list-empty">{emptyText}</div>
const menuItems = (c: Conversation) => [ const menuItems = (c: Conversation) => [
...(isGroup(c.contact) ? [{ label: 'Get info…', onSelect: () => onInfo(c) }] : []), { label: 'Get info…', onSelect: () => onInfo(c) },
...(!isGroup(c.contact) && !contactMap.get(c.contact) ? [{ label: 'Add to contacts…', onSelect: () => addContact(c.contact) }] : []), ...(!isGroup(c.contact) && !contactMap.get(c.contact) ? [{ label: 'Add to contacts…', onSelect: () => addContact(c.contact) }] : []),
c.archived c.archived
? { label: 'Unarchive', onSelect: () => void window.api.setArchived(c.did, c.contact, false) } ? { label: 'Unarchive', onSelect: () => void window.api.setArchived(c.did, c.contact, false) }
+10
View File
@@ -29,6 +29,16 @@ export const BackIcon = () => (
<path d="M15 18l-6-6 6-6" /> <path d="M15 18l-6-6 6-6" />
</svg> </svg>
) )
export const LeftIcon = ({ size = 28 }: { size?: number }) => (
<svg {...base} width={size} height={size}>
<path d="m15 18-6-6 6-6" />
</svg>
)
export const RightIcon = ({ size = 28 }: { size?: number }) => (
<svg {...base} width={size} height={size}>
<path d="m9 18 6-6-6-6" />
</svg>
)
export const UpIcon = () => ( export const UpIcon = () => (
<svg {...base} width={18} height={18}> <svg {...base} width={18} height={18}>
<path d="m18 15-6-6-6 6" /> <path d="m18 15-6-6-6 6" />
+70 -15
View File
@@ -1,6 +1,8 @@
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { mediaKind } from '@shared/mime'
import type { Message } from '@shared/types'
import { ContextMenu, type MenuItem } from './ContextMenu' import { ContextMenu, type MenuItem } from './ContextMenu'
import { CloseIcon, DownloadIcon } from './Icons' import { CloseIcon, DownloadIcon, LeftIcon, RightIcon } from './Icons'
import { mediaSrc } from './MessageBubble' import { mediaSrc } from './MessageBubble'
// Copy an attachment to the clipboard as a PNG (so GIF/WebP/HEIC work too). // Copy an attachment to the clipboard as a PNG (so GIF/WebP/HEIC work too).
@@ -23,20 +25,58 @@ export const imageMenuItems = (id: number, index: number): MenuItem[] => [
{ label: 'Save image…', onSelect: () => void window.api.saveMedia(id, index).catch(() => undefined) } { label: 'Save image…', onSelect: () => void window.api.saveMedia(id, index).catch(() => undefined) }
] ]
export function Lightbox({ id, index, onClose }: { id: number; index: number; onClose: () => void }) { // One picture or video in a conversation.
export interface MediaItem {
id: number // the message
index: number // which of its attachments
ts: number
video: boolean
}
// Every picture and video in a conversation, oldest first.
export function conversationMedia(messages: Message[]): MediaItem[] {
const out: MediaItem[] = []
for (const m of messages) {
m.media?.forEach((ref, index) => {
const kind = mediaKind(ref)
if (kind === 'image' || kind === 'video') out.push({ id: m.id, index, ts: m.ts, video: kind === 'video' })
})
}
return out
}
// Full size, over everything. ← and → step through `items` (oldest first).
export function Lightbox({ items, start, onClose }: { items: MediaItem[]; start: number; onClose: () => void }) {
const [at, setAt] = useState(start)
const [menu, setMenu] = useState<{ x: number; y: number }>() const [menu, setMenu] = useState<{ x: number; y: number }>()
const item = items[at]
const step = (dir: 1 | -1): void => setAt((i) => Math.min(items.length - 1, Math.max(0, i + dir)))
useEffect(() => { useEffect(() => {
const onKey = (e: KeyboardEvent): void => { const onKey = (e: KeyboardEvent): void => {
if (e.key === 'Escape' && !menu) onClose() if (menu) return
// Ours alone: not the dialog underneath, a video's seek or the composer's caret.
if (e.key === 'Escape') onClose()
else if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') step(e.key === 'ArrowLeft' ? -1 : 1)
else return
e.preventDefault()
e.stopPropagation()
} }
window.addEventListener('keydown', onKey) window.addEventListener('keydown', onKey, true)
return () => window.removeEventListener('keydown', onKey) return () => window.removeEventListener('keydown', onKey, true)
}, [onClose, menu]) // eslint-disable-next-line react-hooks/exhaustive-deps
}, [onClose, menu, items.length])
if (!item) return null
const { id, index } = item
return ( return (
<div className="lightbox" onMouseDown={(e) => e.target === e.currentTarget && onClose()}> <div className="lightbox" onMouseDown={(e) => e.target === e.currentTarget && onClose()}>
<div className="lightbox-bar"> <div className="lightbox-bar">
{items.length > 1 && (
<span className="lightbox-count">
{at + 1} of {items.length} · {new Date(item.ts).toLocaleDateString(undefined, { dateStyle: 'medium' })}
</span>
)}
<button className="icon-btn" title="Save…" onClick={() => void window.api.saveMedia(id, index)}> <button className="icon-btn" title="Save…" onClick={() => void window.api.saveMedia(id, index)}>
<DownloadIcon /> <DownloadIcon />
</button> </button>
@@ -44,15 +84,30 @@ export function Lightbox({ id, index, onClose }: { id: number; index: number; on
<CloseIcon size={20} /> <CloseIcon size={20} />
</button> </button>
</div> </div>
<img {items.length > 1 && (
src={mediaSrc(id, index)} <>
alt="" <button className="icon-btn lightbox-step prev" title="Older (←)" disabled={at === 0} onClick={() => step(-1)}>
draggable={false} <LeftIcon />
onContextMenu={(e) => { </button>
e.preventDefault() <button className="icon-btn lightbox-step next" title="Newer (→)" disabled={at === items.length - 1} onClick={() => step(1)}>
setMenu({ x: e.clientX, y: e.clientY }) <RightIcon />
}} </button>
/> </>
)}
{item.video ? (
<video key={`${id}:${index}`} src={mediaSrc(id, index)} controls autoPlay />
) : (
<img
key={`${id}:${index}`}
src={mediaSrc(id, index)}
alt=""
draggable={false}
onContextMenu={(e) => {
e.preventDefault()
setMenu({ x: e.clientX, y: e.clientY })
}}
/>
)}
{menu && <ContextMenu x={menu.x} y={menu.y} items={imageMenuItems(id, index)} onClose={() => setMenu(undefined)} />} {menu && <ContextMenu x={menu.x} y={menu.y} items={imageMenuItems(id, index)} onClose={() => setMenu(undefined)} />}
</div> </div>
) )
+101
View File
@@ -3768,4 +3768,105 @@ label.check {
padding: 0; padding: 0;
} }
/* ---------- chat header: the picture opens Get info (#clickable) ---------- */
.chat-avatar {
border-radius: 50%;
cursor: pointer;
}
.chat-avatar:focus-visible {
outline: none;
box-shadow: 0 0 0 2px var(--highlight);
}
/* ---------- Get info: the number, and the chat's photos ---------- */
.conv-info-number {
font-size: 15px;
user-select: text;
}
.conv-info-top .member-add {
margin: 6px 0 0;
}
.media-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
gap: 4px;
max-height: 284px;
overflow-y: auto;
}
/* Clickable pictures: finger + tooltip + Tab ring, never shaded. */
.media-thumb {
position: relative;
aspect-ratio: 1;
border-radius: 8px;
overflow: hidden;
cursor: pointer;
background: var(--stripe);
}
.media-thumb:focus-visible {
outline: none;
box-shadow: inset 0 0 0 2px var(--highlight);
}
.media-thumb img,
.media-thumb video {
width: 100%;
height: 100%;
object-fit: cover;
display: block;
pointer-events: none;
}
.media-thumb-play {
position: absolute;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
font-size: 22px;
text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}
.media-thumb-missing {
display: flex;
height: 100%;
align-items: center;
justify-content: center;
font-size: 11px;
color: var(--muted, #808080);
}
/* ---------- lightbox: step through the chat's photos ---------- */
.lightbox video {
max-width: 100%;
max-height: 100%;
border-radius: 4px;
}
.lightbox-bar {
align-items: center;
}
.lightbox-count {
color: #ddd;
font-size: 13px;
margin-right: 8px;
}
/* Embossed buttons over the dark: the ordinary glyph color, not light gray on white. */
.lightbox .icon-btn,
.lightbox .icon-btn:hover {
color: var(--glyph);
}
.lightbox-step {
position: absolute;
top: 50%;
transform: translateY(-50%);
width: 44px;
height: 64px;
z-index: 1;
}
.lightbox-step.prev {
left: 8px;
}
.lightbox-step.next {
right: 8px;
}
.lightbox-step:disabled {
visibility: hidden;
}
} }
+8
View File
@@ -48,6 +48,14 @@ describe('toNewMessage (MMS)', () => {
expect(toNewMessage({ ...mms, col_media1: url, media: [url] })).toMatchObject({ kind: 'mms', media: [{ url }] }) expect(toNewMessage({ ...mms, col_media1: url, media: [url] })).toMatchObject({ kind: 'mms', media: [{ url }] })
expect(toNewMessage({ ...mms, col_media1: url })).toMatchObject({ kind: 'mms', media: [{ url }] }) expect(toNewMessage({ ...mms, col_media1: url })).toMatchObject({ kind: 'mms', media: [{ url }] })
}) })
it('drops voip.ms\'s "MMS Received" stand-in text from pictures', () => {
const url = 'https://voip.ms/media/abc/media.jpeg'
expect(toNewMessage({ ...mms, message: 'MMS Received', col_media1: url }).body).toBe('')
expect(toNewMessage({ ...mms, message: ' mms received\n', col_media1: url }).body).toBe('')
expect(toNewMessage({ ...mms, message: 'MMS Received, thanks', col_media1: url }).body).toBe('MMS Received, thanks')
// Typed by a person, with no picture: kept.
expect(toNewMessage({ ...mms, message: 'MMS received', col_media1: '' }).body).toBe('MMS received')
})
it('treats rows without media as plain texts', () => { it('treats rows without media as plain texts', () => {
const m = toNewMessage({ ...mms, message: 'long text', col_media1: '', media: [] }) const m = toNewMessage({ ...mms, message: 'long text', col_media1: '', media: [] })
expect(m.kind).toBeUndefined() expect(m.kind).toBeUndefined()