v0.9.7: bubble for Android 0.7.8 — desktop notifications come down when the chat's read elsewhere, and on quit instead of being stranded in the list
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "voipms-desktop",
|
"name": "voipms-desktop",
|
||||||
"productName": "bubble",
|
"productName": "bubble",
|
||||||
"version": "0.9.6",
|
"version": "0.9.7",
|
||||||
"description": "Signal-style desktop SMS client for voip.ms",
|
"description": "Signal-style desktop SMS client for voip.ms",
|
||||||
"author": "trav <trav@teafry.me>",
|
"author": "trav <trav@teafry.me>",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
|||||||
+11
-3
@@ -26,7 +26,7 @@ import { SendMediaType } from './gvoice/schema'
|
|||||||
import { clearGvSession, exportCookies, gvTransport, hasGvSession, importCookies, parseCookies, signInWindow } from './gvoice/session'
|
import { clearGvSession, exportCookies, gvTransport, hasGvSession, importCookies, parseCookies, signInWindow } from './gvoice/session'
|
||||||
import { gvMessageId, GvSyncEngine } from './gvoice/sync'
|
import { gvMessageId, GvSyncEngine } from './gvoice/sync'
|
||||||
import { WaaSigner } from './gvoice/waa'
|
import { WaaSigner } from './gvoice/waa'
|
||||||
import { clearNotifications, notifyNew } from './notify'
|
import { clearNotifications, closeAllNotifications, notifyNew, sweepNotifications } from './notify'
|
||||||
import * as rabbit from './rabbit'
|
import * as rabbit from './rabbit'
|
||||||
import { checkUrl, clearRelayConfig, loadRelayConfig, newKey, RelayEngine, saveRelayConfig, SIM_DID } from './relay'
|
import { checkUrl, clearRelayConfig, loadRelayConfig, newKey, RelayEngine, saveRelayConfig, SIM_DID } from './relay'
|
||||||
|
|
||||||
@@ -101,6 +101,13 @@ function onNewMessages(msgs: NewMessage[]): void {
|
|||||||
if (settings.notifications && !win?.isFocused()) notifyNew(msgs, { db, contacts, onClick: openFromNotification })
|
if (settings.notifications && !win?.isFocused()) notifyNew(msgs, { db, contacts, onClick: openFromNotification })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Read/unread changed from outside the app: chats read elsewhere lose their
|
||||||
|
// notifications here too.
|
||||||
|
function readStateChanged(): void {
|
||||||
|
sweepNotifications((did, contact) => db.hasUnread(did, contact))
|
||||||
|
send('conversationsChanged')
|
||||||
|
}
|
||||||
|
|
||||||
function openFromNotification(key: { did: string; contact: string }): void {
|
function openFromNotification(key: { did: string; contact: string }): void {
|
||||||
if (!win || win.isDestroyed()) return
|
if (!win || win.isDestroyed()) return
|
||||||
if (win.isMinimized()) win.restore()
|
if (win.isMinimized()) win.restore()
|
||||||
@@ -129,7 +136,7 @@ function startRelay(): void {
|
|||||||
if (!cfg) return
|
if (!cfg) return
|
||||||
relay = new RelayEngine(db, media, cfg, settings.pollSeconds)
|
relay = new RelayEngine(db, media, cfg, settings.pollSeconds)
|
||||||
relay.on('messages', onNewMessages)
|
relay.on('messages', onNewMessages)
|
||||||
relay.on('changed', () => send('conversationsChanged'))
|
relay.on('changed', readStateChanged)
|
||||||
relay.on('status', () => send('relayStatus', relay?.status()))
|
relay.on('status', () => send('relayStatus', relay?.status()))
|
||||||
relay.start()
|
relay.start()
|
||||||
}
|
}
|
||||||
@@ -159,7 +166,7 @@ function startGvSync(): void {
|
|||||||
gvSync = new GvSyncEngine(db, gv, { did, pollSeconds: settings.pollSeconds, backfillFloor: settings.backfillFloor })
|
gvSync = new GvSyncEngine(db, gv, { did, pollSeconds: settings.pollSeconds, backfillFloor: settings.backfillFloor })
|
||||||
gvSync.on('messages', onNewMessages)
|
gvSync.on('messages', onNewMessages)
|
||||||
gvSync.on('status', () => send('syncStatus', syncStatus()))
|
gvSync.on('status', () => send('syncStatus', syncStatus()))
|
||||||
gvSync.on('readChanged', () => send('conversationsChanged'))
|
gvSync.on('readChanged', readStateChanged)
|
||||||
gvSync.start()
|
gvSync.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -838,6 +845,7 @@ app.on('before-quit', (e) => {
|
|||||||
if (quitting || !db) return
|
if (quitting || !db) return
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
quitting = true
|
quitting = true
|
||||||
|
closeAllNotifications()
|
||||||
sync?.stop()
|
sync?.stop()
|
||||||
stopGv()
|
stopGv()
|
||||||
relay?.stop()
|
relay?.stop()
|
||||||
|
|||||||
@@ -31,6 +31,22 @@ export function clearNotifications(did: string, contact: string): void {
|
|||||||
for (const n of shown) n.close()
|
for (const n of shown) n.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Read state changed somewhere else (the Rabbit, the phone, Google Voice's
|
||||||
|
// site): take down what's no longer unread, like the Android app's sweep.
|
||||||
|
export function sweepNotifications(isUnread: (did: string, contact: string) => boolean): void {
|
||||||
|
for (const key of [...live.keys()]) {
|
||||||
|
const [did, contact] = key.split('\n')
|
||||||
|
if (!isUnread(did, contact)) clearNotifications(did, contact)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Quitting: once this process is gone nothing can close them (or answer
|
||||||
|
// their clicks), so they'd sit in the list for good. Take them all down.
|
||||||
|
export function closeAllNotifications(): void {
|
||||||
|
for (const shown of live.values()) for (const n of shown) n.close()
|
||||||
|
live.clear()
|
||||||
|
}
|
||||||
|
|
||||||
const nameOf = (contacts: ContactDirectory, n: string): string => contacts.lookup(n)?.name ?? formatNumber(n)
|
const nameOf = (contacts: ContactDirectory, n: string): string => contacts.lookup(n)?.name ?? formatNumber(n)
|
||||||
|
|
||||||
export function conversationTitle(db: MessageDb, contacts: ContactDirectory, did: string, contact: string): string {
|
export function conversationTitle(db: MessageDb, contacts: ContactDirectory, did: string, contact: string): string {
|
||||||
|
|||||||
Reference in New Issue
Block a user