Files
bubble/src/main/sandbox.ts
T
trav cde8cc6c55 v0.2.0: bubble for Android 0.2.0 — chat search, swipe for unread, faster chat opening
Desktop:
- Search lists chats whose own name matches first, so a named group
  isn't pushed out of the top 8 by chats that merely include a member.

Android (Rabbit R1) app, 0.2.0:
- Pull the chat list past its top for a search box (name, person,
  number, then group members; archived chats too; Back clears it).
- Swipe right to left marks a chat unread / read over a magenta band;
  left to right still archives (SwipeActions replaces SwipeArchive).
- Google Voice chats don't offer voice notes in the paperclip bubble.
- Chats open with their newest 60 messages, then the full history;
  marking read (and the Google Voice network call) waits until they're
  on screen. Cached pictures show at once, and one slow download no
  longer blocks the other images. Fixed a contacts reload race.
- Sandbox data gains filler chats, a named group and a 4,000-message chat.

Also: the Android app, Google Voice support, media, export, emoji and
the other work since the first commit, and a CLAUDE.md carrying the
privacy rule.
2026-11-06 02:19:56 -08:00

75 lines
3.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Sandbox mode, for trying the app (and UI work) without going anywhere near
// the real account: VOIPMS_SANDBOX=<dir> (or VOIPMS_DEMO=1, which uses a temp
// dir) keeps *everything* under <dir> -- the Electron profile (so no saved
// voip.ms password and no Google sign-in), settings, and the message database
// -- skips the system address book, and fills an empty database with made-up
// conversations. Imported first by index.ts so it applies before anything
// reads a path.
import { app } from 'electron'
import os from 'node:os'
import path from 'node:path'
import type { MessageDb, NewMessage } from './db'
import { gvMessageId } from './gvoice/sync'
export const SANDBOX: string | undefined =
process.env['VOIPMS_SANDBOX'] || (process.env['VOIPMS_DEMO'] ? path.join(os.tmpdir(), 'voipms-sandbox') : undefined)
if (SANDBOX) {
app.setPath('userData', path.join(SANDBOX, 'profile'))
process.env['VOIPMS_DATA_DIR'] = path.join(SANDBOX, 'data')
console.log(`[sandbox] everything lives in ${SANDBOX}`)
} else {
// The app was "voip.ms Messages" before it was bubble, and Electron names
// the profile folder after the app: keep using the old one so the saved
// login, Google sign-in and data-location pointer carry over.
app.setPath('userData', path.join(app.getPath('appData'), 'voip.ms Messages'))
}
// Fictional numbers (555-01xx is reserved for fiction).
export const DEMO_VOIP = '5415550100'
export const DEMO_GV = '5415550177'
export function seedDemo(db: MessageDb): void {
if (db.count() > 0) return
const now = Date.now()
const min = 60_000
const group = '5415550101,5415550102,5415550103'
let id = 1000
const v = (contact: string, direction: 'in' | 'out', body: string, ago: number): NewMessage => ({
id: id++,
did: DEMO_VOIP,
contact,
direction,
body,
ts: now - ago * min
})
const g = (contact: string, direction: 'in' | 'out', body: string, ago: number, sender?: string): NewMessage => ({
id: gvMessageId(`demo-${id++}`),
did: DEMO_GV,
contact,
direction,
body,
ts: now - ago * min,
...(sender ? { sender } : {})
})
db.upsertMessages([
v('5415550110', 'in', 'Are we still on for Saturday?', 300),
v('5415550110', 'out', 'Yep! 10am at the market', 290),
v('5415550111', 'in', 'Your table is ready', 2000),
g('5415550120', 'in', 'Package left at the front door', 90),
g('5415550120', 'out', 'Thanks!', 85),
g(group, 'in', 'Who is bringing snacks to the hike?', 40, '5415550101'),
g(group, 'in', 'I can do chips', 38, '5415550102'),
g(group, 'in', 'and salsa', 37, '5415550102'),
g(group, 'out', 'I’ll bring cookies 🍪', 30),
g(group, 'in', 'Loved “I’ll bring cookies 🍪”', 29, '5415550101'),
g(group, 'in', 'Laughed at “I’ll bring cookies 🍪”', 28, '5415550103'),
g(group, 'in', 'Perfect, see everyone at 9', 5, '5415550103'),
g(group, 'in', 'Emphasized “Perfect, see everyone at 9”', 4, '5415550102')
])
db.setGvThread(DEMO_GV, group, 'g.demo')
db.set('unread_floor', '0')
db.set('gv_number', DEMO_GV)
db.set('dids', JSON.stringify([{ did: DEMO_VOIP, description: 'Demo', smsEnabled: true }]))
}