v0.5.1: bubble for Android 0.5.1 — no double sends when a text with an emoji is cut off mid-send
voip.ms's listing drops emoji, so a send whose reply was lost (here the laptop slept 8 s after Send) never matched its own copy in the listing and went out a second time. Match with the emoji taken out (exact match first), and after an uncertain send only send again once a listing check actually got through; if none can, mark it failed with a note instead.
This commit is contained in:
+8
-5
@@ -62,7 +62,7 @@ export class SyncEngine extends EventEmitter {
|
||||
private burstUntil = 0
|
||||
private running = false
|
||||
private backfilling = false
|
||||
private polling?: Promise<void>
|
||||
private polling?: Promise<boolean>
|
||||
private status: SyncStatus
|
||||
|
||||
constructor(
|
||||
@@ -126,16 +126,17 @@ export class SyncEngine extends EventEmitter {
|
||||
|
||||
// Manual refresh. Joins a check that's already under way rather than
|
||||
// returning early, so the caller knows when fresh results are in.
|
||||
async pollNow(): Promise<void> {
|
||||
await this.poll()
|
||||
// Resolves false when the listing couldn't be fetched.
|
||||
pollNow(): Promise<boolean> {
|
||||
return this.poll()
|
||||
}
|
||||
|
||||
private poll(): Promise<void> {
|
||||
private poll(): Promise<boolean> {
|
||||
this.polling ??= this.fetchRecent().finally(() => (this.polling = undefined))
|
||||
return this.polling
|
||||
}
|
||||
|
||||
private async fetchRecent(): Promise<void> {
|
||||
private async fetchRecent(): Promise<boolean> {
|
||||
try {
|
||||
const now = Date.now()
|
||||
const rows = await this.api.getMessages({ from: ymd(now - DAY), to: ymd(now + DAY), limit: PAGE_LIMIT })
|
||||
@@ -143,7 +144,9 @@ export class SyncEngine extends EventEmitter {
|
||||
this.setStatus({ lastPoll: Date.now(), error: undefined, phase: this.backfilling ? 'backfill' : 'polling' })
|
||||
} catch (e) {
|
||||
this.setStatus({ phase: 'error', error: (e as Error).message })
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private async backfill(): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user