Preferences: one Accounts page (voip.ms, Google Voice, Numbers with checking), and jai gets its own page

This commit is contained in:
2026-11-08 20:42:18 -08:00
parent 4d0c15757d
commit 8927c5c59c
3 changed files with 88 additions and 88 deletions
+1 -1
View File
@@ -137,7 +137,7 @@ function startRelay(): void {
// A text over the Rabbit's SIM: pending here until the Rabbit's next check // A text over the Rabbit's SIM: pending here until the Rabbit's next check
// sends it and says how it went (relay.ts). // sends it and says how it went (relay.ts).
function relaySend(contact: string, text: string, refs: MediaRef[]): void { function relaySend(contact: string, text: string, refs: MediaRef[]): void {
if (!relay) throw new Error('The Rabbit relay is off: connect it in Settings → Rabbit.') if (!relay) throw new Error('The Rabbit relay is off: connect it in Settings → jai.')
const kind = refs.length || isGroup(contact) ? 'mms' : 'sms' const kind = refs.length || isGroup(contact) ? 'mms' : 'sms'
const tempId = db.insertPending({ did: SIM_DID, contact, direction: 'out', body: text, ts: Date.now(), kind, ...(refs.length ? { media: refs } : {}) }) const tempId = db.insertPending({ did: SIM_DID, contact, direction: 'out', body: text, ts: Date.now(), kind, ...(refs.length ? { media: refs } : {}) })
relay.send(tempId, contact, text, refs) relay.send(tempId, contact, text, refs)
+1 -1
View File
@@ -228,7 +228,7 @@ export class RelayEngine extends EventEmitter {
body: JSON.stringify({ device: 'desktop', since, push: push.map((r) => r.blob) }), body: JSON.stringify({ device: 'desktop', since, push: push.map((r) => r.blob) }),
signal: AbortSignal.timeout(120_000) signal: AbortSignal.timeout(120_000)
}) })
if (res.status === 401) throw new Error('jai turned down the token. Check it in Settings → Rabbit.') if (res.status === 401) throw new Error('jai turned down the token. Check it in Settings → jai.')
if (!res.ok) throw new Error(`jai answered ${res.status}`) if (!res.ok) throw new Error(`jai answered ${res.status}`)
const body = (await res.json()) as { cursor: number; events: string[]; more: boolean } const body = (await res.json()) as { cursor: number; events: string[]; more: boolean }
// Only now that jai has them: out of the outbox. // Only now that jai has them: out of the outbox.
+86 -86
View File
@@ -18,7 +18,7 @@ export function SettingsDialog({ state, sync, onClose, onChanged }: Props) {
const [s, setS] = useState<Settings>(state.settings) const [s, setS] = useState<Settings>(state.settings)
const [note, setNote] = useState<string>() const [note, setNote] = useState<string>()
const [page, setPage] = useState('Appearance') const [page, setPage] = useState('Appearance')
// voip.ms numbers; Google Voice has its own page. // voip.ms numbers; Google Voice has its own section.
const smsDids = state.dids.filter((d) => d.smsEnabled && d.provider !== 'gvoice') const smsDids = state.dids.filter((d) => d.smsEnabled && d.provider !== 'gvoice')
useEffect(() => { useEffect(() => {
@@ -126,65 +126,59 @@ export function SettingsDialog({ state, sync, onClose, onChanged }: Props) {
</section> </section>
</> </>
), ),
Account: ( Accounts: (
<section className="group"> <>
<h3>voip.ms</h3>
<div className="kv">
<span>voip.ms user</span>
<span>{state.username}</span>
</div>
<div className="kv">
<span>Messages stored</span>
<span>{sync?.total.toLocaleString() ?? '—'}</span>
</div>
<div className="kv">
<span>History import</span>
<span>{sync?.backfillDone ? 'Complete' : sync?.backfillCursor ? `In progress (back to ${sync.backfillCursor})` : 'Pending'}</span>
</div>
<div className="kv">
<span>Password stored in</span>
<span>
{state.keyringBackend.startsWith('gnome') || state.keyringBackend.includes('libsecret')
? 'GNOME Keyring'
: state.keyringBackend}
</span>
</div>
<div className="btn-row">
<button
className="danger"
onClick={() => {
void window.api.signOut().then(onChanged)
}}
>
Sign out
</button>
</div>
</section>
),
'Google Voice': <GoogleVoiceSection number={state.gvoiceNumber} status={sync?.gvoice} onChanged={onChanged} />,
Contacts: <ContactsSection value={s.contactBook} onChange={(contactBook) => change({ ...s, contactBook })} />,
...(smsDids.length > 0 && {
Numbers: (
<section className="group"> <section className="group">
<h3>Numbers to sync</h3> <h3>voip.ms</h3>
{smsDids.map((d) => ( <div className="kv">
<label key={d.did} className="did"> <span>voip.ms user</span>
<input <span>{state.username}</span>
type="checkbox" </div>
checked={synced.includes(d.did)} <div className="kv">
onChange={(e) => { <span>Password stored in</span>
const next = e.target.checked ? [...synced, d.did] : synced.filter((x) => x !== d.did) <span>
if (next.length) {state.keyringBackend.startsWith('gnome') || state.keyringBackend.includes('libsecret')
change({ ? 'GNOME Keyring'
...s, : state.keyringBackend}
dids: next.length === smsDids.length ? [] : next </span>
}) </div>
}} <div className="btn-row">
/> <button
<span>{formatNumber(d.did)}</span> className="danger"
<span className="muted">{d.description}</span> onClick={() => {
</label> void window.api.signOut().then(onChanged)
))} }}
>
Sign out
</button>
</div>
</section>
<GoogleVoiceSection number={state.gvoiceNumber} status={sync?.gvoice} onChanged={onChanged} />
<section className="group">
<h3>Numbers</h3>
{smsDids.length > 0 && (
<>
<p className="muted small">Sync these voip.ms numbers:</p>
{smsDids.map((d) => (
<label key={d.did} className="did">
<input
type="checkbox"
checked={synced.includes(d.did)}
onChange={(e) => {
const next = e.target.checked ? [...synced, d.did] : synced.filter((x) => x !== d.did)
if (next.length)
change({
...s,
dids: next.length === smsDids.length ? [] : next
})
}}
/>
<span>{formatNumber(d.did)}</span>
<span className="muted">{d.description}</span>
</label>
))}
</>
)}
{sendFrom.length > 1 && ( {sendFrom.length > 1 && (
<label className="field"> <label className="field">
Send new chats from Send new chats from
@@ -198,34 +192,40 @@ export function SettingsDialog({ state, sync, onClose, onChanged }: Props) {
</select> </select>
</label> </label>
)} )}
<label className="field">
Check for new messages every
<select value={s.pollSeconds} onChange={(e) => change({ ...s, pollSeconds: Number(e.target.value) })}>
{[10, 15, 30, 60, 120, 300].map((n) => (
<option key={n} value={n}>
{n < 60 ? `${n} seconds` : `${n / 60} minute${n > 60 ? 's' : ''}`}
</option>
))}
</select>
</label>
<label className="field">
Import history back to
<input
type="date"
value={s.backfillFloor}
onChange={(e) => e.target.value && change({ ...s, backfillFloor: e.target.value })}
/>
</label>
<div className="kv">
<span>Messages stored</span>
<span>{sync?.total.toLocaleString() ?? '—'}</span>
</div>
<div className="kv">
<span>History import</span>
<span>
{sync?.backfillDone ? 'Complete' : sync?.backfillCursor ? `In progress (back to ${sync.backfillCursor})` : 'Pending'}
</span>
</div>
</section> </section>
)
}),
Sync: (
<section className="group">
<h3>Checking</h3>
<label className="field">
Check for new messages every
<select value={s.pollSeconds} onChange={(e) => change({ ...s, pollSeconds: Number(e.target.value) })}>
{[10, 15, 30, 60, 120, 300].map((n) => (
<option key={n} value={n}>
{n < 60 ? `${n} seconds` : `${n / 60} minute${n > 60 ? 's' : ''}`}
</option>
))}
</select>
</label>
<label className="field">
Import history back to
<input type="date" value={s.backfillFloor} onChange={(e) => e.target.value && change({ ...s, backfillFloor: e.target.value })} />
</label>
</section>
),
Rabbit: (
<>
<RabbitSection onChanged={onChanged} />
<RelaySection onChanged={onChanged} />
</> </>
), ),
Contacts: <ContactsSection value={s.contactBook} onChange={(contactBook) => change({ ...s, contactBook })} />,
Rabbit: <RabbitSection onChanged={onChanged} />,
jai: <RelaySection onChanged={onChanged} />,
Storage: ( Storage: (
<section className="group"> <section className="group">
<h3>Storage &amp; backups</h3> <h3>Storage &amp; backups</h3>
@@ -526,7 +526,7 @@ function RelaySection({ onChanged }: { onChanged: () => void }) {
.relayConnect(url, token) .relayConnect(url, token)
.then(() => { .then(() => {
setToken('') setToken('')
setDone('Connected. Now use Sync to Rabbit (above) once, with the Rabbit plugged in, so it gets the key.') setDone('Connected. Now use Sync to Rabbit (on the Rabbit page) once, with the Rabbit plugged in, so it gets the key.')
refresh() refresh()
onChanged() onChanged()
}) })
@@ -550,7 +550,7 @@ function RelaySection({ onChanged }: { onChanged: () => void }) {
: undefined : undefined
return ( return (
<section className="group"> <section className="group">
<h3>Rabbit relay (jai)</h3> <h3>Rabbit relay</h3>
<p className="muted small"> <p className="muted small">
Texts the Rabbit's SIM card sends and gets show up here, you can text from it here (as "Rabbit SIM"), and chat names and Texts the Rabbit's SIM card sends and gets show up here, you can text from it here (as "Rabbit SIM"), and chat names and
read/unread/archived stay in step with the Rabbit without plugging it in. It goes through jai, which only passes on sealed messages read/unread/archived stay in step with the Rabbit without plugging it in. It goes through jai, which only passes on sealed messages