Desktop: the travewave house look (shared-resources design.html), switchable with Signal vibes
Preferences → Appearance → Style picks Signal vibes (the look so far) or travewave: house grays, embossed buttons and tiles, a debossed chat-name panel, 8 px framed lists, button-like scrollbars, Century Gothic for names and messages. Either way the window is now one rounded frameless tile with its own title bar (GNOME's button layout) and a menu bar shown by tapping Alt (Edit → Preferences…, Ctrl+,), tooltips drawn by the page with a "Show tooltips" preference, and Preferences laid out like VLC's (categories left, changes apply at once, Close).
This commit is contained in:
+59
-5
@@ -1,6 +1,7 @@
|
||||
// First: in sandbox mode this moves every path the app uses (see sandbox.ts).
|
||||
import { SANDBOX, seedDemo } from './sandbox'
|
||||
import { app, BrowserWindow, clipboard, ClipboardItem, dialog, ipcMain, nativeTheme, net, protocol, safeStorage, shell } from 'electron'
|
||||
import { app, BrowserWindow, clipboard, ClipboardItem, dialog, ipcMain, nativeTheme, net, protocol, safeStorage, screen, shell } from 'electron'
|
||||
import { execFileSync } from 'node:child_process'
|
||||
import crypto from 'node:crypto'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
@@ -8,7 +9,7 @@ import os from 'node:os'
|
||||
import { pathToFileURL } from 'node:url'
|
||||
import { charCount, groupMembers, isGroup, normalizeNumber, SMS_TEXT_LIMIT } from '@shared/phone'
|
||||
import type { ChatExport, IconStyle, Credentials, Did, MediaRef, Message, NewContact, OutgoingAttachment, Provider, Settings, SyncStatus, Theme } from '@shared/types'
|
||||
import type { AppState } from '@shared/api'
|
||||
import type { AppState, WindowAction, WindowState } from '@shared/api'
|
||||
import { addToAddressBook, ContactDirectory, listAddressBooks } from './contacts'
|
||||
import { localDay, MessageDb, type NewMessage } from './db'
|
||||
import { MediaStore } from './media'
|
||||
@@ -337,8 +338,42 @@ function applyTheme(): void {
|
||||
win?.setBackgroundColor(windowBackground())
|
||||
}
|
||||
|
||||
// The window itself stays transparent: the page paints its rounded tile.
|
||||
function windowBackground(): string {
|
||||
return nativeTheme.shouldUseDarkColors ? '#121212' : '#ffffff'
|
||||
return '#00000000'
|
||||
}
|
||||
|
||||
// ---- the window's own frame (design.html#window, #titlebar) ----
|
||||
// Square corners when maximized, fullscreen or tiled. Wayland doesn't tell
|
||||
// us about tiling, so a window within 64 px of the screen's full height
|
||||
// counts as tiled.
|
||||
function windowState(): WindowState {
|
||||
if (!win) return { square: false, maximized: false, focused: true }
|
||||
const maximized = win.isMaximized()
|
||||
const full = screen.getDisplayMatching(win.getBounds()).bounds
|
||||
const tiled = full.height - win.getBounds().height <= 64
|
||||
return { square: maximized || win.isFullScreen() || tiled, maximized, focused: win.isFocused() }
|
||||
}
|
||||
|
||||
function sendWindowState(): void {
|
||||
if (win && !win.isDestroyed()) win.webContents.send('windowState', windowState())
|
||||
}
|
||||
|
||||
// GNOME's button-layout ("appmenu:minimize,maximize,close"): which side
|
||||
// the window buttons go on, and in what order.
|
||||
let buttonLayout: string | undefined
|
||||
function windowButtons(): string {
|
||||
if (buttonLayout === undefined) {
|
||||
try {
|
||||
buttonLayout = execFileSync('gsettings', ['get', 'org.gnome.desktop.wm.preferences', 'button-layout'], { encoding: 'utf8' })
|
||||
.trim()
|
||||
.replace(/^'|'$/g, '')
|
||||
} catch {
|
||||
buttonLayout = ''
|
||||
}
|
||||
if (!buttonLayout.includes(':')) buttonLayout = 'appmenu:minimize,maximize,close'
|
||||
}
|
||||
return buttonLayout
|
||||
}
|
||||
|
||||
const ZOOM_STEP = 0.5
|
||||
@@ -534,6 +569,20 @@ function registerIpc(): void {
|
||||
gvSync?.resetBackfill()
|
||||
}
|
||||
})
|
||||
ipcMain.handle('windowState', () => windowState())
|
||||
ipcMain.handle('windowButtons', () => windowButtons())
|
||||
ipcMain.handle('windowControl', (_e, action: WindowAction) => {
|
||||
if (!win) return
|
||||
if (action === 'zoomIn') setZoom(win.webContents.getZoomLevel() + ZOOM_STEP)
|
||||
else if (action === 'zoomOut') setZoom(win.webContents.getZoomLevel() - ZOOM_STEP)
|
||||
else if (action === 'zoomReset') setZoom(0)
|
||||
else if (action === 'minimize') win.minimize()
|
||||
else if (action === 'maximize') {
|
||||
if (win.isMaximized()) win.unmaximize()
|
||||
else win.maximize()
|
||||
} else if (action === 'close') win.close()
|
||||
else app.quit()
|
||||
})
|
||||
ipcMain.handle('setIcon', (_e, icon: IconStyle) => {
|
||||
settings = { ...settings, icon }
|
||||
saveSettings(settings)
|
||||
@@ -688,8 +737,11 @@ function createWindow(): void {
|
||||
minWidth: 760,
|
||||
minHeight: 480,
|
||||
title: SANDBOX ? 'bubble (sandbox)' : 'bubble',
|
||||
backgroundColor: windowBackground(),
|
||||
autoHideMenuBar: true,
|
||||
// design.html#window: frameless and see-through; the page paints the
|
||||
// rounded tile, its own title bar (#titlebar) and menu bar (#menubar).
|
||||
frame: false,
|
||||
transparent: true,
|
||||
backgroundColor: '#00000000',
|
||||
icon: iconFile(settings.icon),
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, '../preload/index.js'),
|
||||
@@ -724,6 +776,8 @@ function createWindow(): void {
|
||||
win.webContents.on('did-finish-load', () => win!.webContents.setZoomLevel(loadZoom()))
|
||||
// The hidden Google Voice window would otherwise keep 'window-all-closed'
|
||||
// from firing, leaving a windowless process holding the single-instance lock.
|
||||
for (const ev of ['maximize', 'unmaximize', 'enter-full-screen', 'leave-full-screen', 'resize', 'focus', 'blur'] as const)
|
||||
win.on(ev as 'resize', sendWindowState)
|
||||
win.on('closed', () => {
|
||||
win = undefined
|
||||
app.quit()
|
||||
|
||||
@@ -13,6 +13,10 @@ const api: Api = {
|
||||
saveSetup: (creds, settings) => ipcRenderer.invoke('saveSetup', creds, settings),
|
||||
updateSettings: (settings) => ipcRenderer.invoke('updateSettings', settings),
|
||||
setTheme: (theme) => ipcRenderer.invoke('setTheme', theme),
|
||||
windowState: () => ipcRenderer.invoke('windowState'),
|
||||
onWindowState: (cb) => on('windowState', cb),
|
||||
windowButtons: () => ipcRenderer.invoke('windowButtons'),
|
||||
windowControl: (action) => ipcRenderer.invoke('windowControl', action),
|
||||
setIcon: (icon) => ipcRenderer.invoke('setIcon', icon),
|
||||
signOut: () => ipcRenderer.invoke('signOut'),
|
||||
connectGoogleVoice: () => ipcRenderer.invoke('connectGoogleVoice'),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<html lang="en" data-look="trave">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>bubble</title>
|
||||
|
||||
+54
-19
@@ -1,4 +1,4 @@
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import { useCallback, useEffect, useMemo, useState, type JSX, type ReactNode } from 'react'
|
||||
import type { AppState } from '@shared/api'
|
||||
import type { ContactInfo, Conversation, SyncStatus } from '@shared/types'
|
||||
import { Sidebar, type SidebarMode } from './components/Sidebar'
|
||||
@@ -8,6 +8,8 @@ import { SettingsDialog } from './components/SettingsDialog'
|
||||
import { ConversationInfo } from './components/ConversationInfo'
|
||||
import { AddContact, AddContactContext } from './components/AddContact'
|
||||
import { ExportChat } from './components/ExportChat'
|
||||
import { Frame, onCommand, runCommand } from './components/Frame'
|
||||
import { setTooltipsEnabled } from './tooltips'
|
||||
|
||||
export interface ConvKey {
|
||||
did: string
|
||||
@@ -19,8 +21,7 @@ export interface Jump {
|
||||
nonce: number
|
||||
}
|
||||
|
||||
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() {
|
||||
const [state, setState] = useState<AppState>()
|
||||
@@ -86,17 +87,47 @@ export function App() {
|
||||
// The list currently shown in the sidebar (for Alt+↑/↓).
|
||||
const listed = useMemo(() => conversations.filter((c) => c.archived === archiveView), [conversations, archiveView])
|
||||
|
||||
// Keyboard shortcuts (Signal-like).
|
||||
useEffect(() => setTooltipsEnabled(state?.settings.showTooltips !== false), [state?.settings.showTooltips])
|
||||
// Which look the stylesheet draws (styles.css): the house look unless Signal vibes are chosen.
|
||||
useEffect(() => {
|
||||
if (state) document.documentElement.dataset.look = state.settings.look ?? 'trave'
|
||||
}, [state])
|
||||
|
||||
// The menu bar's commands (they work with the bar hidden too).
|
||||
useEffect(
|
||||
() =>
|
||||
onCommand((c) => {
|
||||
if (!state?.configured) return
|
||||
if (c === 'find') {
|
||||
setMode('search')
|
||||
document.getElementById('sidebar-search')?.focus()
|
||||
} else if (c === 'newChat') setMode('compose')
|
||||
else if (c === 'preferences') setSettingsOpen(true)
|
||||
else if (c === 'archived') setArchiveView((v) => !v)
|
||||
else if (c === 'checkNow') void window.api.pollNow()
|
||||
}),
|
||||
[state?.configured]
|
||||
)
|
||||
|
||||
// Keyboard shortcuts (Signal-like, plus the menu bar's).
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent): void => {
|
||||
const mod = e.ctrlKey || e.metaKey
|
||||
if (mod && !e.shiftKey && e.key.toLowerCase() === 'f') {
|
||||
e.preventDefault()
|
||||
setMode('search')
|
||||
document.getElementById('sidebar-search')?.focus()
|
||||
runCommand('find')
|
||||
} else if (mod && e.key.toLowerCase() === 'n') {
|
||||
e.preventDefault()
|
||||
setMode('compose')
|
||||
runCommand('newChat')
|
||||
} else if (mod && e.key === ',') {
|
||||
e.preventDefault()
|
||||
runCommand('preferences')
|
||||
} else if (mod && e.key.toLowerCase() === 'q') {
|
||||
e.preventDefault()
|
||||
void window.api.windowControl('quit')
|
||||
} else if (e.key === 'F5') {
|
||||
e.preventDefault()
|
||||
runCommand('checkNow')
|
||||
} else if (e.altKey && (e.key === 'ArrowDown' || e.key === 'ArrowUp') && listed.length) {
|
||||
e.preventDefault()
|
||||
const i = listed.findIndex((c) => sameConv(c, selected))
|
||||
@@ -108,10 +139,15 @@ export function App() {
|
||||
return () => window.removeEventListener('keydown', onKey)
|
||||
}, [listed, selected, open])
|
||||
|
||||
if (!state) return <div className="app loading" />
|
||||
if (!state.configured) return <Setup initial={state} onDone={refreshState} />
|
||||
const frame = (body: ReactNode): JSX.Element => (
|
||||
<Frame title={document.title} configured={!!state?.configured} hideMenuBar={state?.settings.hideMenuBar !== false}>
|
||||
{body}
|
||||
</Frame>
|
||||
)
|
||||
if (!state) return frame(<div className="app loading" />)
|
||||
if (!state.configured) return frame(<Setup initial={state} onDone={refreshState} />)
|
||||
|
||||
return (
|
||||
return frame(
|
||||
<AddContactContext.Provider value={setAdding}>
|
||||
<div className="app">
|
||||
<Sidebar
|
||||
@@ -162,17 +198,16 @@ export function App() {
|
||||
</main>
|
||||
)}
|
||||
{info && (
|
||||
<ConversationInfo conv={info} name={named(info)} contactMap={contactMap} gvNumber={state.gvoiceNumber} onClose={() => setInfo(null)} />
|
||||
)}
|
||||
{exporting && <ExportChat conv={exporting} name={named(exporting)} contactMap={contactMap} onClose={() => setExporting(null)} />}
|
||||
{settingsOpen && (
|
||||
<SettingsDialog
|
||||
state={state}
|
||||
sync={sync}
|
||||
onClose={() => setSettingsOpen(false)}
|
||||
onChanged={refreshState}
|
||||
<ConversationInfo
|
||||
conv={info}
|
||||
name={named(info)}
|
||||
contactMap={contactMap}
|
||||
gvNumber={state.gvoiceNumber}
|
||||
onClose={() => setInfo(null)}
|
||||
/>
|
||||
)}
|
||||
{exporting && <ExportChat conv={exporting} name={named(exporting)} contactMap={contactMap} onClose={() => setExporting(null)} />}
|
||||
{settingsOpen && <SettingsDialog state={state} sync={sync} onClose={() => setSettingsOpen(false)} onChanged={refreshState} />}
|
||||
{adding && <AddContact number={adding} defaultBook={state.settings.contactBook} onClose={() => setAdding(null)} />}
|
||||
</div>
|
||||
</AddContactContext.Provider>
|
||||
|
||||
@@ -274,12 +274,14 @@ export function ChatView({ conv, contact, contactMap, conversations, onOpen, nam
|
||||
}}
|
||||
/>
|
||||
<span className="hit-count">{q.trim() ? (hits.length ? `${hitIdx + 1} of ${hits.length}` : 'No results') : ''}</span>
|
||||
<div className="tiles">
|
||||
<button className="icon-btn small" title="Older (Enter)" disabled={!hits.length} onClick={() => stepHit(1)}>
|
||||
<UpIcon />
|
||||
</button>
|
||||
<button className="icon-btn small" title="Newer (Shift+Enter)" disabled={!hits.length} onClick={() => stepHit(-1)}>
|
||||
<DownIcon />
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
className="icon-btn small"
|
||||
title="Close"
|
||||
|
||||
@@ -80,7 +80,7 @@ export function Composer({ conv, isNew, smsDids, gvNumber, onChangeDid, ref }: P
|
||||
const el = textarea.current
|
||||
if (el) {
|
||||
el.style.height = 'auto'
|
||||
el.style.height = `${Math.min(el.scrollHeight, 200)}px`
|
||||
el.style.height = `${Math.min(el.scrollHeight + el.offsetHeight - el.clientHeight, 200)}px`
|
||||
}
|
||||
}, [text, key])
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ export interface MenuItem {
|
||||
onSelect: () => void
|
||||
disabled?: boolean
|
||||
separator?: boolean // draw a line above this item
|
||||
shortcut?: string // shown on the right (the menu bar's menus)
|
||||
}
|
||||
|
||||
// A small right-click menu at (x, y), kept inside the window. Closes on any
|
||||
@@ -53,6 +54,7 @@ export function ContextMenu({ x, y, items, onClose }: { x: number; y: number; it
|
||||
}}
|
||||
>
|
||||
{it.label}
|
||||
{it.shortcut && <span className="menu-shortcut">{it.shortcut}</span>}
|
||||
</button>
|
||||
])}
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,326 @@
|
||||
import { useEffect, useRef, useState, type ReactNode } from 'react'
|
||||
import type { WindowAction, WindowState } from '@shared/api'
|
||||
import { ContextMenu, type MenuItem } from './ContextMenu'
|
||||
|
||||
// The window's own frame, after design.html: one rounded tile (#window), a
|
||||
// title bar in the window gray (#titlebar) and a menu bar that can hide
|
||||
// until Alt is tapped (#menubar). The page asks for commands by name; the
|
||||
// app listens with onCommand.
|
||||
|
||||
export type Command = 'newChat' | 'find' | 'preferences' | 'archived' | 'checkNow'
|
||||
|
||||
export function runCommand(c: Command): void {
|
||||
window.dispatchEvent(new CustomEvent<Command>('bubble-command', { detail: c }))
|
||||
}
|
||||
|
||||
export function onCommand(cb: (c: Command) => void): () => void {
|
||||
const listener = (e: Event): void => cb((e as CustomEvent<Command>).detail)
|
||||
window.addEventListener('bubble-command', listener)
|
||||
return () => window.removeEventListener('bubble-command', listener)
|
||||
}
|
||||
|
||||
const control = (a: WindowAction) => () => void window.api.windowControl(a)
|
||||
const edit = (cmd: string) => () => {
|
||||
document.execCommand(cmd)
|
||||
}
|
||||
|
||||
interface Menu {
|
||||
label: string
|
||||
key: string // its Alt+letter
|
||||
items: MenuItem[]
|
||||
}
|
||||
|
||||
function menus(configured: boolean): Menu[] {
|
||||
const app: Menu['items'] = configured
|
||||
? [
|
||||
{
|
||||
label: 'New chat',
|
||||
shortcut: 'Ctrl+N',
|
||||
onSelect: () => runCommand('newChat')
|
||||
},
|
||||
{
|
||||
label: 'Check for new messages',
|
||||
shortcut: 'F5',
|
||||
onSelect: () => runCommand('checkNow')
|
||||
}
|
||||
]
|
||||
: []
|
||||
return [
|
||||
{
|
||||
label: 'File',
|
||||
key: 'f',
|
||||
items: [
|
||||
...app,
|
||||
{
|
||||
label: 'Quit',
|
||||
shortcut: 'Ctrl+Q',
|
||||
onSelect: control('quit'),
|
||||
separator: configured
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'Edit',
|
||||
key: 'e',
|
||||
items: [
|
||||
{ label: 'Undo', shortcut: 'Ctrl+Z', onSelect: edit('undo') },
|
||||
{ label: 'Redo', shortcut: 'Ctrl+Shift+Z', onSelect: edit('redo') },
|
||||
{
|
||||
label: 'Cut',
|
||||
shortcut: 'Ctrl+X',
|
||||
onSelect: edit('cut'),
|
||||
separator: true
|
||||
},
|
||||
{ label: 'Copy', shortcut: 'Ctrl+C', onSelect: edit('copy') },
|
||||
{ label: 'Paste', shortcut: 'Ctrl+V', onSelect: edit('paste') },
|
||||
{
|
||||
label: 'Select all',
|
||||
shortcut: 'Ctrl+A',
|
||||
onSelect: edit('selectAll')
|
||||
},
|
||||
...(configured
|
||||
? [
|
||||
{
|
||||
label: 'Find…',
|
||||
shortcut: 'Ctrl+F',
|
||||
onSelect: () => runCommand('find'),
|
||||
separator: true
|
||||
},
|
||||
{
|
||||
label: 'Preferences…',
|
||||
shortcut: 'Ctrl+,',
|
||||
onSelect: () => runCommand('preferences'),
|
||||
separator: true
|
||||
}
|
||||
]
|
||||
: [])
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'View',
|
||||
key: 'v',
|
||||
items: [
|
||||
...(configured
|
||||
? [
|
||||
{
|
||||
label: 'Archived chats',
|
||||
onSelect: () => runCommand('archived')
|
||||
}
|
||||
]
|
||||
: []),
|
||||
{
|
||||
label: 'Zoom in',
|
||||
shortcut: 'Ctrl++',
|
||||
onSelect: control('zoomIn'),
|
||||
separator: configured
|
||||
},
|
||||
{ label: 'Zoom out', shortcut: 'Ctrl+−', onSelect: control('zoomOut') },
|
||||
{
|
||||
label: 'Actual size',
|
||||
shortcut: 'Ctrl+0',
|
||||
onSelect: control('zoomReset')
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
function useWindowState(): WindowState {
|
||||
const [st, setSt] = useState<WindowState>({
|
||||
square: false,
|
||||
maximized: false,
|
||||
focused: true
|
||||
})
|
||||
useEffect(() => {
|
||||
void window.api.windowState().then(setSt)
|
||||
return window.api.onWindowState(setSt)
|
||||
}, [])
|
||||
return st
|
||||
}
|
||||
|
||||
export function Frame({
|
||||
title,
|
||||
configured,
|
||||
hideMenuBar,
|
||||
children
|
||||
}: {
|
||||
title: string
|
||||
configured: boolean
|
||||
hideMenuBar: boolean
|
||||
children: ReactNode
|
||||
}) {
|
||||
const st = useWindowState()
|
||||
return (
|
||||
<div className={`window${st.square ? ' square' : ''}${st.focused ? '' : ' inactive'}`}>
|
||||
<TitleBar title={title} maximized={st.maximized} />
|
||||
<MenuBar configured={configured} autoHide={hideMenuBar} />
|
||||
<div className="window-body">{children}</div>
|
||||
{/* The soft emboss and outline, painted last over everything. */}
|
||||
<div className="window-edge" aria-hidden>
|
||||
<div className="rim" style={{ inset: 0, opacity: 1 }} />
|
||||
<div className="rim" style={{ inset: 1, opacity: 0.6 }} />
|
||||
<div className="rim half" style={{ inset: 2, opacity: 0.2 }} />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ---- title bar ----
|
||||
|
||||
function WindowButton({ kind, maximized }: { kind: string; maximized: boolean }) {
|
||||
const glyph =
|
||||
kind === 'close' ? (
|
||||
<path d="M8 8l8 8M16 8l-8 8" />
|
||||
) : kind === 'minimize' ? (
|
||||
<path d="M8 15.5h8" />
|
||||
) : maximized ? (
|
||||
<>
|
||||
<rect x="8" y="10" width="6" height="6" rx="0.8" />
|
||||
<path d="M10.5 8h4.7a.8.8 0 0 1 .8.8v4.7" />
|
||||
</>
|
||||
) : (
|
||||
<rect x="8" y="8" width="8" height="8" rx="0.8" />
|
||||
)
|
||||
const label = kind === 'close' ? 'Close' : kind === 'minimize' ? 'Minimize' : maximized ? 'Restore' : 'Maximize'
|
||||
return (
|
||||
<button className="tb-btn" aria-label={label} title={label} onClick={control(kind as WindowAction)}>
|
||||
<svg
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth="1.6"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
>
|
||||
{glyph}
|
||||
</svg>
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
function TitleBar({ title, maximized }: { title: string; maximized: boolean }) {
|
||||
const [layout, setLayout] = useState<[string[], string[]]>([[], ['minimize', 'maximize', 'close']])
|
||||
useEffect(() => {
|
||||
void window.api.windowButtons().then((l) => {
|
||||
const known = (side: string): string[] => side.split(',').filter((b) => ['minimize', 'maximize', 'close'].includes(b))
|
||||
const [left, right = ''] = l.split(':')
|
||||
setLayout([known(left), known(right)])
|
||||
})
|
||||
}, [])
|
||||
const side = (names: string[]): ReactNode => (
|
||||
<div className="tb-buttons">
|
||||
{names.map((n) => (
|
||||
<WindowButton key={n} kind={n} maximized={maximized} />
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
return (
|
||||
<div className="titlebar" onDoubleClick={control('maximize')}>
|
||||
{side(layout[0])}
|
||||
<div className="tb-title">{title}</div>
|
||||
{side(layout[1])}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ---- menu bar ----
|
||||
|
||||
function MenuBar({ configured, autoHide }: { configured: boolean; autoHide: boolean }) {
|
||||
const [shown, setShown] = useState(!autoHide)
|
||||
const [open, setOpen] = useState<number>()
|
||||
const [anchor, setAnchor] = useState({ x: 0, y: 0 })
|
||||
const bar = useRef<HTMLDivElement>(null)
|
||||
const list = menus(configured)
|
||||
const visible = !autoHide || shown || open !== undefined
|
||||
|
||||
useEffect(() => setShown(!autoHide), [autoHide])
|
||||
|
||||
const openMenu = (i: number): void => {
|
||||
setShown(true)
|
||||
// Wait a frame so a bar that was hidden has laid out its labels.
|
||||
requestAnimationFrame(() => {
|
||||
const el = bar.current?.children[i] as HTMLElement | undefined
|
||||
const r = el?.getBoundingClientRect()
|
||||
if (r) setAnchor({ x: r.left, y: r.bottom })
|
||||
setOpen(i)
|
||||
})
|
||||
}
|
||||
|
||||
const close = (): void => {
|
||||
setOpen(undefined)
|
||||
if (autoHide) setShown(false)
|
||||
}
|
||||
|
||||
// Tap Alt (pressed and released with nothing in between) shows or hides
|
||||
// the bar; Alt+letter opens that menu.
|
||||
useEffect(() => {
|
||||
let armed = false
|
||||
const onDown = (e: KeyboardEvent): void => {
|
||||
if (e.key === 'Alt') {
|
||||
armed = !e.ctrlKey && !e.shiftKey && !e.metaKey && !e.repeat
|
||||
return
|
||||
}
|
||||
armed = false
|
||||
if (e.altKey && !e.ctrlKey && !e.metaKey && !e.shiftKey) {
|
||||
const i = list.findIndex((m) => m.key === e.key.toLowerCase())
|
||||
if (i >= 0) {
|
||||
e.preventDefault()
|
||||
openMenu(i)
|
||||
}
|
||||
} else if (e.key === 'Escape' && autoHide && shown && open === undefined) {
|
||||
setShown(false)
|
||||
}
|
||||
}
|
||||
const onUp = (e: KeyboardEvent): void => {
|
||||
if (e.key !== 'Alt' || !armed) return
|
||||
armed = false
|
||||
e.preventDefault()
|
||||
if (open !== undefined) close()
|
||||
else if (autoHide) setShown((s) => !s)
|
||||
}
|
||||
const cancel = (): void => {
|
||||
armed = false
|
||||
}
|
||||
const onClick = (e: MouseEvent): void => {
|
||||
armed = false
|
||||
if (autoHide && shown && open === undefined && !bar.current?.contains(e.target as Node)) setShown(false)
|
||||
}
|
||||
window.addEventListener('keydown', onDown, true)
|
||||
window.addEventListener('keyup', onUp, true)
|
||||
window.addEventListener('mousedown', onClick, true)
|
||||
window.addEventListener('blur', cancel)
|
||||
return () => {
|
||||
window.removeEventListener('keydown', onDown, true)
|
||||
window.removeEventListener('keyup', onUp, true)
|
||||
window.removeEventListener('mousedown', onClick, true)
|
||||
window.removeEventListener('blur', cancel)
|
||||
}
|
||||
})
|
||||
|
||||
if (!visible) return null
|
||||
return (
|
||||
<>
|
||||
<div className="menubar" ref={bar} role="menubar">
|
||||
{list.map((m, i) => (
|
||||
<button
|
||||
key={m.label}
|
||||
role="menuitem"
|
||||
className={open === i ? 'open' : ''}
|
||||
onMouseDown={(e) => {
|
||||
e.preventDefault()
|
||||
if (open === i) close()
|
||||
else openMenu(i)
|
||||
}}
|
||||
onMouseEnter={() => open !== undefined && open !== i && openMenu(i)}
|
||||
>
|
||||
<u>{m.label[0]}</u>
|
||||
{m.label.slice(1)}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
{open !== undefined && <ContextMenu x={anchor.x} y={anchor.y} items={list[open].items} onClose={close} />}
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useEffect, useState, type ReactNode } from 'react'
|
||||
import type { AppState, RabbitStatus, RelayStatus } from '@shared/api'
|
||||
import { didName, formatNumber } from '@shared/phone'
|
||||
import type { AddressBook, GvStatus, IconStyle, Settings, SyncStatus, Theme } from '@shared/types'
|
||||
import type { AddressBook, GvStatus, IconStyle, Look, Settings, SyncStatus, Theme } from '@shared/types'
|
||||
import { CloseIcon } from './Icons'
|
||||
|
||||
interface Props {
|
||||
@@ -11,14 +11,15 @@ interface Props {
|
||||
onChanged: () => void
|
||||
}
|
||||
|
||||
// Laid out like VLC's preferences (design.html#prefs): categories on the
|
||||
// left, the chosen page on the right, a Close button. Every change applies
|
||||
// as it's made.
|
||||
export function SettingsDialog({ state, sync, onClose, onChanged }: Props) {
|
||||
const [s, setS] = useState<Settings>(state.settings)
|
||||
const [note, setNote] = useState<string>()
|
||||
// voip.ms numbers; Google Voice has its own section.
|
||||
const [page, setPage] = useState('Appearance')
|
||||
// voip.ms numbers; Google Voice has its own page.
|
||||
const smsDids = state.dids.filter((d) => d.smsEnabled && d.provider !== 'gvoice')
|
||||
// Theme and icon are saved on click, so they never make the dialog dirty.
|
||||
const clicked = { theme: undefined, icon: undefined }
|
||||
const dirty = JSON.stringify({ ...s, ...clicked }) !== JSON.stringify({ ...state.settings, ...clicked })
|
||||
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent): void => {
|
||||
@@ -28,30 +29,47 @@ export function SettingsDialog({ state, sync, onClose, onChanged }: Props) {
|
||||
return () => window.removeEventListener('keydown', onKey)
|
||||
}, [onClose])
|
||||
|
||||
const save = async (): Promise<void> => {
|
||||
await window.api.updateSettings(s)
|
||||
onChanged()
|
||||
onClose()
|
||||
const change = (next: Settings): void => {
|
||||
setS(next)
|
||||
void window.api.updateSettings(next).then(onChanged)
|
||||
}
|
||||
|
||||
const synced = s.dids.length ? s.dids : smsDids.map((d) => d.did)
|
||||
const sendFrom = [...synced, ...(state.gvoiceNumber ? [state.gvoiceNumber] : []), ...state.dids.filter((d) => d.provider === 'sim').map((d) => d.did)]
|
||||
const sendFrom = [
|
||||
...synced,
|
||||
...(state.gvoiceNumber ? [state.gvoiceNumber] : []),
|
||||
...state.dids.filter((d) => d.provider === 'sim').map((d) => d.did)
|
||||
]
|
||||
|
||||
return (
|
||||
<div className="modal-backdrop" onMouseDown={(e) => e.target === e.currentTarget && onClose()}>
|
||||
<div className="modal" role="dialog" aria-label="Settings">
|
||||
<header>
|
||||
<h2>Settings</h2>
|
||||
<button className="icon-btn" onClick={onClose} title="Close">
|
||||
<CloseIcon />
|
||||
const pages: Record<string, ReactNode> = {
|
||||
Appearance: (
|
||||
<>
|
||||
<section className="group">
|
||||
<h3>Look</h3>
|
||||
<div className="field">
|
||||
Style
|
||||
<div className="tiles" role="radiogroup" aria-label="Style">
|
||||
{(
|
||||
[
|
||||
['signal', 'Signal vibes'],
|
||||
['trave', 'travewave']
|
||||
] as [Look, string][]
|
||||
).map(([l, label]) => (
|
||||
<button
|
||||
key={l}
|
||||
role="radio"
|
||||
aria-checked={(s.look ?? 'trave') === l}
|
||||
className={(s.look ?? 'trave') === l ? 'on' : ''}
|
||||
onClick={() => change({ ...s, look: l })}
|
||||
>
|
||||
{label}
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<section>
|
||||
<h3>Appearance</h3>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="field">
|
||||
Theme
|
||||
<div className="segmented" role="radiogroup" aria-label="Theme">
|
||||
<div className="tiles" role="radiogroup" aria-label="Theme">
|
||||
{(['system', 'light', 'dark'] as Theme[]).map((t) => (
|
||||
<button
|
||||
key={t}
|
||||
@@ -70,7 +88,7 @@ export function SettingsDialog({ state, sync, onClose, onChanged }: Props) {
|
||||
</div>
|
||||
<div className="field">
|
||||
Icon
|
||||
<div className="segmented" role="radiogroup" aria-label="Icon">
|
||||
<div className="tiles" role="radiogroup" aria-label="Icon">
|
||||
{(['dark', 'inverted'] as IconStyle[]).map((t) => (
|
||||
<button
|
||||
key={t}
|
||||
@@ -87,17 +105,30 @@ export function SettingsDialog({ state, sync, onClose, onChanged }: Props) {
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<label className="field">
|
||||
Show new messages in the notification list
|
||||
<input type="checkbox" checked={s.notifications} onChange={(e) => setS({ ...s, notifications: e.target.checked })} />
|
||||
</label>
|
||||
<p className="muted small">
|
||||
Zoom with <kbd>Ctrl</kbd> <kbd>+</kbd> / <kbd>Ctrl</kbd> <kbd>−</kbd>, and <kbd>Ctrl</kbd> <kbd>0</kbd> to reset.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h3>Account</h3>
|
||||
<section className="group">
|
||||
<h3>Window</h3>
|
||||
<label className="check">
|
||||
<input type="checkbox" checked={s.hideMenuBar !== false} onChange={(e) => change({ ...s, hideMenuBar: e.target.checked })} />
|
||||
Hide the menu bar until Alt is pressed
|
||||
</label>
|
||||
<label className="check">
|
||||
<input type="checkbox" checked={s.showTooltips !== false} onChange={(e) => change({ ...s, showTooltips: e.target.checked })} />
|
||||
Show tooltips
|
||||
</label>
|
||||
<label className="check">
|
||||
<input type="checkbox" checked={s.notifications} onChange={(e) => change({ ...s, notifications: e.target.checked })} />
|
||||
Show new messages in the notification list
|
||||
</label>
|
||||
</section>
|
||||
</>
|
||||
),
|
||||
Account: (
|
||||
<section className="group">
|
||||
<h3>voip.ms</h3>
|
||||
<div className="kv">
|
||||
<span>voip.ms user</span>
|
||||
<span>{state.username}</span>
|
||||
@@ -112,8 +143,13 @@ export function SettingsDialog({ state, sync, onClose, onChanged }: Props) {
|
||||
</div>
|
||||
<div className="kv">
|
||||
<span>Password stored in</span>
|
||||
<span>{state.keyringBackend.startsWith('gnome') || state.keyringBackend.includes('libsecret') ? 'GNOME Keyring' : state.keyringBackend}</span>
|
||||
<span>
|
||||
{state.keyringBackend.startsWith('gnome') || state.keyringBackend.includes('libsecret')
|
||||
? 'GNOME Keyring'
|
||||
: state.keyringBackend}
|
||||
</span>
|
||||
</div>
|
||||
<div className="btn-row">
|
||||
<button
|
||||
className="danger"
|
||||
onClick={() => {
|
||||
@@ -122,18 +158,15 @@ export function SettingsDialog({ state, sync, onClose, onChanged }: Props) {
|
||||
>
|
||||
Sign out
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<GoogleVoiceSection number={state.gvoiceNumber} status={sync?.gvoice} onChanged={onChanged} />
|
||||
|
||||
<ContactsSection value={s.contactBook} onChange={(contactBook) => setS({ ...s, contactBook })} />
|
||||
|
||||
<RabbitSection onChanged={onChanged} />
|
||||
<RelaySection onChanged={onChanged} />
|
||||
|
||||
{smsDids.length > 0 && (
|
||||
<section>
|
||||
<h3>Numbers</h3>
|
||||
),
|
||||
'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">
|
||||
<h3>Numbers to sync</h3>
|
||||
{smsDids.map((d) => (
|
||||
<label key={d.did} className="did">
|
||||
<input
|
||||
@@ -141,7 +174,11 @@ export function SettingsDialog({ state, sync, onClose, onChanged }: Props) {
|
||||
checked={synced.includes(d.did)}
|
||||
onChange={(e) => {
|
||||
const next = e.target.checked ? [...synced, d.did] : synced.filter((x) => x !== d.did)
|
||||
setS({ ...s, dids: next.length === smsDids.length ? [] : next })
|
||||
if (next.length)
|
||||
change({
|
||||
...s,
|
||||
dids: next.length === smsDids.length ? [] : next
|
||||
})
|
||||
}}
|
||||
/>
|
||||
<span>{formatNumber(d.did)}</span>
|
||||
@@ -151,7 +188,7 @@ export function SettingsDialog({ state, sync, onClose, onChanged }: Props) {
|
||||
{sendFrom.length > 1 && (
|
||||
<label className="field">
|
||||
Send new chats from
|
||||
<select value={s.defaultDid ?? sendFrom[0]} onChange={(e) => setS({ ...s, defaultDid: e.target.value })}>
|
||||
<select value={s.defaultDid ?? sendFrom[0]} onChange={(e) => change({ ...s, defaultDid: e.target.value })}>
|
||||
{sendFrom.map((d) => (
|
||||
<option key={d} value={d}>
|
||||
{didName(d)}
|
||||
@@ -162,13 +199,14 @@ export function SettingsDialog({ state, sync, onClose, onChanged }: Props) {
|
||||
</label>
|
||||
)}
|
||||
</section>
|
||||
)}
|
||||
|
||||
<section>
|
||||
<h3>Sync</h3>
|
||||
)
|
||||
}),
|
||||
Sync: (
|
||||
<section className="group">
|
||||
<h3>Checking</h3>
|
||||
<label className="field">
|
||||
Check for new messages every
|
||||
<select value={s.pollSeconds} onChange={(e) => setS({ ...s, pollSeconds: Number(e.target.value) })}>
|
||||
<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' : ''}`}
|
||||
@@ -178,15 +216,22 @@ export function SettingsDialog({ state, sync, onClose, onChanged }: Props) {
|
||||
</label>
|
||||
<label className="field">
|
||||
Import history back to
|
||||
<input type="date" value={s.backfillFloor} onChange={(e) => e.target.value && setS({ ...s, backfillFloor: e.target.value })} />
|
||||
<input type="date" value={s.backfillFloor} onChange={(e) => e.target.value && change({ ...s, backfillFloor: e.target.value })} />
|
||||
</label>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
),
|
||||
Rabbit: (
|
||||
<>
|
||||
<RabbitSection onChanged={onChanged} />
|
||||
<RelaySection onChanged={onChanged} />
|
||||
</>
|
||||
),
|
||||
Storage: (
|
||||
<section className="group">
|
||||
<h3>Storage & backups</h3>
|
||||
<p className="muted small">
|
||||
Your message history lives here. A dated snapshot is written daily and on quit (last 7 kept in <code>snapshots/</code>) so
|
||||
backups always contain a clean copy.
|
||||
Your message history lives here. A dated snapshot is written daily and on quit (last 7 kept in <code>snapshots/</code>) so backups
|
||||
always contain a clean copy.
|
||||
</p>
|
||||
<code className="path">{state.dataDir}</code>
|
||||
<div className="btn-row">
|
||||
@@ -196,11 +241,36 @@ export function SettingsDialog({ state, sync, onClose, onChanged }: Props) {
|
||||
</div>
|
||||
{note && <p className="muted small">{note}</p>}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="modal-backdrop" onMouseDown={(e) => e.target === e.currentTarget && onClose()}>
|
||||
<div className="modal prefs" role="dialog" aria-label="Preferences">
|
||||
<header>
|
||||
<h2>Preferences</h2>
|
||||
</header>
|
||||
<div className="prefs-body">
|
||||
<div className="prefs-list list-frame" role="tablist" aria-orientation="vertical">
|
||||
{Object.keys(pages).map((name) => (
|
||||
<button
|
||||
key={name}
|
||||
role="tab"
|
||||
aria-selected={page === name}
|
||||
className={page === name ? 'active' : ''}
|
||||
onClick={() => setPage(name)}
|
||||
>
|
||||
{name}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<div className="prefs-page" role="tabpanel" aria-label={page}>
|
||||
{pages[page]}
|
||||
</div>
|
||||
</div>
|
||||
<footer>
|
||||
<button onClick={onClose}>{dirty ? 'Cancel' : 'Close'}</button>
|
||||
<button className="primary" disabled={!dirty} onClick={() => void save()}>
|
||||
Save
|
||||
<button onClick={onClose}>
|
||||
<CloseIcon size={14} /> Close
|
||||
</button>
|
||||
</footer>
|
||||
</div>
|
||||
@@ -215,7 +285,12 @@ function gvStatusText(st?: GvStatus): string {
|
||||
if (st.phase === 'signedOut') return 'Signed out'
|
||||
if (st.phase === 'error') return `Error: ${st.error ?? 'unknown'}`
|
||||
if (!st.backfillDone) return 'Importing history…'
|
||||
return st.lastPoll ? `Up to date (checked ${new Date(st.lastPoll).toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' })})` : 'Connected'
|
||||
return st.lastPoll
|
||||
? `Up to date (checked ${new Date(st.lastPoll).toLocaleTimeString([], {
|
||||
hour: 'numeric',
|
||||
minute: '2-digit'
|
||||
})})`
|
||||
: 'Connected'
|
||||
}
|
||||
|
||||
function GoogleVoiceSection({ number, status, onChanged }: { number?: string; status?: GvStatus; onChanged: () => void }) {
|
||||
@@ -236,19 +311,27 @@ function GoogleVoiceSection({ number, status, onChanged }: { number?: string; st
|
||||
<details className="gv-fallback">
|
||||
<summary>Sign-in window not working?</summary>
|
||||
<p className="muted small">
|
||||
Google sometimes refuses sign-ins inside apps. Instead, sign in at voice.google.com in Firefox, open the developer tools
|
||||
(F12) → Network, reload, right-click any request to <code>clients6.google.com</code> → Copy → Copy as cURL, and paste it here.
|
||||
It holds your Google sign-in, so only paste it here.
|
||||
Google sometimes refuses sign-ins inside apps. Instead, sign in at voice.google.com in Firefox, open the developer tools (F12) →
|
||||
Network, reload, right-click any request to <code>clients6.google.com</code> → Copy → Copy as cURL, and paste it here. It holds your
|
||||
Google sign-in, so only paste it here.
|
||||
</p>
|
||||
<textarea value={cookies} onChange={(e) => setCookies(e.target.value)} placeholder="curl 'https://clients6.google.com/…' -H 'Cookie: …'" rows={4} />
|
||||
<button disabled={busy || !cookies.trim()} onClick={() => run(window.api.connectGoogleVoiceCookies(cookies).then(() => setCookies('')))}>
|
||||
<textarea
|
||||
value={cookies}
|
||||
onChange={(e) => setCookies(e.target.value)}
|
||||
placeholder="curl 'https://clients6.google.com/…' -H 'Cookie: …'"
|
||||
rows={4}
|
||||
/>
|
||||
<button
|
||||
disabled={busy || !cookies.trim()}
|
||||
onClick={() => run(window.api.connectGoogleVoiceCookies(cookies).then(() => setCookies('')))}
|
||||
>
|
||||
Connect with these cookies
|
||||
</button>
|
||||
</details>
|
||||
)
|
||||
|
||||
return (
|
||||
<section>
|
||||
<section className="group">
|
||||
<h3>Google Voice</h3>
|
||||
{number ? (
|
||||
<>
|
||||
@@ -275,8 +358,8 @@ function GoogleVoiceSection({ number, status, onChanged }: { number?: string; st
|
||||
) : (
|
||||
<>
|
||||
<p className="muted small">
|
||||
Text from your Google Voice number here too. This uses the private API behind voice.google.com (Google has no public one),
|
||||
so a change on Google's side can break it until the app is updated. voip.ms keeps working either way.
|
||||
Text from your Google Voice number here too. This uses the private API behind voice.google.com (Google has no public one), so a
|
||||
change on Google's side can break it until the app is updated. voip.ms keeps working either way.
|
||||
</p>
|
||||
<button className="primary" disabled={busy} onClick={() => run(window.api.connectGoogleVoice())}>
|
||||
{busy ? 'Waiting for sign-in…' : 'Connect Google Voice…'}
|
||||
@@ -304,7 +387,7 @@ function ContactsSection({ value, onChange }: { value?: string; onChange: (uid?:
|
||||
.catch((e: Error) => setError(cleanError(e)))
|
||||
}, [])
|
||||
return (
|
||||
<section>
|
||||
<section className="group">
|
||||
<h3>Contacts</h3>
|
||||
<label className="field">
|
||||
Add new contacts to
|
||||
@@ -351,9 +434,9 @@ function RabbitSection({ onChanged }: { onChanged: () => void }) {
|
||||
.then(() => {
|
||||
setDone(
|
||||
what === 'install'
|
||||
? 'Installed. It\'s open on the Rabbit now.'
|
||||
? "Installed. It's open on the Rabbit now."
|
||||
: what === 'update'
|
||||
? 'Updated. It\'s open on the Rabbit now.'
|
||||
? "Updated. It's open on the Rabbit now."
|
||||
: 'Synced accounts, chat names and read status.'
|
||||
)
|
||||
onChanged()
|
||||
@@ -369,7 +452,7 @@ function RabbitSection({ onChanged }: { onChanged: () => void }) {
|
||||
const device = st?.device
|
||||
const installed = device?.installedVersion
|
||||
return (
|
||||
<section>
|
||||
<section className="group">
|
||||
<h3>Rabbit</h3>
|
||||
<div className="kv">
|
||||
<span>Device</span>
|
||||
@@ -385,10 +468,10 @@ function RabbitSection({ onChanged }: { onChanged: () => void }) {
|
||||
</div>
|
||||
)}
|
||||
<p className="muted small">
|
||||
Install puts the app on the Rabbit along with your voip.ms and Google Voice sign-ins, your message history and photos, and
|
||||
your chat names. Update installs a new version of the app and keeps everything already on the Rabbit. Sync sends the
|
||||
sign-ins again (say, after reconnecting Google Voice here) and merges chat names and read/unread/archived both ways, newest
|
||||
change winning. Recopy replaces the Rabbit's history with this computer's, sending only photos it doesn't have.
|
||||
Install puts the app on the Rabbit along with your voip.ms and Google Voice sign-ins, your message history and photos, and your chat
|
||||
names. Update installs a new version of the app and keeps everything already on the Rabbit. Sync sends the sign-ins again (say,
|
||||
after reconnecting Google Voice here) and merges chat names and read/unread/archived both ways, newest change winning. Recopy
|
||||
replaces the Rabbit's history with this computer's, sending only photos it doesn't have.
|
||||
</p>
|
||||
<div className="btn-row">
|
||||
{installed ? (
|
||||
@@ -459,15 +542,20 @@ function RelaySection({ onChanged }: { onChanged: () => void }) {
|
||||
})
|
||||
}
|
||||
|
||||
const last = st?.lastSync ? new Date(st.lastSync).toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' }) : undefined
|
||||
const last = st?.lastSync
|
||||
? new Date(st.lastSync).toLocaleTimeString([], {
|
||||
hour: 'numeric',
|
||||
minute: '2-digit'
|
||||
})
|
||||
: undefined
|
||||
return (
|
||||
<section>
|
||||
<section className="group">
|
||||
<h3>Rabbit relay (jai)</h3>
|
||||
<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 read/unread/archived stay in step with the Rabbit without plugging it in. It goes through jai, which only passes on
|
||||
sealed messages it can't read: the key stays on this computer and the Rabbit. A text sent from here goes out at the
|
||||
Rabbit's next background check (Settings there: how often), so it can take a while.
|
||||
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
|
||||
it can't read: the key stays on this computer and the Rabbit. A text sent from here goes out at the Rabbit's next background check
|
||||
(Settings there: how often), so it can take a while.
|
||||
</p>
|
||||
{st?.connected ? (
|
||||
<>
|
||||
@@ -499,7 +587,13 @@ function RelaySection({ onChanged }: { onChanged: () => void }) {
|
||||
</label>
|
||||
<label className="field">
|
||||
Token
|
||||
<input type="password" value={token} onChange={(e) => setToken(e.target.value)} placeholder="from scripts/deploy-jai.sh --token" autoComplete="off" />
|
||||
<input
|
||||
type="password"
|
||||
value={token}
|
||||
onChange={(e) => setToken(e.target.value)}
|
||||
placeholder="from scripts/deploy-jai.sh --token"
|
||||
autoComplete="off"
|
||||
/>
|
||||
</label>
|
||||
<div className="btn-row">
|
||||
<button className="primary" disabled={busy || !token.trim()} onClick={connect}>
|
||||
|
||||
@@ -171,6 +171,7 @@ export function Sidebar(p: Props) {
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
<div className="tiles">
|
||||
<button className="icon-btn" title="New chat (Ctrl+N)" onClick={() => p.setMode('compose')}>
|
||||
<ComposeIcon />
|
||||
</button>
|
||||
@@ -186,9 +187,10 @@ export function Sidebar(p: Props) {
|
||||
>
|
||||
<ArchiveIcon />
|
||||
</button>
|
||||
<button className="icon-btn" title="Settings" onClick={p.onSettings}>
|
||||
<button className="icon-btn" title="Preferences (Ctrl+,)" onClick={p.onSettings}>
|
||||
<GearIcon />
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
<div className="sidebar-body">
|
||||
{p.mode === 'search' && p.query.trim() ? (
|
||||
@@ -254,7 +256,10 @@ function SyncFooter({ sync }: { sync?: SyncStatus }) {
|
||||
cls += ' error'
|
||||
} else if (!sync.backfillDone && sync.backfillCursor) {
|
||||
const d = new Date(sync.backfillCursor + 'T12:00:00Z')
|
||||
text = `Importing history… back to ${d.toLocaleDateString([], { month: 'short', year: 'numeric' })} · ${sync.total.toLocaleString()} messages`
|
||||
text = `Importing history… back to ${d.toLocaleDateString([], {
|
||||
month: 'short',
|
||||
year: 'numeric'
|
||||
})} · ${sync.total.toLocaleString()} messages`
|
||||
} else if (!sync.backfillDone && sync.phase === 'backfill') {
|
||||
text = 'Importing history…'
|
||||
} else if (gv && !gv.backfillDone && gv.phase === 'backfill') {
|
||||
@@ -279,7 +284,7 @@ function RefreshButton() {
|
||||
void Promise.allSettled([window.api.pollNow(), minSpin]).then(() => setBusy(false))
|
||||
}
|
||||
return (
|
||||
<button className={`icon-btn${busy ? ' spinning' : ''}`} title="Check for new messages" onClick={refresh}>
|
||||
<button className={`icon-btn${busy ? ' spinning' : ''}`} title="Check for new messages (F5)" onClick={refresh}>
|
||||
<RefreshIcon />
|
||||
</button>
|
||||
)
|
||||
|
||||
@@ -2,6 +2,9 @@ import { StrictMode } from 'react'
|
||||
import { createRoot } from 'react-dom/client'
|
||||
import { App } from './App'
|
||||
import './styles.css'
|
||||
import { installTooltips } from './tooltips'
|
||||
|
||||
installTooltips()
|
||||
|
||||
createRoot(document.getElementById('root')!).render(
|
||||
<StrictMode>
|
||||
|
||||
+2235
-1
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,82 @@
|
||||
// Tooltips drawn by the page (design.html#tooltips): every glyph-only
|
||||
// button's title shows in the window.lighter(130) colour, and the "Show
|
||||
// tooltips" preference turns them all off at once. Off keeps the text: a
|
||||
// title moves to data-tip (and becomes the aria-label of a button that has
|
||||
// no text of its own), so screen readers still have every name.
|
||||
|
||||
let enabled = true
|
||||
let tip: HTMLDivElement | undefined
|
||||
let timer: number | undefined
|
||||
let current: Element | undefined
|
||||
|
||||
export function setTooltipsEnabled(on: boolean): void {
|
||||
enabled = on
|
||||
if (!on) hide()
|
||||
}
|
||||
|
||||
function hide(): void {
|
||||
window.clearTimeout(timer)
|
||||
timer = undefined
|
||||
current = undefined
|
||||
tip?.remove()
|
||||
tip = undefined
|
||||
}
|
||||
|
||||
// Take over an element's title so Chromium's own tooltip never shows.
|
||||
function adopt(el: Element): string | undefined {
|
||||
const t = el.getAttribute('title')
|
||||
if (t !== null) {
|
||||
el.removeAttribute('title')
|
||||
el.setAttribute('data-tip', t)
|
||||
if (!el.hasAttribute('aria-label') && !el.textContent?.trim()) el.setAttribute('aria-label', t)
|
||||
}
|
||||
return el.getAttribute('data-tip') || undefined
|
||||
}
|
||||
|
||||
function show(el: Element, text: string, x: number, y: number): void {
|
||||
tip?.remove()
|
||||
tip = document.createElement('div')
|
||||
tip.className = 'tooltip'
|
||||
tip.textContent = text
|
||||
document.querySelector('.window')?.appendChild(tip) ?? document.body.appendChild(tip)
|
||||
const r = tip.getBoundingClientRect()
|
||||
const left = Math.max(4, Math.min(x, window.innerWidth - r.width - 4))
|
||||
const below = y + 20
|
||||
tip.style.left = `${left}px`
|
||||
tip.style.top = `${below + r.height > window.innerHeight - 4 ? y - r.height - 8 : below}px`
|
||||
current = el
|
||||
}
|
||||
|
||||
export function installTooltips(): void {
|
||||
let x = 0
|
||||
let y = 0
|
||||
document.addEventListener(
|
||||
'mouseover',
|
||||
(e) => {
|
||||
const el = (e.target as Element).closest?.('[title], [data-tip]')
|
||||
if (!el) return
|
||||
const text = adopt(el)
|
||||
if (el === current || !text || !enabled) return
|
||||
hide()
|
||||
timer = window.setTimeout(() => {
|
||||
if (el.isConnected && enabled) show(el, el.getAttribute('data-tip') ?? text, x, y)
|
||||
}, 600)
|
||||
},
|
||||
true
|
||||
)
|
||||
document.addEventListener(
|
||||
'mousemove',
|
||||
(e) => {
|
||||
x = e.clientX
|
||||
y = e.clientY
|
||||
if (current && !current.contains(e.target as Node)) hide()
|
||||
else if (timer && !current) {
|
||||
const el = (e.target as Element).closest?.('[data-tip]')
|
||||
if (!el) hide()
|
||||
}
|
||||
},
|
||||
true
|
||||
)
|
||||
for (const ev of ['mousedown', 'keydown', 'wheel', 'blur'] as const) window.addEventListener(ev, hide, true)
|
||||
document.addEventListener('mouseleave', hide)
|
||||
}
|
||||
@@ -11,6 +11,15 @@ export interface AppState {
|
||||
gvoiceNumber?: string // set when Google Voice is connected
|
||||
}
|
||||
|
||||
// The window's frame, drawn by the page (design.html#window).
|
||||
export interface WindowState {
|
||||
square: boolean // maximized, fullscreen or tiled: no round corners
|
||||
maximized: boolean
|
||||
focused: boolean
|
||||
}
|
||||
|
||||
export type WindowAction = 'minimize' | 'maximize' | 'close' | 'quit' | 'zoomIn' | 'zoomOut' | 'zoomReset'
|
||||
|
||||
export interface RabbitStatus {
|
||||
adb: boolean // adb is installed
|
||||
bundledVersion?: string // the Android app this build carries
|
||||
@@ -31,6 +40,10 @@ export interface Api {
|
||||
saveSetup(creds: Credentials, settings: Settings): Promise<void>
|
||||
updateSettings(settings: Settings): Promise<void>
|
||||
setTheme(theme: Theme): Promise<void>
|
||||
windowState(): Promise<WindowState>
|
||||
onWindowState(cb: (s: WindowState) => void): () => void
|
||||
windowButtons(): Promise<string> // GNOME's button-layout
|
||||
windowControl(action: WindowAction): Promise<void>
|
||||
setIcon(icon: IconStyle): Promise<void>
|
||||
signOut(): Promise<void>
|
||||
connectGoogleVoice(): Promise<void>
|
||||
|
||||
@@ -123,6 +123,9 @@ export interface GvStatus {
|
||||
error?: string
|
||||
}
|
||||
|
||||
// 'signal': Signal Desktop vibes; 'trave': the house look (shared-resources/design.html).
|
||||
export type Look = 'signal' | 'trave'
|
||||
|
||||
export interface Settings {
|
||||
pollSeconds: number
|
||||
dids: string[] // DIDs to sync; empty = all SMS-enabled
|
||||
@@ -132,6 +135,9 @@ export interface Settings {
|
||||
icon?: IconStyle // absent = dark
|
||||
notifications: boolean // new messages go to the notification list
|
||||
contactBook?: string // where "Add to contacts" puts them; default: GNOME Contacts' default
|
||||
look?: Look // absent = travewave
|
||||
hideMenuBar?: boolean // until Alt is tapped (design.html#menubar); absent = hidden
|
||||
showTooltips?: boolean // design.html#tooltips; absent = shown
|
||||
}
|
||||
|
||||
export interface Credentials {
|
||||
|
||||
Reference in New Issue
Block a user