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).
|
// First: in sandbox mode this moves every path the app uses (see sandbox.ts).
|
||||||
import { SANDBOX, seedDemo } from './sandbox'
|
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 crypto from 'node:crypto'
|
||||||
import fs from 'node:fs'
|
import fs from 'node:fs'
|
||||||
import path from 'node:path'
|
import path from 'node:path'
|
||||||
@@ -8,7 +9,7 @@ import os from 'node:os'
|
|||||||
import { pathToFileURL } from 'node:url'
|
import { pathToFileURL } from 'node:url'
|
||||||
import { charCount, groupMembers, isGroup, normalizeNumber, SMS_TEXT_LIMIT } from '@shared/phone'
|
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 { 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 { addToAddressBook, ContactDirectory, listAddressBooks } from './contacts'
|
||||||
import { localDay, MessageDb, type NewMessage } from './db'
|
import { localDay, MessageDb, type NewMessage } from './db'
|
||||||
import { MediaStore } from './media'
|
import { MediaStore } from './media'
|
||||||
@@ -337,8 +338,42 @@ function applyTheme(): void {
|
|||||||
win?.setBackgroundColor(windowBackground())
|
win?.setBackgroundColor(windowBackground())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The window itself stays transparent: the page paints its rounded tile.
|
||||||
function windowBackground(): string {
|
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
|
const ZOOM_STEP = 0.5
|
||||||
@@ -534,6 +569,20 @@ function registerIpc(): void {
|
|||||||
gvSync?.resetBackfill()
|
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) => {
|
ipcMain.handle('setIcon', (_e, icon: IconStyle) => {
|
||||||
settings = { ...settings, icon }
|
settings = { ...settings, icon }
|
||||||
saveSettings(settings)
|
saveSettings(settings)
|
||||||
@@ -688,8 +737,11 @@ function createWindow(): void {
|
|||||||
minWidth: 760,
|
minWidth: 760,
|
||||||
minHeight: 480,
|
minHeight: 480,
|
||||||
title: SANDBOX ? 'bubble (sandbox)' : 'bubble',
|
title: SANDBOX ? 'bubble (sandbox)' : 'bubble',
|
||||||
backgroundColor: windowBackground(),
|
// design.html#window: frameless and see-through; the page paints the
|
||||||
autoHideMenuBar: true,
|
// rounded tile, its own title bar (#titlebar) and menu bar (#menubar).
|
||||||
|
frame: false,
|
||||||
|
transparent: true,
|
||||||
|
backgroundColor: '#00000000',
|
||||||
icon: iconFile(settings.icon),
|
icon: iconFile(settings.icon),
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
preload: path.join(__dirname, '../preload/index.js'),
|
preload: path.join(__dirname, '../preload/index.js'),
|
||||||
@@ -724,6 +776,8 @@ function createWindow(): void {
|
|||||||
win.webContents.on('did-finish-load', () => win!.webContents.setZoomLevel(loadZoom()))
|
win.webContents.on('did-finish-load', () => win!.webContents.setZoomLevel(loadZoom()))
|
||||||
// The hidden Google Voice window would otherwise keep 'window-all-closed'
|
// The hidden Google Voice window would otherwise keep 'window-all-closed'
|
||||||
// from firing, leaving a windowless process holding the single-instance lock.
|
// 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.on('closed', () => {
|
||||||
win = undefined
|
win = undefined
|
||||||
app.quit()
|
app.quit()
|
||||||
|
|||||||
@@ -13,6 +13,10 @@ const api: Api = {
|
|||||||
saveSetup: (creds, settings) => ipcRenderer.invoke('saveSetup', creds, settings),
|
saveSetup: (creds, settings) => ipcRenderer.invoke('saveSetup', creds, settings),
|
||||||
updateSettings: (settings) => ipcRenderer.invoke('updateSettings', settings),
|
updateSettings: (settings) => ipcRenderer.invoke('updateSettings', settings),
|
||||||
setTheme: (theme) => ipcRenderer.invoke('setTheme', theme),
|
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),
|
setIcon: (icon) => ipcRenderer.invoke('setIcon', icon),
|
||||||
signOut: () => ipcRenderer.invoke('signOut'),
|
signOut: () => ipcRenderer.invoke('signOut'),
|
||||||
connectGoogleVoice: () => ipcRenderer.invoke('connectGoogleVoice'),
|
connectGoogleVoice: () => ipcRenderer.invoke('connectGoogleVoice'),
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en" data-look="trave">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<title>bubble</title>
|
<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 { AppState } from '@shared/api'
|
||||||
import type { ContactInfo, Conversation, SyncStatus } from '@shared/types'
|
import type { ContactInfo, Conversation, SyncStatus } from '@shared/types'
|
||||||
import { Sidebar, type SidebarMode } from './components/Sidebar'
|
import { Sidebar, type SidebarMode } from './components/Sidebar'
|
||||||
@@ -8,6 +8,8 @@ import { SettingsDialog } from './components/SettingsDialog'
|
|||||||
import { ConversationInfo } from './components/ConversationInfo'
|
import { ConversationInfo } from './components/ConversationInfo'
|
||||||
import { AddContact, AddContactContext } from './components/AddContact'
|
import { AddContact, AddContactContext } from './components/AddContact'
|
||||||
import { ExportChat } from './components/ExportChat'
|
import { ExportChat } from './components/ExportChat'
|
||||||
|
import { Frame, onCommand, runCommand } from './components/Frame'
|
||||||
|
import { setTooltipsEnabled } from './tooltips'
|
||||||
|
|
||||||
export interface ConvKey {
|
export interface ConvKey {
|
||||||
did: string
|
did: string
|
||||||
@@ -19,8 +21,7 @@ export interface Jump {
|
|||||||
nonce: number
|
nonce: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export const sameConv = (a?: ConvKey | null, b?: ConvKey | null): boolean =>
|
export const sameConv = (a?: ConvKey | null, b?: ConvKey | null): boolean => !!a && !!b && a.did === b.did && a.contact === b.contact
|
||||||
!!a && !!b && a.did === b.did && a.contact === b.contact
|
|
||||||
|
|
||||||
export function App() {
|
export function App() {
|
||||||
const [state, setState] = useState<AppState>()
|
const [state, setState] = useState<AppState>()
|
||||||
@@ -86,17 +87,47 @@ export function App() {
|
|||||||
// 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])
|
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(() => {
|
useEffect(() => {
|
||||||
const onKey = (e: KeyboardEvent): void => {
|
const onKey = (e: KeyboardEvent): void => {
|
||||||
const mod = e.ctrlKey || e.metaKey
|
const mod = e.ctrlKey || e.metaKey
|
||||||
if (mod && !e.shiftKey && e.key.toLowerCase() === 'f') {
|
if (mod && !e.shiftKey && e.key.toLowerCase() === 'f') {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
setMode('search')
|
runCommand('find')
|
||||||
document.getElementById('sidebar-search')?.focus()
|
|
||||||
} else if (mod && e.key.toLowerCase() === 'n') {
|
} else if (mod && e.key.toLowerCase() === 'n') {
|
||||||
e.preventDefault()
|
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) {
|
} else if (e.altKey && (e.key === 'ArrowDown' || e.key === 'ArrowUp') && listed.length) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
const i = listed.findIndex((c) => sameConv(c, selected))
|
const i = listed.findIndex((c) => sameConv(c, selected))
|
||||||
@@ -108,10 +139,15 @@ export function App() {
|
|||||||
return () => window.removeEventListener('keydown', onKey)
|
return () => window.removeEventListener('keydown', onKey)
|
||||||
}, [listed, selected, open])
|
}, [listed, selected, open])
|
||||||
|
|
||||||
if (!state) return <div className="app loading" />
|
const frame = (body: ReactNode): JSX.Element => (
|
||||||
if (!state.configured) return <Setup initial={state} onDone={refreshState} />
|
<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}>
|
<AddContactContext.Provider value={setAdding}>
|
||||||
<div className="app">
|
<div className="app">
|
||||||
<Sidebar
|
<Sidebar
|
||||||
@@ -162,17 +198,16 @@ export function App() {
|
|||||||
</main>
|
</main>
|
||||||
)}
|
)}
|
||||||
{info && (
|
{info && (
|
||||||
<ConversationInfo conv={info} name={named(info)} contactMap={contactMap} gvNumber={state.gvoiceNumber} onClose={() => setInfo(null)} />
|
<ConversationInfo
|
||||||
)}
|
conv={info}
|
||||||
{exporting && <ExportChat conv={exporting} name={named(exporting)} contactMap={contactMap} onClose={() => setExporting(null)} />}
|
name={named(info)}
|
||||||
{settingsOpen && (
|
contactMap={contactMap}
|
||||||
<SettingsDialog
|
gvNumber={state.gvoiceNumber}
|
||||||
state={state}
|
onClose={() => setInfo(null)}
|
||||||
sync={sync}
|
|
||||||
onClose={() => setSettingsOpen(false)}
|
|
||||||
onChanged={refreshState}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{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)} />}
|
{adding && <AddContact number={adding} defaultBook={state.settings.contactBook} onClose={() => setAdding(null)} />}
|
||||||
</div>
|
</div>
|
||||||
</AddContactContext.Provider>
|
</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>
|
<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)}>
|
<button className="icon-btn small" title="Older (Enter)" disabled={!hits.length} onClick={() => stepHit(1)}>
|
||||||
<UpIcon />
|
<UpIcon />
|
||||||
</button>
|
</button>
|
||||||
<button className="icon-btn small" title="Newer (Shift+Enter)" disabled={!hits.length} onClick={() => stepHit(-1)}>
|
<button className="icon-btn small" title="Newer (Shift+Enter)" disabled={!hits.length} onClick={() => stepHit(-1)}>
|
||||||
<DownIcon />
|
<DownIcon />
|
||||||
</button>
|
</button>
|
||||||
|
</div>
|
||||||
<button
|
<button
|
||||||
className="icon-btn small"
|
className="icon-btn small"
|
||||||
title="Close"
|
title="Close"
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ export function Composer({ conv, isNew, smsDids, gvNumber, onChangeDid, ref }: P
|
|||||||
const el = textarea.current
|
const el = textarea.current
|
||||||
if (el) {
|
if (el) {
|
||||||
el.style.height = 'auto'
|
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])
|
}, [text, key])
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ export interface MenuItem {
|
|||||||
onSelect: () => void
|
onSelect: () => void
|
||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
separator?: boolean // draw a line above this item
|
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
|
// 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.label}
|
||||||
|
{it.shortcut && <span className="menu-shortcut">{it.shortcut}</span>}
|
||||||
</button>
|
</button>
|
||||||
])}
|
])}
|
||||||
</div>
|
</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 type { AppState, RabbitStatus, RelayStatus } from '@shared/api'
|
||||||
import { didName, formatNumber } from '@shared/phone'
|
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'
|
import { CloseIcon } from './Icons'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -11,14 +11,15 @@ interface Props {
|
|||||||
onChanged: () => void
|
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) {
|
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>()
|
||||||
// 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')
|
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(() => {
|
useEffect(() => {
|
||||||
const onKey = (e: KeyboardEvent): void => {
|
const onKey = (e: KeyboardEvent): void => {
|
||||||
@@ -28,30 +29,47 @@ export function SettingsDialog({ state, sync, onClose, onChanged }: Props) {
|
|||||||
return () => window.removeEventListener('keydown', onKey)
|
return () => window.removeEventListener('keydown', onKey)
|
||||||
}, [onClose])
|
}, [onClose])
|
||||||
|
|
||||||
const save = async (): Promise<void> => {
|
const change = (next: Settings): void => {
|
||||||
await window.api.updateSettings(s)
|
setS(next)
|
||||||
onChanged()
|
void window.api.updateSettings(next).then(onChanged)
|
||||||
onClose()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const synced = s.dids.length ? s.dids : smsDids.map((d) => d.did)
|
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 (
|
const pages: Record<string, ReactNode> = {
|
||||||
<div className="modal-backdrop" onMouseDown={(e) => e.target === e.currentTarget && onClose()}>
|
Appearance: (
|
||||||
<div className="modal" role="dialog" aria-label="Settings">
|
<>
|
||||||
<header>
|
<section className="group">
|
||||||
<h2>Settings</h2>
|
<h3>Look</h3>
|
||||||
<button className="icon-btn" onClick={onClose} title="Close">
|
<div className="field">
|
||||||
<CloseIcon />
|
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>
|
</button>
|
||||||
</header>
|
))}
|
||||||
|
</div>
|
||||||
<section>
|
</div>
|
||||||
<h3>Appearance</h3>
|
|
||||||
<div className="field">
|
<div className="field">
|
||||||
Theme
|
Theme
|
||||||
<div className="segmented" role="radiogroup" aria-label="Theme">
|
<div className="tiles" role="radiogroup" aria-label="Theme">
|
||||||
{(['system', 'light', 'dark'] as Theme[]).map((t) => (
|
{(['system', 'light', 'dark'] as Theme[]).map((t) => (
|
||||||
<button
|
<button
|
||||||
key={t}
|
key={t}
|
||||||
@@ -70,7 +88,7 @@ export function SettingsDialog({ state, sync, onClose, onChanged }: Props) {
|
|||||||
</div>
|
</div>
|
||||||
<div className="field">
|
<div className="field">
|
||||||
Icon
|
Icon
|
||||||
<div className="segmented" role="radiogroup" aria-label="Icon">
|
<div className="tiles" role="radiogroup" aria-label="Icon">
|
||||||
{(['dark', 'inverted'] as IconStyle[]).map((t) => (
|
{(['dark', 'inverted'] as IconStyle[]).map((t) => (
|
||||||
<button
|
<button
|
||||||
key={t}
|
key={t}
|
||||||
@@ -87,17 +105,30 @@ export function SettingsDialog({ state, sync, onClose, onChanged }: Props) {
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</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">
|
<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.
|
Zoom with <kbd>Ctrl</kbd> <kbd>+</kbd> / <kbd>Ctrl</kbd> <kbd>−</kbd>, and <kbd>Ctrl</kbd> <kbd>0</kbd> to reset.
|
||||||
</p>
|
</p>
|
||||||
</section>
|
</section>
|
||||||
|
<section className="group">
|
||||||
<section>
|
<h3>Window</h3>
|
||||||
<h3>Account</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">
|
<div className="kv">
|
||||||
<span>voip.ms user</span>
|
<span>voip.ms user</span>
|
||||||
<span>{state.username}</span>
|
<span>{state.username}</span>
|
||||||
@@ -112,8 +143,13 @@ export function SettingsDialog({ state, sync, onClose, onChanged }: Props) {
|
|||||||
</div>
|
</div>
|
||||||
<div className="kv">
|
<div className="kv">
|
||||||
<span>Password stored in</span>
|
<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>
|
||||||
|
<div className="btn-row">
|
||||||
<button
|
<button
|
||||||
className="danger"
|
className="danger"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -122,18 +158,15 @@ export function SettingsDialog({ state, sync, onClose, onChanged }: Props) {
|
|||||||
>
|
>
|
||||||
Sign out
|
Sign out
|
||||||
</button>
|
</button>
|
||||||
|
</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 })} />,
|
||||||
<ContactsSection value={s.contactBook} onChange={(contactBook) => setS({ ...s, contactBook })} />
|
...(smsDids.length > 0 && {
|
||||||
|
Numbers: (
|
||||||
<RabbitSection onChanged={onChanged} />
|
<section className="group">
|
||||||
<RelaySection onChanged={onChanged} />
|
<h3>Numbers to sync</h3>
|
||||||
|
|
||||||
{smsDids.length > 0 && (
|
|
||||||
<section>
|
|
||||||
<h3>Numbers</h3>
|
|
||||||
{smsDids.map((d) => (
|
{smsDids.map((d) => (
|
||||||
<label key={d.did} className="did">
|
<label key={d.did} className="did">
|
||||||
<input
|
<input
|
||||||
@@ -141,7 +174,11 @@ export function SettingsDialog({ state, sync, onClose, onChanged }: Props) {
|
|||||||
checked={synced.includes(d.did)}
|
checked={synced.includes(d.did)}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
const next = e.target.checked ? [...synced, d.did] : synced.filter((x) => x !== d.did)
|
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>
|
<span>{formatNumber(d.did)}</span>
|
||||||
@@ -151,7 +188,7 @@ export function SettingsDialog({ state, sync, onClose, onChanged }: Props) {
|
|||||||
{sendFrom.length > 1 && (
|
{sendFrom.length > 1 && (
|
||||||
<label className="field">
|
<label className="field">
|
||||||
Send new chats from
|
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) => (
|
{sendFrom.map((d) => (
|
||||||
<option key={d} value={d}>
|
<option key={d} value={d}>
|
||||||
{didName(d)}
|
{didName(d)}
|
||||||
@@ -162,13 +199,14 @@ export function SettingsDialog({ state, sync, onClose, onChanged }: Props) {
|
|||||||
</label>
|
</label>
|
||||||
)}
|
)}
|
||||||
</section>
|
</section>
|
||||||
)}
|
)
|
||||||
|
}),
|
||||||
<section>
|
Sync: (
|
||||||
<h3>Sync</h3>
|
<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) => 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) => (
|
{[10, 15, 30, 60, 120, 300].map((n) => (
|
||||||
<option key={n} value={n}>
|
<option key={n} value={n}>
|
||||||
{n < 60 ? `${n} seconds` : `${n / 60} minute${n > 60 ? 's' : ''}`}
|
{n < 60 ? `${n} seconds` : `${n / 60} minute${n > 60 ? 's' : ''}`}
|
||||||
@@ -178,15 +216,22 @@ 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 && setS({ ...s, backfillFloor: e.target.value })} />
|
<input type="date" value={s.backfillFloor} onChange={(e) => e.target.value && change({ ...s, backfillFloor: e.target.value })} />
|
||||||
</label>
|
</label>
|
||||||
</section>
|
</section>
|
||||||
|
),
|
||||||
<section>
|
Rabbit: (
|
||||||
|
<>
|
||||||
|
<RabbitSection onChanged={onChanged} />
|
||||||
|
<RelaySection onChanged={onChanged} />
|
||||||
|
</>
|
||||||
|
),
|
||||||
|
Storage: (
|
||||||
|
<section className="group">
|
||||||
<h3>Storage & backups</h3>
|
<h3>Storage & backups</h3>
|
||||||
<p className="muted small">
|
<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
|
Your message history lives here. A dated snapshot is written daily and on quit (last 7 kept in <code>snapshots/</code>) so backups
|
||||||
backups always contain a clean copy.
|
always contain a clean copy.
|
||||||
</p>
|
</p>
|
||||||
<code className="path">{state.dataDir}</code>
|
<code className="path">{state.dataDir}</code>
|
||||||
<div className="btn-row">
|
<div className="btn-row">
|
||||||
@@ -196,11 +241,36 @@ export function SettingsDialog({ state, sync, onClose, onChanged }: Props) {
|
|||||||
</div>
|
</div>
|
||||||
{note && <p className="muted small">{note}</p>}
|
{note && <p className="muted small">{note}</p>}
|
||||||
</section>
|
</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>
|
<footer>
|
||||||
<button onClick={onClose}>{dirty ? 'Cancel' : 'Close'}</button>
|
<button onClick={onClose}>
|
||||||
<button className="primary" disabled={!dirty} onClick={() => void save()}>
|
<CloseIcon size={14} /> Close
|
||||||
Save
|
|
||||||
</button>
|
</button>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
@@ -215,7 +285,12 @@ function gvStatusText(st?: GvStatus): string {
|
|||||||
if (st.phase === 'signedOut') return 'Signed out'
|
if (st.phase === 'signedOut') return 'Signed out'
|
||||||
if (st.phase === 'error') return `Error: ${st.error ?? 'unknown'}`
|
if (st.phase === 'error') return `Error: ${st.error ?? 'unknown'}`
|
||||||
if (!st.backfillDone) return 'Importing history…'
|
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 }) {
|
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">
|
<details className="gv-fallback">
|
||||||
<summary>Sign-in window not working?</summary>
|
<summary>Sign-in window not working?</summary>
|
||||||
<p className="muted small">
|
<p className="muted small">
|
||||||
Google sometimes refuses sign-ins inside apps. Instead, sign in at voice.google.com in Firefox, open the developer tools
|
Google sometimes refuses sign-ins inside apps. Instead, sign in at voice.google.com in Firefox, open the developer tools (F12) →
|
||||||
(F12) → Network, reload, right-click any request to <code>clients6.google.com</code> → Copy → Copy as cURL, and paste it here.
|
Network, reload, right-click any request to <code>clients6.google.com</code> → Copy → Copy as cURL, and paste it here. It holds your
|
||||||
It holds your Google sign-in, so only paste it here.
|
Google sign-in, so only paste it here.
|
||||||
</p>
|
</p>
|
||||||
<textarea value={cookies} onChange={(e) => setCookies(e.target.value)} placeholder="curl 'https://clients6.google.com/…' -H 'Cookie: …'" rows={4} />
|
<textarea
|
||||||
<button disabled={busy || !cookies.trim()} onClick={() => run(window.api.connectGoogleVoiceCookies(cookies).then(() => setCookies('')))}>
|
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
|
Connect with these cookies
|
||||||
</button>
|
</button>
|
||||||
</details>
|
</details>
|
||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section>
|
<section className="group">
|
||||||
<h3>Google Voice</h3>
|
<h3>Google Voice</h3>
|
||||||
{number ? (
|
{number ? (
|
||||||
<>
|
<>
|
||||||
@@ -275,8 +358,8 @@ function GoogleVoiceSection({ number, status, onChanged }: { number?: string; st
|
|||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<p className="muted small">
|
<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),
|
Text from your Google Voice number here too. This uses the private API behind voice.google.com (Google has no public one), so a
|
||||||
so a change on Google's side can break it until the app is updated. voip.ms keeps working either way.
|
change on Google's side can break it until the app is updated. voip.ms keeps working either way.
|
||||||
</p>
|
</p>
|
||||||
<button className="primary" disabled={busy} onClick={() => run(window.api.connectGoogleVoice())}>
|
<button className="primary" disabled={busy} onClick={() => run(window.api.connectGoogleVoice())}>
|
||||||
{busy ? 'Waiting for sign-in…' : 'Connect Google Voice…'}
|
{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)))
|
.catch((e: Error) => setError(cleanError(e)))
|
||||||
}, [])
|
}, [])
|
||||||
return (
|
return (
|
||||||
<section>
|
<section className="group">
|
||||||
<h3>Contacts</h3>
|
<h3>Contacts</h3>
|
||||||
<label className="field">
|
<label className="field">
|
||||||
Add new contacts to
|
Add new contacts to
|
||||||
@@ -351,9 +434,9 @@ function RabbitSection({ onChanged }: { onChanged: () => void }) {
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
setDone(
|
setDone(
|
||||||
what === 'install'
|
what === 'install'
|
||||||
? 'Installed. It\'s open on the Rabbit now.'
|
? "Installed. It's open on the Rabbit now."
|
||||||
: what === 'update'
|
: 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.'
|
: 'Synced accounts, chat names and read status.'
|
||||||
)
|
)
|
||||||
onChanged()
|
onChanged()
|
||||||
@@ -369,7 +452,7 @@ function RabbitSection({ onChanged }: { onChanged: () => void }) {
|
|||||||
const device = st?.device
|
const device = st?.device
|
||||||
const installed = device?.installedVersion
|
const installed = device?.installedVersion
|
||||||
return (
|
return (
|
||||||
<section>
|
<section className="group">
|
||||||
<h3>Rabbit</h3>
|
<h3>Rabbit</h3>
|
||||||
<div className="kv">
|
<div className="kv">
|
||||||
<span>Device</span>
|
<span>Device</span>
|
||||||
@@ -385,10 +468,10 @@ function RabbitSection({ onChanged }: { onChanged: () => void }) {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<p className="muted small">
|
<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
|
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
|
||||||
your chat names. Update installs a new version of the app and keeps everything already on the Rabbit. Sync sends the
|
names. Update installs a new version of the app and keeps everything already on the Rabbit. Sync sends the sign-ins again (say,
|
||||||
sign-ins again (say, after reconnecting Google Voice here) and merges chat names and read/unread/archived both ways, newest
|
after reconnecting Google Voice here) and merges chat names and read/unread/archived both ways, newest change winning. Recopy
|
||||||
change winning. Recopy replaces the Rabbit's history with this computer's, sending only photos it doesn't have.
|
replaces the Rabbit's history with this computer's, sending only photos it doesn't have.
|
||||||
</p>
|
</p>
|
||||||
<div className="btn-row">
|
<div className="btn-row">
|
||||||
{installed ? (
|
{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 (
|
return (
|
||||||
<section>
|
<section className="group">
|
||||||
<h3>Rabbit relay (jai)</h3>
|
<h3>Rabbit relay (jai)</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
|
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
|
||||||
and read/unread/archived stay in step with the Rabbit without plugging it in. It goes through jai, which only passes on
|
read/unread/archived stay in step with the Rabbit without plugging it in. It goes through jai, which only passes on sealed messages
|
||||||
sealed messages it can't read: the key stays on this computer and the Rabbit. A text sent from here goes out at the
|
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
|
||||||
Rabbit's next background check (Settings there: how often), so it can take a while.
|
(Settings there: how often), so it can take a while.
|
||||||
</p>
|
</p>
|
||||||
{st?.connected ? (
|
{st?.connected ? (
|
||||||
<>
|
<>
|
||||||
@@ -499,7 +587,13 @@ function RelaySection({ onChanged }: { onChanged: () => void }) {
|
|||||||
</label>
|
</label>
|
||||||
<label className="field">
|
<label className="field">
|
||||||
Token
|
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>
|
</label>
|
||||||
<div className="btn-row">
|
<div className="btn-row">
|
||||||
<button className="primary" disabled={busy || !token.trim()} onClick={connect}>
|
<button className="primary" disabled={busy || !token.trim()} onClick={connect}>
|
||||||
|
|||||||
@@ -171,6 +171,7 @@ export function Sidebar(p: Props) {
|
|||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
<div className="tiles">
|
||||||
<button className="icon-btn" title="New chat (Ctrl+N)" onClick={() => p.setMode('compose')}>
|
<button className="icon-btn" title="New chat (Ctrl+N)" onClick={() => p.setMode('compose')}>
|
||||||
<ComposeIcon />
|
<ComposeIcon />
|
||||||
</button>
|
</button>
|
||||||
@@ -186,9 +187,10 @@ export function Sidebar(p: Props) {
|
|||||||
>
|
>
|
||||||
<ArchiveIcon />
|
<ArchiveIcon />
|
||||||
</button>
|
</button>
|
||||||
<button className="icon-btn" title="Settings" onClick={p.onSettings}>
|
<button className="icon-btn" title="Preferences (Ctrl+,)" onClick={p.onSettings}>
|
||||||
<GearIcon />
|
<GearIcon />
|
||||||
</button>
|
</button>
|
||||||
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<div className="sidebar-body">
|
<div className="sidebar-body">
|
||||||
{p.mode === 'search' && p.query.trim() ? (
|
{p.mode === 'search' && p.query.trim() ? (
|
||||||
@@ -254,7 +256,10 @@ function SyncFooter({ sync }: { sync?: SyncStatus }) {
|
|||||||
cls += ' error'
|
cls += ' error'
|
||||||
} else if (!sync.backfillDone && sync.backfillCursor) {
|
} else if (!sync.backfillDone && sync.backfillCursor) {
|
||||||
const d = new Date(sync.backfillCursor + 'T12:00:00Z')
|
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') {
|
} else if (!sync.backfillDone && sync.phase === 'backfill') {
|
||||||
text = 'Importing history…'
|
text = 'Importing history…'
|
||||||
} else if (gv && !gv.backfillDone && gv.phase === 'backfill') {
|
} else if (gv && !gv.backfillDone && gv.phase === 'backfill') {
|
||||||
@@ -279,7 +284,7 @@ function RefreshButton() {
|
|||||||
void Promise.allSettled([window.api.pollNow(), minSpin]).then(() => setBusy(false))
|
void Promise.allSettled([window.api.pollNow(), minSpin]).then(() => setBusy(false))
|
||||||
}
|
}
|
||||||
return (
|
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 />
|
<RefreshIcon />
|
||||||
</button>
|
</button>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ import { StrictMode } from 'react'
|
|||||||
import { createRoot } from 'react-dom/client'
|
import { createRoot } from 'react-dom/client'
|
||||||
import { App } from './App'
|
import { App } from './App'
|
||||||
import './styles.css'
|
import './styles.css'
|
||||||
|
import { installTooltips } from './tooltips'
|
||||||
|
|
||||||
|
installTooltips()
|
||||||
|
|
||||||
createRoot(document.getElementById('root')!).render(
|
createRoot(document.getElementById('root')!).render(
|
||||||
<StrictMode>
|
<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
|
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 {
|
export interface RabbitStatus {
|
||||||
adb: boolean // adb is installed
|
adb: boolean // adb is installed
|
||||||
bundledVersion?: string // the Android app this build carries
|
bundledVersion?: string // the Android app this build carries
|
||||||
@@ -31,6 +40,10 @@ export interface Api {
|
|||||||
saveSetup(creds: Credentials, settings: Settings): Promise<void>
|
saveSetup(creds: Credentials, settings: Settings): Promise<void>
|
||||||
updateSettings(settings: Settings): Promise<void>
|
updateSettings(settings: Settings): Promise<void>
|
||||||
setTheme(theme: Theme): 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>
|
setIcon(icon: IconStyle): Promise<void>
|
||||||
signOut(): Promise<void>
|
signOut(): Promise<void>
|
||||||
connectGoogleVoice(): Promise<void>
|
connectGoogleVoice(): Promise<void>
|
||||||
|
|||||||
@@ -123,6 +123,9 @@ export interface GvStatus {
|
|||||||
error?: string
|
error?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 'signal': Signal Desktop vibes; 'trave': the house look (shared-resources/design.html).
|
||||||
|
export type Look = 'signal' | 'trave'
|
||||||
|
|
||||||
export interface Settings {
|
export interface Settings {
|
||||||
pollSeconds: number
|
pollSeconds: number
|
||||||
dids: string[] // DIDs to sync; empty = all SMS-enabled
|
dids: string[] // DIDs to sync; empty = all SMS-enabled
|
||||||
@@ -132,6 +135,9 @@ export interface Settings {
|
|||||||
icon?: IconStyle // absent = dark
|
icon?: IconStyle // absent = dark
|
||||||
notifications: boolean // new messages go to the notification list
|
notifications: boolean // new messages go to the notification list
|
||||||
contactBook?: string // where "Add to contacts" puts them; default: GNOME Contacts' default
|
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 {
|
export interface Credentials {
|
||||||
|
|||||||
Reference in New Issue
Block a user