Desktop: - Search lists chats whose own name matches first, so a named group isn't pushed out of the top 8 by chats that merely include a member. Android (Rabbit R1) app, 0.2.0: - Pull the chat list past its top for a search box (name, person, number, then group members; archived chats too; Back clears it). - Swipe right to left marks a chat unread / read over a magenta band; left to right still archives (SwipeActions replaces SwipeArchive). - Google Voice chats don't offer voice notes in the paperclip bubble. - Chats open with their newest 60 messages, then the full history; marking read (and the Google Voice network call) waits until they're on screen. Cached pictures show at once, and one slow download no longer blocks the other images. Fixed a contacts reload race. - Sandbox data gains filler chats, a named group and a 4,000-message chat. Also: the Android app, Google Voice support, media, export, emoji and the other work since the first commit, and a CLAUDE.md carrying the privacy rule.
60 lines
3.3 KiB
TypeScript
60 lines
3.3 KiB
TypeScript
import { contextBridge, ipcRenderer, type IpcRendererEvent } from 'electron'
|
|
import type { Api } from '@shared/api'
|
|
|
|
function on<T extends unknown[]>(channel: string, cb: (...args: T) => void): () => void {
|
|
const listener = (_e: IpcRendererEvent, ...args: unknown[]): void => cb(...(args as T))
|
|
ipcRenderer.on(channel, listener)
|
|
return () => ipcRenderer.removeListener(channel, listener)
|
|
}
|
|
|
|
const api: Api = {
|
|
getState: () => ipcRenderer.invoke('getState'),
|
|
testCredentials: (creds) => ipcRenderer.invoke('testCredentials', creds),
|
|
saveSetup: (creds, settings) => ipcRenderer.invoke('saveSetup', creds, settings),
|
|
updateSettings: (settings) => ipcRenderer.invoke('updateSettings', settings),
|
|
setTheme: (theme) => ipcRenderer.invoke('setTheme', theme),
|
|
signOut: () => ipcRenderer.invoke('signOut'),
|
|
connectGoogleVoice: () => ipcRenderer.invoke('connectGoogleVoice'),
|
|
connectGoogleVoiceCookies: (text) => ipcRenderer.invoke('connectGoogleVoiceCookies', text),
|
|
disconnectGoogleVoice: () => ipcRenderer.invoke('disconnectGoogleVoice'),
|
|
rabbitStatus: () => ipcRenderer.invoke('rabbitStatus'),
|
|
rabbitInstall: (mode) => ipcRenderer.invoke('rabbitInstall', mode),
|
|
rabbitSync: () => ipcRenderer.invoke('rabbitSync'),
|
|
onRabbitProgress: (cb) => on('rabbitProgress', cb),
|
|
|
|
listContacts: () => ipcRenderer.invoke('listContacts'),
|
|
listAddressBooks: () => ipcRenderer.invoke('listAddressBooks'),
|
|
addContact: (c) => ipcRenderer.invoke('addContact', c),
|
|
listConversations: () => ipcRenderer.invoke('listConversations'),
|
|
getMessages: (did, contact) => ipcRenderer.invoke('getMessages', did, contact),
|
|
markRead: (did, contact) => ipcRenderer.invoke('markRead', did, contact),
|
|
markUnread: (did, contact) => ipcRenderer.invoke('markUnread', did, contact),
|
|
setArchived: (did, contact, archived) => ipcRenderer.invoke('setArchived', did, contact, archived),
|
|
setName: (did, contact, name) => ipcRenderer.invoke('setName', did, contact, name),
|
|
getDrafts: () => ipcRenderer.invoke('getDrafts'),
|
|
setDraft: (contact, text) => ipcRenderer.invoke('setDraft', contact, text),
|
|
search: (query, scope) => ipcRenderer.invoke('search', query, scope),
|
|
send: (did, contact, text, attachments) => ipcRenderer.invoke('send', did, contact, text, attachments),
|
|
deleteFailed: (id) => ipcRenderer.invoke('deleteFailed', id),
|
|
retryFailed: (id) => ipcRenderer.invoke('retryFailed', id),
|
|
saveMedia: (id, index) => ipcRenderer.invoke('saveMedia', id, index),
|
|
exportChat: (did, contact, opts) => ipcRenderer.invoke('exportChat', did, contact, opts),
|
|
readMedia: (id, index) => ipcRenderer.invoke('readMedia', id, index),
|
|
copyImage: (png) => ipcRenderer.invoke('copyImage', png),
|
|
|
|
syncStatus: () => ipcRenderer.invoke('syncStatus'),
|
|
pollNow: () => ipcRenderer.invoke('pollNow'),
|
|
openDataFolder: () => ipcRenderer.invoke('openDataFolder'),
|
|
snapshotNow: () => ipcRenderer.invoke('snapshotNow'),
|
|
chooseDataDir: () => ipcRenderer.invoke('chooseDataDir'),
|
|
|
|
onMessages: (cb) => on('messages', cb),
|
|
onConversationsChanged: (cb) => on('conversationsChanged', cb),
|
|
onSyncStatus: (cb) => on('syncStatus', cb),
|
|
onContactsChanged: (cb) => on('contactsChanged', cb),
|
|
onStateChanged: (cb) => on('stateChanged', cb),
|
|
onOpenConversation: (cb) => on('openConversation', cb)
|
|
}
|
|
|
|
contextBridge.exposeInMainWorld('api', api)
|