fix: sync latest frontend source with linter fixes
This commit is contained in:
@@ -35,6 +35,14 @@ export interface MeshChannel {
|
||||
has_secret: boolean
|
||||
}
|
||||
|
||||
export type MeshMessageTypeLabel =
|
||||
| 'text'
|
||||
| 'alert'
|
||||
| 'invoice'
|
||||
| 'psbt_hash'
|
||||
| 'coordinate'
|
||||
| 'block_header'
|
||||
|
||||
export interface MeshMessage {
|
||||
id: number
|
||||
direction: 'sent' | 'received'
|
||||
@@ -44,6 +52,46 @@ export interface MeshMessage {
|
||||
timestamp: string
|
||||
delivered: boolean
|
||||
encrypted: boolean
|
||||
message_type?: MeshMessageTypeLabel
|
||||
typed_payload?: InvoiceData | AlertData | CoordinateData | null
|
||||
}
|
||||
|
||||
export interface InvoiceData {
|
||||
bolt11: string
|
||||
amount_sats: number
|
||||
memo: string | null
|
||||
payment_hash?: string
|
||||
paid?: boolean
|
||||
}
|
||||
|
||||
export interface AlertData {
|
||||
alert_type: 'emergency' | 'status' | 'dead_man' | 'block_header'
|
||||
message: string
|
||||
coordinate?: { lat: number; lng: number; label?: string }
|
||||
signed?: boolean
|
||||
}
|
||||
|
||||
export interface CoordinateData {
|
||||
lat: number
|
||||
lng: number
|
||||
label?: string
|
||||
}
|
||||
|
||||
export interface SessionStatus {
|
||||
has_session: boolean
|
||||
forward_secrecy: boolean
|
||||
message_count: number
|
||||
ratchet_generation: number
|
||||
peer_did: string | null
|
||||
}
|
||||
|
||||
export interface AlertStatus {
|
||||
dead_man_enabled: boolean
|
||||
dead_man_interval_secs: number
|
||||
triggered: boolean
|
||||
time_remaining_secs: number
|
||||
has_gps: boolean
|
||||
emergency_contacts: number
|
||||
}
|
||||
|
||||
export const useMeshStore = defineStore('mesh', () => {
|
||||
@@ -163,6 +211,64 @@ export const useMeshStore = defineStore('mesh', () => {
|
||||
}
|
||||
}
|
||||
|
||||
async function sendInvoice(contactId: number, amountSats: number, memo?: string) {
|
||||
try {
|
||||
sending.value = true
|
||||
error.value = null
|
||||
return await rpcClient.call<{ sent: boolean; amount_sats: number; bolt11: string }>({
|
||||
method: 'mesh.send-invoice',
|
||||
params: { contact_id: contactId, amount_sats: amountSats, memo },
|
||||
})
|
||||
} catch (err: unknown) {
|
||||
error.value = err instanceof Error ? err.message : 'Failed to send invoice'
|
||||
throw err
|
||||
} finally {
|
||||
sending.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function sendCoordinate(contactId: number, lat: number, lng: number, label?: string) {
|
||||
try {
|
||||
sending.value = true
|
||||
error.value = null
|
||||
return await rpcClient.call<{ sent: boolean }>({
|
||||
method: 'mesh.send-coordinate',
|
||||
params: { contact_id: contactId, lat, lng, label },
|
||||
})
|
||||
} catch (err: unknown) {
|
||||
error.value = err instanceof Error ? err.message : 'Failed to send coordinate'
|
||||
throw err
|
||||
} finally {
|
||||
sending.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function sendAlert(message: string, alertType: string, broadcast = false, lat?: number, lng?: number) {
|
||||
try {
|
||||
error.value = null
|
||||
return await rpcClient.call<{ sent: boolean; signed: boolean }>({
|
||||
method: 'mesh.send-alert',
|
||||
params: { message, alert_type: alertType, broadcast, lat, lng },
|
||||
})
|
||||
} catch (err: unknown) {
|
||||
error.value = err instanceof Error ? err.message : 'Failed to send alert'
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
||||
async function getSessionStatus(contactId: number): Promise<SessionStatus> {
|
||||
return rpcClient.call<SessionStatus>({
|
||||
method: 'mesh.session-status',
|
||||
params: { contact_id: contactId },
|
||||
})
|
||||
}
|
||||
|
||||
async function rotatePrekeys() {
|
||||
return rpcClient.call<{ rotated: boolean; one_time_prekeys: number }>({
|
||||
method: 'mesh.rotate-prekeys',
|
||||
})
|
||||
}
|
||||
|
||||
async function refreshAll() {
|
||||
await Promise.all([fetchStatus(), fetchPeers(), fetchMessages()])
|
||||
}
|
||||
@@ -185,5 +291,10 @@ export const useMeshStore = defineStore('mesh', () => {
|
||||
refreshAll,
|
||||
markChatRead,
|
||||
clearViewingChat,
|
||||
sendInvoice,
|
||||
sendCoordinate,
|
||||
sendAlert,
|
||||
getSessionStatus,
|
||||
rotatePrekeys,
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user