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.
This change improves the performance of unread message tracking and
collocates code that configures the scroll down button
Before, a block was asynced back onto the main queue to take out a read
transaction. This was a fairly hot path, occurring on
-scrollViewDidScroll:, a 100ms timer, etc. This transaction was usually
not useful since unread count updates only occur sparingly.
This change breaks out unread message count updates into a separate
method. When updating lastVisibleSortId, the unread method will only be
called when it appears that we may moving from the unread -> read state.
This adds a couple other minor changes:
- Minor reconfiguring of some properties (e.g. making a property
readwrite, renaming a getter, etc)
- Leverages a custom setter to automatically reconfigure the
scrollDownButton on relevant changes
- Moves all repeated view configuration of the scrollDownButton into a
single method