Compare commits

...
10 Commits
Author SHA1 Message Date
travandClaude Opus 5.5 50cca0ba83 Concise README with a screenshot (Signal vibes, made-up data)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 11:12:43 -08:00
trav ea9ce012e4 v0.9.4: bubble for Android 0.7.7 — tap the paperclip, then tap a choice (holding and swiping up went home) 2026-11-15 15:07:35 -08:00
travandClaude Opus 5.5 e5439d37bd v0.9.3: the unread button's bubbles don't touch
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 13:22:52 -08:00
travandClaude Opus 5.5 8c320fde0a v0.9.2: an unread view
A button with three outlined bubbles, between Check for new messages and Archived chats, lists only unread chats (archived ones too) under an "Unread chats" header, like the archive's. The chat you open from it reads as usual but stays in the list, to keep replying, until you open another one; then it drops out.

Tried on the sandbox's made-up chats: an archived unread chat listed, an opened chat kept until the next was opened, and the view emptying back to the still-unread ones when left and reopened.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 13:15:10 -08:00
travandClaude Opus 5.5 4b7a6882da v0.9.1: bubble for Android 0.7.6 — pictures have the bubble's round corners; no "MMS Sent"
Android: a picture in a chat is clipped to the bubble's 30 dp corner, sent and received. Checked on the Rabbit with the dev app (the sandbox now has a made-up picture each way).

Both: voip.ms gives a picture we sent with no words the text "MMS Sent", like the "MMS Received" already dropped; that goes too, from new messages and (once) from ones already stored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 12:39:02 -08:00
trav babf00a1f9 v0.9.0: the history lives in ~/Documents/bubble-data
On its first launch bubble copies ~/Documents/voipms-desktop-data to ~/Documents/bubble-data (through a .partial folder, renamed only once the copy is whole) and uses that. The old folder stays as a backup with a "MOVED TO bubble-data.txt" note, to delete once everything looks right. A data folder chosen in Settings elsewhere stays put; if the copy fails, bubble keeps using the old folder rather than starting empty.

