oxen-io / session-android

A private messenger for Android.
https://getsession.org
GNU General Public License v3.0
1.86k stars 170 forks source link

[SES-1901] Fix last sent called excessively #1489

Closed bemusementpark closed 4 months ago

bemusementpark commented 4 months ago

This PR removes much of the need to query the db for the last sent message.

  1. Initial query is moved into the background as the loader is being fetched.
  2. Basing on timestamps, as sms and mms ids can collide if id is not paired with isMms.
  3. onSend we put that new message into the cache.
  4. Subsequent queries are only performed if the previous lastSentTimestamp was deleted.
  5. This PR also will not force Sent status to be visible for outgoing messages if it is 20 messages old. We could make this older, but there's little point going excessively far into history to show the Sent status if it impacts performance.

This PR also fixes a logic error that caused onAttachmentNeedsDownload to run AttachmentDownloadJobs more than intended.