Fixes a bug where a nil MessageBody was passed to a Swift initializer
expecting non-nil. To fix, OutgoingMessagePreparer.init will now accept
a nil MessageBody and process it correctly.
- Removes ContactsUpdater singleton. It wasn't really tracking much
state anyway
- Introduces ContactDiscoveryTask. This creates a
ContactDiscoveryOperation (modern or legacy) and updates the
SignalRecipients database on completion. Returns a promise.
- Begin migrating away from operation queues
PromiseKit is weird about priority propogation, so this shouldn't be
used yet. Since all then closures are asynced, priorities don't
propogate down to underlying queues. This means the a
ContactDiscoveryTask on the main queue will not boost the priority on
the ModernContactDiscoverOperation's owned operation queue
This fixes a bug where the ScrollDownButton would continue to persist
even after jumping to the bottom.
This is due to undefined ordering in UIKit with how it handles
scrollViewDidScroll: and updating the collectionView's visible index
paths. We'd receive the final scrollViewDidScroll: before the visible
items were updated.
To fix this, we need to figure out what cell's are visible without
relying on UICollectionView's cell appearance to be up to date. This
instead uses the collection view layout's cell frames to determine if
they live in the visible content rect of the collection view. Since
layout must be available for the cell to be visible, this should be
correct.
Made some other minor changes around naming. Clarified that lastSortId
and lastIndexPath refer to the viewmodel's loaded window, not the
global thread state.
This change moves -lastVisibleSortID from a property to a method.
Instead of having to explicitly call an update method to recompute the
lastVisibleSortID, we'll just recompute it every time it's invoked.
This is an improvement because:
a. The computation wasn't very expensive
b. We were calling -updateLastVisibleSortID much more frequently than
how often we actually read it.
c. We had to make sure we aggressively updated the lastVisibleSortID to
make sure it was up to date when we actually read it.
By moving to something that's recomputed at the time of invocation, we
end up reducing unnecessary work for a more accurate result.
-updateLastVisibleSortId had one side-effect: clearing the unread
message flag. This responsibility is now moved to
-markVisibleMessagesAsRead. This seems to make more sense anyway.
Other changes:
- Adds an explicit clear-only way of updating the unread flag. This is
only called from one place but it removes logic that might be unclear
at the call site with a method name that makes more sense.
- Adds some debug assertions to existing code
- Adds a new ivar to track the last sortID reported to
OWSReadReceiptManager
- Updates -markVisibleMessagesAsRead to adopt this new ivar. Minor
spacing improvements to this method.
- Renames the method to clear the thread unread flag. This helps to
differentiate from other similarly named symbols that refer to the
ConversationViewController's unread flag.