Include typing indicators in configuration sync messages; emit when that value changes.

This commit is contained in:
Matthew Chen 2018-11-01 14:05:54 -04:00
parent 33f5398ba8
commit a5ebe394d1
4 changed files with 22 additions and 3 deletions

View file

@ -106,6 +106,11 @@ NSString *const kSyncManagerLastContactSyncKey = @"kTSStorageManagerOWSSyncManag
return TSAccountManager.sharedInstance;
}
- (id<OWSTypingIndicators>)typingIndicators
{
return SSKEnvironment.shared.typingIndicators;
}
#pragma mark - Notifications
- (void)signalAccountsDidChange:(id)notification {
@ -219,10 +224,12 @@ NSString *const kSyncManagerLastContactSyncKey = @"kTSStorageManagerOWSSyncManag
BOOL areReadReceiptsEnabled = SSKEnvironment.shared.readReceiptManager.areReadReceiptsEnabled;
BOOL showUnidentifiedDeliveryIndicators = Environment.shared.preferences.shouldShowUnidentifiedDeliveryIndicators;
BOOL showTypingIndicators = self.typingIndicators.areTypingIndicatorsEnabled;
OWSSyncConfigurationMessage *syncConfigurationMessage =
[[OWSSyncConfigurationMessage alloc] initWithReadReceiptsEnabled:areReadReceiptsEnabled
showUnidentifiedDeliveryIndicators:showUnidentifiedDeliveryIndicators];
showUnidentifiedDeliveryIndicators:showUnidentifiedDeliveryIndicators
showTypingIndicators:showTypingIndicators];
[self.editingDatabaseConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
[self.messageSenderJobQueue addMessage:syncConfigurationMessage transaction:transaction];

View file

@ -11,7 +11,9 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithReadReceiptsEnabled:(BOOL)readReceiptsEnabled
showUnidentifiedDeliveryIndicators:(BOOL)showUnidentifiedDeliveryIndicators NS_DESIGNATED_INITIALIZER;
showUnidentifiedDeliveryIndicators:(BOOL)showUnidentifiedDeliveryIndicators
showTypingIndicators:(BOOL)showTypingIndicators NS_DESIGNATED_INITIALIZER;
- (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
@end

View file

@ -11,13 +11,15 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly) BOOL areReadReceiptsEnabled;
@property (nonatomic, readonly) BOOL showUnidentifiedDeliveryIndicators;
@property (nonatomic, readonly) BOOL showTypingIndicators;
@end
@implementation OWSSyncConfigurationMessage
- (instancetype)initWithReadReceiptsEnabled:(BOOL)areReadReceiptsEnabled
showUnidentifiedDeliveryIndicators:(BOOL)showUnidentifiedDeliveryIndicators {
showUnidentifiedDeliveryIndicators:(BOOL)showUnidentifiedDeliveryIndicators
showTypingIndicators:(BOOL)showTypingIndicators {
self = [super init];
if (!self) {
return nil;
@ -25,6 +27,7 @@ NS_ASSUME_NONNULL_BEGIN
_areReadReceiptsEnabled = areReadReceiptsEnabled;
_showUnidentifiedDeliveryIndicators = showUnidentifiedDeliveryIndicators;
_showTypingIndicators = showTypingIndicators;
return self;
}
@ -39,6 +42,7 @@ NS_ASSUME_NONNULL_BEGIN
SSKProtoSyncMessageConfigurationBuilder *configurationBuilder = [SSKProtoSyncMessageConfiguration builder];
configurationBuilder.readReceipts = self.areReadReceiptsEnabled;
configurationBuilder.unidentifiedDeliveryIndicators = self.showUnidentifiedDeliveryIndicators;
configurationBuilder.typingIndicators = self.showTypingIndicators;
NSError *error;
SSKProtoSyncMessageConfiguration *_Nullable configurationProto = [configurationBuilder buildAndReturnError:&error];

View file

@ -67,6 +67,10 @@ public class TypingIndicatorsImpl: NSObject, TypingIndicators {
return SSKEnvironment.shared.primaryStorage
}
private var syncManager: OWSSyncManagerProtocol {
return SSKEnvironment.shared.syncManager
}
// MARK: -
@objc
@ -76,6 +80,8 @@ public class TypingIndicatorsImpl: NSObject, TypingIndicators {
_areTypingIndicatorsEnabled = value
primaryStorage.dbReadWriteConnection.setBool(value, forKey: kDatabaseKey_TypingIndicatorsEnabled, inCollection: kDatabaseCollection)
syncManager.sendConfigurationSyncMessage()
}
@objc