Preferences: one Accounts page (voip.ms, Google Voice, Numbers with checking), and jai gets its own page
This commit is contained in:
+1
-1
@@ -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
@@ -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.
|
||||||
|
|||||||
@@ -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,21 +126,14 @@ export function SettingsDialog({ state, sync, onClose, onChanged }: Props) {
|
|||||||
</section>
|
</section>
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
Account: (
|
Accounts: (
|
||||||
|
<>
|
||||||
<section className="group">
|
<section className="group">
|
||||||
<h3>voip.ms</h3>
|
<h3>voip.ms</h3>
|
||||||
<div className="kv">
|
<div className="kv">
|
||||||
<span>voip.ms user</span>
|
<span>voip.ms user</span>
|
||||||
<span>{state.username}</span>
|
<span>{state.username}</span>
|
||||||
</div>
|
</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">
|
<div className="kv">
|
||||||
<span>Password stored in</span>
|
<span>Password stored in</span>
|
||||||
<span>
|
<span>
|
||||||
@@ -160,13 +153,12 @@ export function SettingsDialog({ state, sync, onClose, onChanged }: Props) {
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
),
|
<GoogleVoiceSection number={state.gvoiceNumber} status={sync?.gvoice} onChanged={onChanged} />
|
||||||
'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>Numbers</h3>
|
||||||
|
{smsDids.length > 0 && (
|
||||||
|
<>
|
||||||
|
<p className="muted small">Sync these voip.ms numbers:</p>
|
||||||
{smsDids.map((d) => (
|
{smsDids.map((d) => (
|
||||||
<label key={d.did} className="did">
|
<label key={d.did} className="did">
|
||||||
<input
|
<input
|
||||||
@@ -185,6 +177,8 @@ export function SettingsDialog({ state, sync, onClose, onChanged }: Props) {
|
|||||||
<span className="muted">{d.description}</span>
|
<span className="muted">{d.description}</span>
|
||||||
</label>
|
</label>
|
||||||
))}
|
))}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
{sendFrom.length > 1 && (
|
{sendFrom.length > 1 && (
|
||||||
<label className="field">
|
<label className="field">
|
||||||
Send new chats from
|
Send new chats from
|
||||||
@@ -198,12 +192,6 @@ export function SettingsDialog({ state, sync, onClose, onChanged }: Props) {
|
|||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
)}
|
)}
|
||||||
</section>
|
|
||||||
)
|
|
||||||
}),
|
|
||||||
Sync: (
|
|
||||||
<section className="group">
|
|
||||||
<h3>Checking</h3>
|
|
||||||
<label className="field">
|
<label className="field">
|
||||||
Check for new messages every
|
Check for new messages every
|
||||||
<select value={s.pollSeconds} onChange={(e) => change({ ...s, pollSeconds: Number(e.target.value) })}>
|
<select value={s.pollSeconds} onChange={(e) => change({ ...s, pollSeconds: Number(e.target.value) })}>
|
||||||
@@ -216,16 +204,28 @@ export function SettingsDialog({ state, sync, onClose, onChanged }: Props) {
|
|||||||
</label>
|
</label>
|
||||||
<label className="field">
|
<label className="field">
|
||||||
Import history back to
|
Import history back to
|
||||||
<input type="date" value={s.backfillFloor} onChange={(e) => e.target.value && change({ ...s, backfillFloor: e.target.value })} />
|
<input
|
||||||
|
type="date"
|
||||||
|
value={s.backfillFloor}
|
||||||
|
onChange={(e) => e.target.value && change({ ...s, backfillFloor: e.target.value })}
|
||||||
|
/>
|
||||||
</label>
|
</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>
|
||||||
),
|
|
||||||
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 & backups</h3>
|
<h3>Storage & 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
|
||||||
|
|||||||
Reference in New Issue
Block a user