Tried with a throwaway home holding the sandbox's made-up history: the copy, the note, the chats loading from the new folder, no second copy on the next launch, and a saved pointer to the old folder moving along with it.
2026-11-13 12:15:09 -08:00
trav 4133c4ad67 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.
2026-11-13 12:01:56 -08:00
trav 928a4b9b35 v0.8.7: a bubble round a picture follows its corner evenly
Its corners were 18 px round round an 8 px picture with 4 px of padding, so the gap across each corner shrank to about 1.5 px. They are 12 px now (the picture's 8 plus the padding), the same 4 px all the way round.
2026-11-13 11:51:18 -08:00
trav 5af309562a v0.8.6: bubble for Android 0.7.4 — the message box sits inside the composer again
The composer row lined its children up by text baseline, and the attach/send glyphs have no text, so the text box was lifted 27 px out the top of the composer and cut off. Rows now line up by their bottoms. Checked on the Rabbit with the dev app and made-up chats: at rest, with the keyboard up, and with three lines typed.
2026-11-13 11:43:44 -08:00
trav 41f42b19e7 v0.8.5: the chat search field is just its glyph
No "Search in chat" placeholder; the field keeps it as its accessible name.
2026-11-13 11:28:02 -08:00
24 changed files with 248 additions and 211 deletions
+11 -101
View File
@@ -1,110 +1,20 @@
# bubble # bubble
A Signal Desktop–style SMS client for [voip.ms](https://voip.ms). It keeps your full message history on your own machine, lets you search it, and shows your GNOME contacts' names and photos. ![bubble](docs/screenshot.png)
## Features A Signal-style desktop SMS/MMS client for [voip.ms](https://voip.ms) and Google Voice (Electron, Linux), plus a companion texting app for the Rabbit R1 (`android/`).
- A conversation list on the left, with contact photos, previews, times, and unread badges. The chat opens on the right. - Keeps your whole message history locally (SQLite), with full-text search
- A **full local copy of your history.** On first run the app imports everything from voip.ms, working backwards in 90-day windows, and picks up where it left off if interrupted. After that it checks for new messages every 30 seconds (you can change this). - Group chats, MMS, reactions, emoji shortcodes, GNOME contacts
- **Search** everything from the sidebar (Ctrl+F). Results show a highlighted preview, and clicking one jumps to that exact message. You can also search inside a single chat (Ctrl+Shift+F), using Enter and Shift+Enter to step through the matches. - Optional end-to-end-sealed relay to sync with the Rabbit R1 (`server/`)
- **New chat** (Ctrl+N), with autocomplete from your contacts by name or number.
- Contacts are read-only, straight from GNOME's Evolution Data Server caches: your Nextcloud CardDAV books and anything else GNOME Contacts shows. They reload automatically when the books sync.
- Messages longer than 160 characters are split automatically. If a send fails, it's marked with Retry and Delete options.
- **MMS**: photos, video and audio appear inline in the chat. Click a photo to view it full size or save it. You can attach up to 3 files with the paperclip, by drag-and-drop, or by pasting. Photos too big for voip.ms (the budget is 900 KB each) are shrunk automatically before sending.
- **Emoji shortcodes**: type `:` and at least two letters, for example `:jo`, to get matching emoji. Pick one with ↑/↓ and Tab/Enter or by clicking it; Esc closes the list. A finished `:joy:` converts on its own. The shortcodes are Signal's and Slack's, from [emoji-datasource](https://github.com/iamcal/emoji-data); `npm run gen:emoji` regenerates them.
- Alt+↑/↓ moves between conversations.
- Ctrl +/− zooms and Ctrl 0 resets. Choose Light, Dark, or System under Settings → Appearance, and the dark or inverted (lighter) icon.
- **The Rabbit's SIM, from here** (Settings → Rabbit relay): with bubble as the Rabbit R1's texting app, its SIM is a third number to text from ("Rabbit SIM"), its texts show up here, and chat names and read/unread/archived stay in step with the Rabbit, no cable needed. It goes through a small relay on jai (`server/bubble_relay.py`, deployed with `scripts/deploy-jai.sh`), which only ever holds AES-256-GCM-sealed messages: the key lives on this computer and the Rabbit, never on jai. A text sent from here goes out at the Rabbit's next background check, so it can take a while; older photos come over when you open them.
## Where your data lives ## Run
| What | Where | Backed up? |
|---|---|---|
| Message database | `~/Documents/voipms-desktop-data/messages.db` | ✅ Déjà Dup covers `~/Documents` |
| Daily snapshots, last 7 kept | `~/Documents/voipms-desktop-data/snapshots/` | ✅ |
| Settings | `~/Documents/voipms-desktop-data/settings.json` | ✅ |
| MMS photos and attachments (cached on arrival) | `~/Documents/voipms-desktop-data/media/` | ✅ |
| API password | GNOME Keyring (via Electron `safeStorage`) → `~/.config/voipms-desktop/credentials.bin` | ❌ on purpose; you re-enter it after a restore |
| Contact photo cache | `~/.config/voipms-desktop/photo-cache/` | ❌ not needed |
| Rabbit relay address, token and key | GNOME Keyring → `~/.config/voip.ms Messages/relay.bin` | ❌ on purpose; reconnect and Sync to Rabbit after a restore |
The snapshots are consistent SQLite copies, made daily and whenever you quit. So even if a backup catches the live database halfway through a write, the backup still holds a clean, restorable copy. To move the data folder, go to Settings → Storage → Move…. If you point it at a folder that already holds a `messages.db`, for example one restored from backup, the app uses that history.
## Setup
In the voip.ms portal, go to **Main Menu → SOAP & REST/JSON API** and:
1. Enable the API.
2. Set an **API password**. This is separate from your login password.
3. Add your IP address under **Enable IP Addresses**.
Then launch the app and enter your account email and API password.
### The Rabbit relay (optional)
1. `scripts/deploy-jai.sh` puts the relay on jai (its own folder, port 8080 on the tailscale address only); `scripts/deploy-jai.sh --token` prints its token.
2. Settings → Rabbit relay: paste the token, Connect.
3. Plug in the Rabbit and press Sync to Rabbit once: that hands it the address, token and the sealing key.
### Apple-style emoji (optional)
To look like Signal, the app uses an `Apple Color Emoji` font when one is installed, and falls back to Noto Color Emoji otherwise. To install it for your user only (about 116 MB):
```sh ```sh
curl -L -o ~/.local/share/fonts/AppleColorEmoji.ttf \ npm run deps:install # via sfw (npm i -g sfw)
https://github.com/samuelngs/apple-emoji-linux/releases/latest/download/AppleColorEmoji-Linux.ttf VOIPMS_SANDBOX=/tmp/bubble-demo npm run dev # try it with made-up data
fc-cache -f npm run dev # real account: enter your voip.ms API login
npm run install-desktop # build the AppImage + GNOME launcher
``` ```
Alternatively, install the `fonts-apple-color-emoji.rpm` from the same release to make it available system-wide. Restart the app afterward. voip.ms setup: Main Menu → SOAP & REST/JSON API → enable the API, set an API password, allow your IP.
## Development
Dependencies are installed through [Socket Firewall](https://docs.socket.dev/docs/socket-firewall-free)
(`sfw`), which checks every package, transitive ones included, against socket.dev
before npm downloads it. Install it once with `npm i -g sfw`, then use the
`deps:*` scripts instead of bare `npm install` (a Claude Code hook in
`.claude/` enforces this for Claude):
```bash
npm run deps:install # after cloning or pulling changes to package-lock.json
npm run deps:add -- pkg # add a package
npm run deps:update # update within package.json's ranges
```
```bash
npm run dev # run with hot reload
npm test # unit tests (run under Electron's Node for better-sqlite3)
npm run test:live # also reads your real EDS address books (read-only)
npm run typecheck
npm run install-desktop # build the AppImage and add a GNOME launcher
```
To try the app or work on the UI without going near your real account, run it
in a sandbox. Everything it uses (Electron profile, so no saved voip.ms password
or Google sign-in, plus settings and the message database) lives under the given
folder; it skips your address book and fills itself with made-up conversations,
1:1 and group, on a demo voip.ms number and a demo Google Voice number:
```bash
VOIPMS_SANDBOX=/tmp/voipms-sandbox npm run dev # or VOIPMS_DEMO=1, same folder
rm -rf /tmp/voipms-sandbox # start over
```
### Layout
```
src/main/ Electron main process
voipms.ts REST client (getDIDsInfo, getSMS, sendSMS)
sync.ts history backfill + polling
db.ts SQLite schema, FTS5 search, snapshots
contacts.ts EDS cache reader + vCard parser
secrets.ts keyring-encrypted credentials
settings.ts data folder + preferences
src/preload/ typed IPC bridge (window.api)
src/renderer/ React UI
src/shared/ types + phone-number helpers shared by both sides
resources/ icon, eds-sources.py (lists live EDS address books)
```
The message table already reserves `kind` and `media_json` columns for MMS support.
@@ -13,23 +13,24 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
/** /**
* Hold the paperclip and the composer swells upward into a bubble while * Tap the paperclip and the composer swells upward into a bubble while
* camera, photo and microphone (no microphone on a Google Voice chat, which * camera, photo and microphone (no microphone on a Google Voice chat, which
* can't send voice notes) float out from under the clip, jostle each * can't send voice notes) float out from under the clip, jostle each
* other apart and settle above and to the right of it. The thumb stays down: * other apart and settle above and to the right of it. The next touch picks:
* a soft spotlight follows it inside the bubble, leans toward whichever icon * a soft spotlight follows the thumb inside the bubble, leans toward whichever
* it's near (so it needn't be exact), and that icon gets a glowing blue ring. * icon it's near (so it needn't be exact), and that icon gets a glowing blue
* Let go on one to attach that; let go on none and they all slip back under * ring. Let go on one to attach that; let go on none and they all slip back
* the clip as the bubble sinks. * under the clip as the bubble sinks.
*
* <p>Not hold-and-drag from the clip: on the R1 the clip is in the bottom
* 48 dp, where a swipe up is the system's home gesture.
* *
* <p>The way out is a little physics: each icon is sprung to a home spot and * <p>The way out is a little physics: each icon is sprung to a home spot and
* the icons push each other away, launched a beat apart in nearly the same * the icons push each other away, launched a beat apart in nearly the same
* direction so they bump and fan out. The bubble's height just chases the * direction so they bump and fan out. The bubble's height just chases the
* icons. The way back is a plain ease-in, since they're only going away. * icons. The way back is a plain ease-in, since they're only going away.
* *
* <p>Lives on the window's decor while open; the paperclip's own touch * <p>Lives on the window's decor while open and takes its touches itself.
* listener feeds it ({@link #move}, {@link #release}) since the touch began there.
* After a quick tap ({@link #stay}) it takes the next touch itself instead.
*/ */
final class AttachBubble extends View { final class AttachBubble extends View {
interface OnPick { interface OnPick {
@@ -69,7 +70,6 @@ final class AttachBubble extends View {
private float width; // the bubble's right edge private float width; // the bubble's right edge
private float tx, ty; // the thumb private float tx, ty; // the thumb
private boolean touched; // the thumb has moved since the bubble opened private boolean touched; // the thumb has moved since the bubble opened
private boolean sticky; // opened by a tap: the next touch picks or closes
// Icon state, in dp from the clip's centre with y up. // Icon state, in dp from the clip's centre with y up.
private final float[] px = new float[3], py = new float[3], vx = new float[3], vy = new float[3]; private final float[] px = new float[3], py = new float[3], vx = new float[3], vy = new float[3];
@@ -134,7 +134,7 @@ final class AttachBubble extends View {
width = cx + (float) Math.cos(Math.toRadians(HOME_DEG[n - 1])) * HOME_DIST * dp + iconR + margin; width = cx + (float) Math.cos(Math.toRadians(HOME_DEG[n - 1])) * HOME_DIST * dp + iconR + margin;
tx = cx; tx = cx;
ty = cy; ty = cy;
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
invalidate(); invalidate();
} }
@@ -230,18 +230,8 @@ final class AttachBubble extends View {
if (pick >= 0) performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK); if (pick >= 0) performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK);
} }
boolean dragged() {
return touched;
}
/** Opened by a quick tap: stay out until the next touch. */
void stay() {
sticky = true;
}
@Override @Override
public boolean onTouchEvent(MotionEvent e) { public boolean onTouchEvent(MotionEvent e) {
if (!sticky) return true;
switch (e.getActionMasked()) { switch (e.getActionMasked()) {
case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_MOVE: case MotionEvent.ACTION_MOVE:
@@ -39,8 +39,6 @@ public final class ChatActivity extends BaseActivity {
private static final int PICK = 1; private static final int PICK = 1;
private static final int VOICE = 2; private static final int VOICE = 2;
private static final int CAMERA = 3; private static final int CAMERA = 3;
/** A press on the paperclip shorter than this (ms), without dragging, is a tap: the bubble stays open. */
private static final int TAP_MS = 250;
private static final int MAX_PHOTOS = 3; private static final int MAX_PHOTOS = 3;
private String did, contact; private String did, contact;
@@ -64,8 +62,6 @@ public final class ChatActivity extends BaseActivity {
// Audio playing in the list: one at a time, keyed "id/index". // Audio playing in the list: one at a time, keyed "id/index".
private android.media.MediaPlayer player; private android.media.MediaPlayer player;
private String playing; private String playing;
// The bubble while a press on the paperclip is feeding it.
private AttachBubble bubble;
// Where the camera is writing the photo it's taking. // Where the camera is writing the photo it's taking.
private Uri shot; private Uri shot;
@@ -123,23 +119,16 @@ public final class ChatActivity extends BaseActivity {
/** /**
* The R1 has 640 px of height and the keyboard takes about half: with a * The R1 has 640 px of height and the keyboard takes about half: with a
* photo attached, the full-size composer would push the text box under * photo attached, the composer would push the text box under it. So
* it. So while it's up, the photos, text and padding all shrink and the * while it's up, the photos shrink, the text box gives up a line and the
* subtitle goes, leaving the text box and a few messages in view. * subtitle goes, leaving the text box and a few messages in view. (The
* composer itself is always the small size: see composer().)
*/ */
private void setCompact(boolean on) { private void setCompact(boolean on) {
compact = on; compact = on;
header.setPadding(Ui.dp(this, 24), Ui.dp(this, on ? 4 : 10), Ui.dp(this, 24), Ui.dp(this, on ? 4 : 10)); header.setPadding(Ui.dp(this, 24), Ui.dp(this, on ? 4 : 10), Ui.dp(this, 24), Ui.dp(this, on ? 4 : 10));
subView.setVisibility(on || subView.getText().length() == 0 ? View.GONE : View.VISIBLE); subView.setVisibility(on || subView.getText().length() == 0 ? View.GONE : View.VISIBLE);
composerBox.setPadding(Ui.dp(this, 12), Ui.dp(this, on ? 4 : 10), Ui.dp(this, 12), Ui.dp(this, on ? 4 : 10));
input.setTextSize(TypedValue.COMPLEX_UNIT_SP, on ? Ui.T_SMALL : Ui.T_BODY);
input.setPadding(Ui.dp(this, on ? 18 : 24), Ui.dp(this, on ? 8 : 14), Ui.dp(this, on ? 18 : 24), Ui.dp(this, on ? 8 : 14));
input.setMaxLines(on ? 3 : 4); input.setMaxLines(on ? 3 : 4);
for (TextView b : new TextView[] {attach, send}) {
b.setMinWidth(Ui.dp(this, on ? 60 : 80));
b.setMinHeight(Ui.dp(this, on ? 56 : 80));
b.setTextSize(TypedValue.COMPLEX_UNIT_SP, on ? 28 : 34);
}
for (int i = 0; i < tray.getChildCount(); i++) tray.getChildAt(i).setLayoutParams(thumbParams()); for (int i = 0; i < tray.getChildCount(); i++) tray.getChildAt(i).setLayoutParams(thumbParams());
if (on) list.post(this::showLatest); if (on) list.post(this::showLatest);
} }
@@ -165,7 +154,9 @@ public final class ChatActivity extends BaseActivity {
LinearLayout box = composerBox = new LinearLayout(this); LinearLayout box = composerBox = new LinearLayout(this);
box.setOrientation(LinearLayout.VERTICAL); box.setOrientation(LinearLayout.VERTICAL);
box.setBackgroundColor(Ui.PANEL); box.setBackgroundColor(Ui.PANEL);
box.setPadding(Ui.dp(this, 12), Ui.dp(this, 10), Ui.dp(this, 12), Ui.dp(this, 10)); // Always the compact size (it used to shrink only with the keyboard
// up): the big one's padding was wasted on a 640 px screen.
box.setPadding(Ui.dp(this, 12), Ui.dp(this, 4), Ui.dp(this, 12), Ui.dp(this, 4));
// From-number picker, only for a conversation with nothing in it yet. // From-number picker, only for a conversation with nothing in it yet.
fromRow = new LinearLayout(this); fromRow = new LinearLayout(this);
@@ -183,17 +174,23 @@ public final class ChatActivity extends BaseActivity {
LinearLayout row = new LinearLayout(this); LinearLayout row = new LinearLayout(this);
row.setGravity(Gravity.BOTTOM); row.setGravity(Gravity.BOTTOM);
// Not lined up by text baseline: the attach/send glyphs have no text,
// and matching their empty baseline lifted the text box out the top
// of the composer, cut off.
row.setBaselineAligned(false);
attach = Ui.headerButton(this, Glyph.Kind.ATTACH); attach = Ui.headerButton(this, Glyph.Kind.ATTACH);
attach.setOnTouchListener((v, e) -> attachTouch(e)); attach.setOnClickListener(v -> openAttach());
compactButton(attach);
input = new EditText(this); input = new EditText(this);
input.setHint("Message"); input.setHint("Message");
input.setHintTextColor(Ui.MUTED); input.setHintTextColor(Ui.MUTED);
input.setTextColor(Ui.TEXT); input.setTextColor(Ui.TEXT);
input.setTextSize(TypedValue.COMPLEX_UNIT_SP, Ui.T_BODY); input.setTextSize(TypedValue.COMPLEX_UNIT_SP, Ui.T_SMALL);
input.setMaxLines(4); input.setMaxLines(4);
input.setBackground(Ui.input(this, 36)); input.setBackground(Ui.input(this, 36));
input.setPadding(Ui.dp(this, 24), Ui.dp(this, 14), Ui.dp(this, 24), Ui.dp(this, 14)); input.setPadding(Ui.dp(this, 18), Ui.dp(this, 8), Ui.dp(this, 18), Ui.dp(this, 8));
send = Ui.headerButton(this, Glyph.Kind.SEND, Ui.ACCENT); send = Ui.headerButton(this, Glyph.Kind.SEND, Ui.ACCENT);
compactButton(send);
send.setOnClickListener(v -> submit()); send.setOnClickListener(v -> submit());
row.addView(attach); row.addView(attach);
row.addView(input, new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1)); row.addView(input, new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1));
@@ -222,6 +219,12 @@ public final class ChatActivity extends BaseActivity {
return box; return box;
} }
private void compactButton(TextView b) {
b.setMinWidth(Ui.dp(this, 60));
b.setMinHeight(Ui.dp(this, 56));
b.setTextSize(TypedValue.COMPLEX_UNIT_SP, 28);
}
private android.content.SharedPreferences drafts() { private android.content.SharedPreferences drafts() {
return getSharedPreferences("drafts", MODE_PRIVATE); return getSharedPreferences("drafts", MODE_PRIVATE);
} }
@@ -375,33 +378,13 @@ public final class ChatActivity extends BaseActivity {
} }
/** /**
* Press the paperclip and the bubble is out at once: drag to a choice and * Tap the paperclip and the bubble opens; tap a choice, or anywhere else
* let go. A quick tap leaves it open to tap a choice (or anywhere else to close). * to close it. Not hold-and-drag: the clip sits in the R1's bottom 48 dp,
* where a swipe up is the system's home gesture, and no app can opt out of that.
*/ */
private boolean attachTouch(android.view.MotionEvent e) { private void openAttach() {
switch (e.getActionMasked()) { // Google Voice only lets apps send photos: no voice-note choice there.
case android.view.MotionEvent.ACTION_DOWN: new AttachBubble(this, attach, composerBox, !Config.get(this).isGv(did), this::attachKind).show(this);
attach.getParent().requestDisallowInterceptTouchEvent(true);
// Google Voice only lets apps send photos: no voice-note choice there.
bubble = new AttachBubble(this, attach, composerBox, !Config.get(this).isGv(did), this::attachKind);
bubble.show(this);
return true;
case android.view.MotionEvent.ACTION_MOVE:
if (bubble != null) bubble.move(e.getRawX(), e.getRawY());
return true;
case android.view.MotionEvent.ACTION_UP:
if (bubble == null) return true;
if (e.getEventTime() - e.getDownTime() < TAP_MS && !bubble.dragged()) bubble.stay();
else bubble.release();
bubble = null;
return true;
case android.view.MotionEvent.ACTION_CANCEL:
if (bubble != null) bubble.dismiss();
bubble = null;
return true;
default:
return true;
}
} }
private void attachKind(int which) { private void attachKind(int which) {
@@ -747,6 +730,14 @@ public final class ChatActivity extends BaseActivity {
ImageView iv = new ImageView(c); ImageView iv = new ImageView(c);
iv.setScaleType(ImageView.ScaleType.CENTER_CROP); iv.setScaleType(ImageView.ScaleType.CENTER_CROP);
iv.setBackgroundColor(0x22FFFFFF); iv.setBackgroundColor(0x22FFFFFF);
// The picture's corners match the bubble's (30 dp).
float corner = Ui.dp(c, 30);
iv.setOutlineProvider(new android.view.ViewOutlineProvider() {
@Override public void getOutline(View v, android.graphics.Outline o) {
o.setRoundRect(0, 0, v.getWidth(), v.getHeight(), corner);
}
});
iv.setClipToOutline(true);
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(bw, bh); FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(bw, bh);
iv.setLayoutParams(new LinearLayout.LayoutParams(bw, bh)); iv.setLayoutParams(new LinearLayout.LayoutParams(bw, bh));
String tag = id + "/" + index; String tag = id + "/" + index;
@@ -96,6 +96,11 @@ final class Store {
db.execSQL("UPDATE messages SET body = '' WHERE media_json IS NOT NULL AND lower(trim(body)) = 'mms received'"); db.execSQL("UPDATE messages SET body = '' WHERE media_json IS NOT NULL AND lower(trim(body)) = 'mms received'");
set("mms_received_stripped", "1"); set("mms_received_stripped", "1");
} }
// ...and one we sent with no words "MMS Sent".
if (get("mms_sent_stripped") == null) {
db.execSQL("UPDATE messages SET body = '' WHERE media_json IS NOT NULL AND lower(trim(body)) = 'mms sent'");
set("mms_sent_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()));
} }
@@ -127,7 +127,7 @@ final class VoipMs {
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. // 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 = ""; if (m.body.trim().equalsIgnoreCase("MMS Received") || m.body.trim().equalsIgnoreCase("MMS Sent")) 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.3" VERSION_NAME = "0.7.7"
VERSION_CODE = 11 VERSION_CODE = 15
PACKAGE = "me.teafry.voipmessages" PACKAGE = "me.teafry.voipmessages"
DEV_PACKAGE = PACKAGE + ".dev" DEV_PACKAGE = PACKAGE + ".dev"
+16
View File
@@ -17,7 +17,9 @@ import json
import os import os
import sqlite3 import sqlite3
import subprocess import subprocess
import struct
import tempfile import tempfile
import zlib
import time import time
from pathlib import Path from pathlib import Path
@@ -26,6 +28,12 @@ VOIP, GV = "5415550100", "5415550177"
GROUP = "5415550101,5415550102,5415550103" GROUP = "5415550101,5415550102,5415550103"
def gradient_png(w: int, h: int) -> bytes:
raw = b"".join(b"\0" + bytes(c for x in range(w) for c in (x * 255 // w, y * 255 // h, 160)) for y in range(h))
chunk = lambda t, b: struct.pack(">I", len(b)) + t + b + struct.pack(">I", zlib.crc32(t + b))
return b"\x89PNG\r\n\x1a\n" + chunk(b"IHDR", struct.pack(">IIBBBBB", w, h, 8, 2, 0, 0, 0)) + chunk(b"IDAT", zlib.compress(raw)) + chunk(b"IEND", b"")
def push(local: Path, name: str): def push(local: Path, name: str):
with open(local, "rb") as f: with open(local, "rb") as f:
subprocess.run(["adb", "shell", f"run-as {PKG} sh -c 'cat > files/{name}'"], stdin=f, check=True) subprocess.run(["adb", "shell", f"run-as {PKG} sh -c 'cat > files/{name}'"], stdin=f, check=True)
@@ -84,6 +92,12 @@ def main():
rows.append((SIM_BASE + 1, "sim", "5415550150", "in", "Texting your SIM number now", now - 20 * m, None)) rows.append((SIM_BASE + 1, "sim", "5415550150", "in", "Texting your SIM number now", now - 20 * m, None))
rows.append((SIM_BASE + 2, "sim", "5415550150", "out", "Got it, this is the SIM", now - 19 * m, None)) rows.append((SIM_BASE + 2, "sim", "5415550150", "out", "Got it, this is the SIM", now - 19 * m, None))
con.executemany("INSERT INTO messages (id, did, contact, direction, body, ts, sender) VALUES (?,?,?,?,?,?,?)", rows) con.executemany("INSERT INTO messages (id, did, contact, direction, body, ts, sender) VALUES (?,?,?,?,?,?,?)", rows)
# Pictures both ways (a made-up gradient), to see their corners.
pic = Path(d) / "sandbox-pic.png"
pic.write_bytes(gradient_png(400, 300))
ref = json.dumps([{"file": "sandbox-pic.png", "mime": "image/png", "width": 400, "height": 300}])
con.execute("INSERT INTO messages (id, did, contact, direction, body, ts, kind, media_json) VALUES (1007, ?, '5415550110', 'in', 'Look at this', ?, 'mms', ?)", (VOIP, now - 280 * m, ref))
con.execute("INSERT INTO messages (id, did, contact, direction, body, ts, kind, media_json) VALUES (1008, ?, '5415550110', 'out', '', ?, 'mms', ?)", (VOIP, now - 279 * m, ref))
con.execute("INSERT INTO kv VALUES ('unread_floor', '0')") con.execute("INSERT INTO kv VALUES ('unread_floor', '0')")
con.execute("INSERT INTO gv_threads VALUES (?, ?, 'g.demo')", (GV, GROUP)) con.execute("INSERT INTO gv_threads VALUES (?, ?, 'g.demo')", (GV, GROUP))
con.commit() con.commit()
@@ -99,6 +113,8 @@ def main():
})) }))
push(db, "messages.db") push(db, "messages.db")
push(cfg, "config.json") push(cfg, "config.json")
subprocess.run(["adb", "shell", f"run-as {PKG} mkdir -p files/media"], check=True)
push(pic, "media/sandbox-pic.png")
subprocess.run(["adb", "shell", "am", "start", "-n", f"{PKG}/me.teafry.voipmessages.MainActivity"], check=True) subprocess.run(["adb", "shell", "am", "start", "-n", f"{PKG}/me.teafry.voipmessages.MainActivity"], check=True)
print("sandbox data pushed to", PKG) print("sandbox data pushed to", PKG)
Binary file not shown.

After

Width:  |  Height:  |  Size: 145 KiB

+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "voipms-desktop", "name": "voipms-desktop",
"productName": "bubble", "productName": "bubble",
"version": "0.8.4", "version": "0.9.4",
"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.3", "version_code": 11, "package": "me.teafry.voipmessages"} {"version_name": "0.7.7", "version_code": 15, "package": "me.teafry.voipmessages"}
+4 -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 = 11 const SCHEMA_VERSION = 12
export interface ReadState { export interface ReadState {
did: string did: string
@@ -170,6 +170,9 @@ export class MessageDb {
// Received"; nobody wrote it, so it goes. // Received"; nobody wrote it, so it goes.
if (version >= 1 && version < 11) 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.exec(`UPDATE messages SET body = '' WHERE media_json IS NOT NULL AND lower(trim(body)) = 'mms received'`)
// v12: and one we sent with no words "MMS Sent".
if (version >= 1 && version < 12)
this.db.exec(`UPDATE messages SET body = '' WHERE media_json IS NOT NULL AND lower(trim(body)) = 'mms sent'`)
this.db.pragma(`user_version = ${SCHEMA_VERSION}`) this.db.pragma(`user_version = ${SCHEMA_VERSION}`)
} }
+10 -5
View File
@@ -16,7 +16,7 @@ import { MediaStore } from './media'
import { exportHtml, exportText, inRange, rangeLabel } from './export' import { exportHtml, exportText, inRange, rangeLabel } from './export'
import { extFor, guessMime } from '@shared/mime' import { extFor, guessMime } from '@shared/mime'
import { clearCredentials, loadCredentials, saveCredentials } from './secrets' import { clearCredentials, loadCredentials, saveCredentials } from './secrets'
import { getDataDir, loadSettings, saveSettings, setDataDir } from './settings' import { getDataDir, loadSettings, moveToBubbleData, saveSettings, setDataDir } from './settings'
import { SyncEngine } from './sync' import { SyncEngine } from './sync'
import { loadZoom, saveZoom } from './uistate' import { loadZoom, saveZoom } from './uistate'
import { sendWithRetry } from './send' import { sendWithRetry } from './send'
@@ -239,13 +239,17 @@ async function servePhoto(req: Request): Promise<Response> {
} }
} }
// ---- MMS attachments: mms-media://m/<messageId>/<index> ---- // ---- MMS attachments: mms-media://m/<messageId>/<index>[?thumb] ----
// ?thumb: a smaller copy of a still picture, for the chat and Get info.
async function serveMedia(req: Request): Promise<Response> { async function serveMedia(req: Request): Promise<Response> {
const [id, index] = new URL(req.url).pathname.slice(1).split('/').map(Number) const url = new URL(req.url)
const [id, index] = url.pathname.slice(1).split('/').map(Number)
const ref = await media.resolve(id, index) const ref = await media.resolve(id, index)
if (!ref?.file) return new Response(null, { status: 404 }) if (!ref?.file) return new Response(null, { status: 404 })
const headers = { 'content-type': ref.mime ?? guessMime(ref.file) ?? 'application/octet-stream' } const thumb = url.searchParams.has('thumb') ? await media.thumb(ref).catch(() => undefined) : undefined
return new Response(fs.readFileSync(media.filePath(ref.file)), { headers }) const file = thumb ?? media.filePath(ref.file)
const mime = thumb ? (thumb.endsWith('.png') ? 'image/png' : 'image/jpeg') : (ref.mime ?? guessMime(ref.file) ?? 'application/octet-stream')
return new Response(await fs.promises.readFile(file), { headers: { 'content-type': mime } })
} }
async function saveMediaAs(id: number, index: number): Promise<void> { async function saveMediaAs(id: number, index: number): Promise<void> {
@@ -794,6 +798,7 @@ app.on('second-instance', () => {
}) })
app.whenReady().then(async () => { app.whenReady().then(async () => {
moveToBubbleData()
settings = loadSettings() settings = loadSettings()
db = new MessageDb(path.join(getDataDir(), 'messages.db')) db = new MessageDb(path.join(getDataDir(), 'messages.db'))
if (SANDBOX) seedDemo(db) if (SANDBOX) seedDemo(db)
+27
View File
@@ -9,6 +9,9 @@ import { extFor, guessMime } from '@shared/mime'
import type { MediaRef } from '@shared/types' import type { MediaRef } from '@shared/types'
import type { MessageDb, NewMessage } from './db' 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 { export class MediaStore {
private inflight = new Map<string, Promise<MediaRef | undefined>>() private inflight = new Map<string, Promise<MediaRef | undefined>>()
@@ -23,6 +26,30 @@ export class MediaStore {
return path.join(this.dir, path.basename(file)) 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 { save(data: Uint8Array, mime: string): string {
const file = `${crypto.createHash('sha1').update(data).digest('hex')}.${extFor(mime)}` const file = `${crypto.createHash('sha1').update(data).digest('hex')}.${extFor(mime)}`
fs.mkdirSync(this.dir, { recursive: true }) fs.mkdirSync(this.dir, { recursive: true })
+42 -2
View File
@@ -1,6 +1,6 @@
// Where the data lives + non-secret preferences. // Where the data lives + non-secret preferences.
// //
// The message database defaults to ~/Documents/voipms-desktop-data so Déjà Dup // The message database defaults to ~/Documents/bubble-data so Déjà Dup
// backs it up (it excludes ~/.config, ~/.local and ~/.cache). A small pointer // backs it up (it excludes ~/.config, ~/.local and ~/.cache). A small pointer
// file in Electron's userData remembers a custom location if one is chosen. // file in Electron's userData remembers a custom location if one is chosen.
import { app } from 'electron' import { app } from 'electron'
@@ -19,7 +19,47 @@ const DEFAULTS: Settings = {
const pointerFile = (): string => path.join(app.getPath('userData'), 'data-location.json') const pointerFile = (): string => path.join(app.getPath('userData'), 'data-location.json')
export function defaultDataDir(): string { export function defaultDataDir(): string {
return path.join(app.getPath('documents'), 'voipms-desktop-data') return path.join(app.getPath('documents'), 'bubble-data')
}
// Where it lived before the app was called bubble.
const OLD_NAME = 'voipms-desktop-data'
// Once, before anything opens the database: copy ~/Documents/voipms-desktop-data
// to ~/Documents/bubble-data (via a .partial folder, renamed only when the
// copy is whole) and use that. The old folder stays as a backup, with a note
// saying so, for its owner to delete. Only the default place moves: a folder
// chosen in Settings stays where it is. If the copy fails, carry on in the old
// folder rather than starting an empty history.
export function moveToBubbleData(): void {
if (process.env['VOIPMS_DATA_DIR']) return
const old = path.join(app.getPath('documents'), OLD_NAME)
const dest = defaultDataDir()
let pointed: string | undefined
try {
pointed = (JSON.parse(fs.readFileSync(pointerFile(), 'utf8')) as { dataDir?: string }).dataDir
} catch {
/* no pointer: the default place */
}
if (pointed && path.resolve(pointed) !== path.resolve(old)) return
if (!fs.existsSync(path.join(old, 'messages.db')) || fs.existsSync(dest)) return
const partial = `${dest}.partial`
try {
fs.rmSync(partial, { recursive: true, force: true }) // a copy cut short last time
console.log(`[data] copying ${old} to ${dest}`)
fs.cpSync(old, partial, { recursive: true, preserveTimestamps: true, errorOnExist: true })
fs.renameSync(partial, dest)
if (pointed) setDataDir(dest)
fs.writeFileSync(
path.join(old, 'MOVED TO bubble-data.txt'),
`bubble copied this folder to ${dest} on ${new Date().toString()} and uses that one now.\n` +
`This is the backup from before the move: once bubble looks right, it can be deleted.\n`
)
} catch (e) {
console.error('[data] copy to bubble-data failed; staying in the old folder:', e)
fs.rmSync(partial, { recursive: true, force: true })
setDataDir(old)
}
} }
export function getDataDir(): string { export function getDataDir(): string {
+1 -1
View File
@@ -18,7 +18,7 @@ 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 const isMmsPlaceholder = (body: string): boolean => /^mms (received|sent)$/.test(body.trim().toLowerCase())
export function toNewMessage(r: RawSms): NewMessage { export function toNewMessage(r: RawSms): NewMessage {
const m: NewMessage = { const m: NewMessage = {
+27 -6
View File
@@ -21,6 +21,11 @@ export interface Jump {
nonce: number nonce: number
} }
/** Which chats the sidebar lists. */
export type ListView = 'chats' | 'archived' | 'unread'
export const isUnread = (c: Conversation): boolean => c.unread > 0 || c.markedUnread
export const sameConv = (a?: ConvKey | null, b?: ConvKey | null): boolean => !!a && !!b && a.did === b.did && a.contact === b.contact export const sameConv = (a?: ConvKey | null, b?: ConvKey | null): boolean => !!a && !!b && a.did === b.did && a.contact === b.contact
export function App() { export function App() {
@@ -34,7 +39,13 @@ export function App() {
const [sync, setSync] = useState<SyncStatus>() const [sync, setSync] = useState<SyncStatus>()
const [settingsOpen, setSettingsOpen] = useState(false) const [settingsOpen, setSettingsOpen] = useState(false)
const [msgVersion, setMsgVersion] = useState(0) const [msgVersion, setMsgVersion] = useState(0)
const [archiveView, setArchiveView] = useState(false) const [view, setViewState] = useState<ListView>('chats')
// The chat opened from the unread view: it stays listed (read now) until another is opened.
const [kept, setKept] = useState<ConvKey | null>(null)
const setView = useCallback((v: ListView) => {
setViewState(v)
setKept(null)
}, [])
const [info, setInfo] = useState<ConvKey | null>(null) const [info, setInfo] = useState<ConvKey | null>(null)
const [exporting, setExporting] = useState<ConvKey | null>(null) const [exporting, setExporting] = useState<ConvKey | null>(null)
const [adding, setAdding] = useState<string | null>(null) const [adding, setAdding] = useState<string | null>(null)
@@ -60,6 +71,7 @@ export function App() {
window.api.onOpenConversation((key) => { window.api.onOpenConversation((key) => {
setMode('chats') setMode('chats')
setSelected(key) setSelected(key)
setKept(key)
setJump(undefined) setJump(undefined)
}) })
] ]
@@ -78,6 +90,7 @@ export function App() {
const open = useCallback((key: ConvKey, jumpTo?: number) => { const open = useCallback((key: ConvKey, jumpTo?: number) => {
setSelected(key) setSelected(key)
setKept(key)
setJump(jumpTo !== undefined ? { id: jumpTo, nonce: Date.now() } : undefined) setJump(jumpTo !== undefined ? { id: jumpTo, nonce: Date.now() } : undefined)
}, []) }, [])
@@ -85,7 +98,14 @@ export function App() {
const onMarkUnread = useCallback((key: ConvKey) => setSelected((cur) => (sameConv(cur, key) ? null : cur)), []) const onMarkUnread = useCallback((key: ConvKey) => setSelected((cur) => (sameConv(cur, key) ? null : cur)), [])
// The list currently shown in the sidebar (for Alt+↑/↓). // The list currently shown in the sidebar (for Alt+↑/↓).
const listed = useMemo(() => conversations.filter((c) => c.archived === archiveView), [conversations, archiveView]) // The unread view takes archived chats too.
const listed = useMemo(
() =>
conversations.filter((c) =>
view === 'unread' ? isUnread(c) || sameConv(c, kept) : c.archived === (view === 'archived')
),
[conversations, view, kept]
)
useEffect(() => setTooltipsEnabled(state?.settings.showTooltips !== false), [state?.settings.showTooltips]) useEffect(() => setTooltipsEnabled(state?.settings.showTooltips !== false), [state?.settings.showTooltips])
// Which look the stylesheet draws (styles.css): the house look unless Signal vibes are chosen. // Which look the stylesheet draws (styles.css): the house look unless Signal vibes are chosen.
@@ -103,10 +123,10 @@ export function App() {
document.getElementById('sidebar-search')?.focus() document.getElementById('sidebar-search')?.focus()
} else if (c === 'newChat') setMode('compose') } else if (c === 'newChat') setMode('compose')
else if (c === 'preferences') setSettingsOpen(true) else if (c === 'preferences') setSettingsOpen(true)
else if (c === 'archived') setArchiveView((v) => !v) else if (c === 'archived') setView(view === 'archived' ? 'chats' : 'archived')
else if (c === 'checkNow') void window.api.pollNow() else if (c === 'checkNow') void window.api.pollNow()
}), }),
[state?.configured] [state?.configured, view, setView]
) )
// Keyboard shortcuts (Signal-like, plus the menu bar's). // Keyboard shortcuts (Signal-like, plus the menu bar's).
@@ -166,8 +186,9 @@ export function App() {
gvNumber={state.gvoiceNumber} gvNumber={state.gvoiceNumber}
defaultDid={state.settings.defaultDid ?? smsDids[0]?.did} defaultDid={state.settings.defaultDid ?? smsDids[0]?.did}
onSettings={() => setSettingsOpen(true)} onSettings={() => setSettingsOpen(true)}
archiveView={archiveView} view={view}
setArchiveView={setArchiveView} setView={setView}
listed={listed}
onMarkUnread={onMarkUnread} onMarkUnread={onMarkUnread}
onInfo={setInfo} onInfo={setInfo}
onExport={setExporting} onExport={setExporting}
-1
View File
@@ -321,7 +321,6 @@ export function ChatView({ conv, contact, contactMap, conversations, onOpen, nam
<input <input
ref={searchInput} ref={searchInput}
value={q} value={q}
placeholder="Search in chat"
aria-label="Search in chat (Ctrl+Shift+F)" aria-label="Search in chat (Ctrl+Shift+F)"
onChange={(e) => setQ(e.target.value)} onChange={(e) => setQ(e.target.value)}
onKeyDown={(e) => { onKeyDown={(e) => {
@@ -8,7 +8,7 @@ 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 { conversationMedia, Lightbox, type MediaItem } from './Lightbox'
import { mediaSrc } from './MessageBubble' import { mediaSrc, thumbSrc } from './MessageBubble'
interface Props { interface Props {
conv: ConvKey conv: ConvKey
@@ -67,7 +67,7 @@ function MediaGrid({ conv }: { conv: ConvKey }) {
</span> </span>
</> </>
) : ( ) : (
<img src={mediaSrc(it.id, it.index)} alt="" loading="lazy" draggable={false} onError={() => setBroken((b) => new Set(b).add(key(it)))} /> <img src={thumbSrc(it.id, it.index)} alt="" loading="lazy" decoding="async" draggable={false} onError={() => setBroken((b) => new Set(b).add(key(it)))} />
)} )}
</div> </div>
))} ))}
+8
View File
@@ -90,6 +90,14 @@ export const ArchiveIcon = () => (
<path d="M5 9v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V9M10 13h4" /> <path d="M5 9v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V9M10 13h4" />
</svg> </svg>
) )
// Three outlined bubbles of different sizes: the unread view.
export const BubblesIcon = () => (
<svg {...base}>
<circle cx="8.5" cy="14.5" r="5.5" />
<circle cx="17" cy="6" r="3" />
<circle cx="20" cy="17" r="2" />
</svg>
)
export const GroupIcon = () => ( export const GroupIcon = () => (
<svg {...base}> <svg {...base}>
<circle cx="9" cy="8" r="3.5" /> <circle cx="9" cy="8" r="3.5" />
@@ -30,6 +30,8 @@ function renderText(text: string, highlight: string): ReactNode[] {
} }
export const mediaSrc = (id: number, index: number): string => `mms-media://m/${id}/${index}` export const mediaSrc = (id: number, index: number): string => `mms-media://m/${id}/${index}`
// The smaller copy the chat and Get info show (the original if it's small already).
export const thumbSrc = (id: number, index: number): string => `${mediaSrc(id, index)}?thumb`
// Display box for an image: fit within 300×360, keeping the aspect ratio when // Display box for an image: fit within 300×360, keeping the aspect ratio when
// we know it (so the list doesn't jump when the image arrives). // we know it (so the list doesn't jump when the image arrives).
@@ -41,8 +43,8 @@ function imageBox(ref: MediaRef): { width: number; height: number } | undefined
function Attachment({ id, index, media, onOpen, onMenu, onLoad }: { id: number; index: number; media: MediaRef; onOpen: () => void; onMenu: (e: React.MouseEvent) => void; onLoad: () => void }) { function Attachment({ id, index, media, onOpen, onMenu, onLoad }: { id: number; index: number; media: MediaRef; onOpen: () => void; onMenu: (e: React.MouseEvent) => void; onLoad: () => void }) {
const [broken, setBroken] = useState(false) const [broken, setBroken] = useState(false)
const src = mediaSrc(id, index)
const kind = mediaKind(media) const kind = mediaKind(media)
const src = kind === 'image' ? thumbSrc(id, index) : mediaSrc(id, index)
// Still on the Rabbit (relayed history): asked for, it arrives after the Rabbit's next check. // Still on the Rabbit (relayed history): asked for, it arrives after the Rabbit's next check.
if (broken && media.url?.startsWith('mmspart:') && !media.file) return <div className="media-missing">On the Rabbit — it'll appear after its next check</div> if (broken && media.url?.startsWith('mmspart:') && !media.file) return <div className="media-missing">On the Rabbit — it'll appear after its next check</div>
if (broken) return <div className="media-missing">Media unavailable</div> if (broken) return <div className="media-missing">Media unavailable</div>
@@ -53,6 +55,7 @@ function Attachment({ id, index, media, onOpen, onMenu, onLoad }: { id: number;
src={src} src={src}
alt="" alt=""
draggable={false} draggable={false}
decoding="async"
style={imageBox(media) ?? { minHeight: 120, minWidth: 120 }} style={imageBox(media) ?? { minHeight: 120, minWidth: 120 }}
onClick={onOpen} onClick={onOpen}
onContextMenu={onMenu} onContextMenu={onMenu}
+32 -20
View File
@@ -1,13 +1,20 @@
import { useEffect, useRef, useState, type CSSProperties, type PointerEvent as ReactPointerEvent } from 'react' import { useEffect, useRef, useState, type CSSProperties, type PointerEvent as ReactPointerEvent } from 'react'
import type { ContactInfo, Conversation, Did, SyncStatus } from '@shared/types' import type { ContactInfo, Conversation, Did, SyncStatus } from '@shared/types'
import type { ConvKey } from '../App' import type { ConvKey, ListView } from '../App'
import { ConversationList } from './ConversationList' import { ConversationList } from './ConversationList'
import { SearchResults } from './SearchResults' import { SearchResults } from './SearchResults'
import { NewChat } from './NewChat' import { NewChat } from './NewChat'
import { ArchiveIcon, BackIcon, CloseIcon, ComposeIcon, GearIcon, RefreshIcon, SearchIcon } from './Icons' import { ArchiveIcon, BackIcon, BubblesIcon, CloseIcon, ComposeIcon, GearIcon, RefreshIcon, SearchIcon } from './Icons'
export type SidebarMode = 'chats' | 'search' | 'compose' export type SidebarMode = 'chats' | 'search' | 'compose'
const VIEW_TITLE = { unread: 'Unread chats', archived: 'Archived chats' } as const
const EMPTY_TEXT: Record<ListView, string> = {
chats: 'No conversations yet.',
archived: 'No archived chats. Right-click a chat to archive it.',
unread: 'No unread chats.'
}
// Dragging below the default width shrinks the sidebar's contents // Dragging below the default width shrinks the sidebar's contents
// proportionally (via --s) rather than dropping parts of each row. // proportionally (via --s) rather than dropping parts of each row.
const DEFAULT_WIDTH = 340 const DEFAULT_WIDTH = 340
@@ -100,8 +107,10 @@ interface Props {
gvNumber?: string gvNumber?: string
defaultDid?: string defaultDid?: string
onSettings: () => void onSettings: () => void
archiveView: boolean view: ListView
setArchiveView: (on: boolean) => void setView: (v: ListView) => void
/** The chats the current view shows. */
listed: Conversation[]
onMarkUnread: (key: ConvKey) => void onMarkUnread: (key: ConvKey) => void
onInfo: (key: ConvKey) => void onInfo: (key: ConvKey) => void
onExport: (key: ConvKey) => void onExport: (key: ConvKey) => void
@@ -176,17 +185,20 @@ export function Sidebar(p: Props) {
<ComposeIcon /> <ComposeIcon />
</button> </button>
<RefreshButton /> <RefreshButton />
<button {(['unread', 'archived'] as const).map((v) => (
className={`icon-btn${p.archiveView ? ' on' : ''}`} <button
title={p.archiveView ? 'Back to chats' : 'Archived chats'} key={v}
aria-pressed={p.archiveView} className={`icon-btn${p.view === v ? ' on' : ''}`}
onClick={() => { title={p.view === v ? 'Back to chats' : VIEW_TITLE[v]}
p.setArchiveView(!p.archiveView) aria-pressed={p.view === v}
if (p.mode === 'search') clearSearch() onClick={() => {
}} p.setView(p.view === v ? 'chats' : v)
> if (p.mode === 'search') clearSearch()
<ArchiveIcon /> }}
</button> >
{v === 'unread' ? <BubblesIcon /> : <ArchiveIcon />}
</button>
))}
<button className="icon-btn" title="Preferences (Ctrl+,)" onClick={p.onSettings}> <button className="icon-btn" title="Preferences (Ctrl+,)" onClick={p.onSettings}>
<GearIcon /> <GearIcon />
</button> </button>
@@ -204,21 +216,21 @@ export function Sidebar(p: Props) {
/> />
) : ( ) : (
<> <>
{p.archiveView && ( {p.view !== 'chats' && (
<div className="archive-header"> <div className="archive-header">
<button className="icon-btn inline" title="Back to chats" onClick={() => p.setArchiveView(false)}> <button className="icon-btn inline" title="Back to chats" onClick={() => p.setView('chats')}>
<BackIcon /> <BackIcon />
</button> </button>
Archived chats {VIEW_TITLE[p.view]}
</div> </div>
)} )}
<ConversationList <ConversationList
conversations={p.conversations.filter((c) => c.archived === p.archiveView)} conversations={p.listed}
contactMap={p.contactMap} contactMap={p.contactMap}
selected={p.selected} selected={p.selected}
multiDid={p.multiDid} multiDid={p.multiDid}
gvNumber={p.gvNumber} gvNumber={p.gvNumber}
emptyText={p.archiveView ? 'No archived chats. Right-click a chat to archive it.' : 'No conversations yet.'} emptyText={EMPTY_TEXT[p.view]}
onOpen={p.onOpen} onOpen={p.onOpen}
onMarkUnread={p.onMarkUnread} onMarkUnread={p.onMarkUnread}
onInfo={p.onInfo} onInfo={p.onInfo}
+6
View File
@@ -3503,6 +3503,12 @@ select {
.media-file { .media-file {
border-radius: 8px; border-radius: 8px;
} }
/* A bubble round a picture follows its corner at the same 4 px gap as the
sides: the picture's 8 px plus the padding (Signal-style grouped corners
stay tighter). */
.bubble.has-media {
border-radius: 12px;
}
.media-img { .media-img {
cursor: pointer; cursor: pointer;
} }
+1
View File
@@ -53,6 +53,7 @@ describe('toNewMessage (MMS)', () => {
expect(toNewMessage({ ...mms, message: 'MMS Received', col_media1: url }).body).toBe('') 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\n', col_media1: url }).body).toBe('')
expect(toNewMessage({ ...mms, message: 'MMS Received, thanks', col_media1: url }).body).toBe('MMS Received, thanks') expect(toNewMessage({ ...mms, message: 'MMS Received, thanks', col_media1: url }).body).toBe('MMS Received, thanks')
expect(toNewMessage({ ...mms, message: 'MMS Sent', col_media1: url }).body).toBe('')
// Typed by a person, with no picture: kept. // Typed by a person, with no picture: kept.
expect(toNewMessage({ ...mms, message: 'MMS received', col_media1: '' }).body).toBe('MMS received') expect(toNewMessage({ ...mms, message: 'MMS received', col_media1: '' }).body).toBe('MMS received')
}) })