Signal-iOS/SignalServiceKit
Evan Hahn 47480b7eee Speed up "mark read locally" optimization check
This should cause no change in behavior.

We had logic like this pseudocode:

```
unreadCount = db.countUnreadMessages()
messagesWithUnreadReactionsCount = db.countMessagesWithUnreadReactions()
if unreadCount == 0 && messagesWithUnreadReactionsCount == 0 {
  // Avoid unnecessary writes.
  return
}

db.markMessagesRead()
```

This optimization works but has two problems:

1. We don't actually need the count. We just need to know whether
   anything exists.
2. If there are unread messages, we should do the cleanup regardless,
   and we don't need to do the second check query.

Now the pseudocode looks like this:

```
if db.hasUnreadMessages() || db.hasMessagesToMarkRead() {
  // Avoid unnecessary writes.
  return
}

db.markMessagesRead()
```
2023-03-30 10:22:50 -05:00
..
Calls Enable a RingRTC field trial for all users, with kill switch 2023-02-01 16:20:16 -06:00
ChangePhoneNumber Clean up SignalRecipient create & fetch APIs 2023-03-29 18:40:05 -07:00
DateProvider Implement RegistrationSessionManager 2023-02-08 15:37:12 -08:00
Dependencies Rename StorageServiceManagerProtocol 2023-03-23 09:29:38 -07:00
Experience Upgrades guard usernames megaphone on usernames feature flag 2023-03-17 10:25:25 -07:00
GroupMembers Clean up logic that builds the TSGroupMember table 2023-03-27 12:52:54 -07:00
Jobs Clean up queue names 2023-02-27 14:16:09 -08:00
KeyBackupService Handle being de-registered while still in the middle of registration 2023-03-28 07:50:56 -07:00
Mocks Make SystemStoryManagerTest synchronous to end its reign of flaky terror 2023-03-29 08:47:49 -07:00
protobuf Atomically persist values from change-number 2023-03-23 16:50:59 -07:00
Registration Change all e164 references in reg coordinator to E164 type 2023-03-16 11:32:13 -07:00
Resources Add parsing support for the pni capability 2023-03-24 10:07:39 -07:00
Schedulers Make SystemStoryManagerTest synchronous to end its reign of flaky terror 2023-03-29 08:47:49 -07:00
src Speed up "mark read locally" optimization check 2023-03-30 10:22:50 -05:00
tests Swiftify AppVersion.compare 2023-03-30 10:19:59 -05:00
Usernames Rename StorageServiceManagerProtocol 2023-03-23 09:29:38 -07:00
.clang-format Update clang-format with AllowShortEnumsOnASingleLine: false 2022-03-14 11:20:20 -07:00
.gitignore
.travis.yml
SignalServiceKit-Prefix.pch Change license to AGPL 2022-10-13 08:25:37 -05:00
SignalServiceKit.h Remove unused NSArray+OWS.[hm] files 2023-03-27 11:30:06 -07:00