mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Include typing indicators in configuration sync messages; emit when that value changes.
This commit is contained in:
parent
33f5398ba8
commit
a5ebe394d1
4 changed files with 22 additions and 3 deletions
|
@ -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];
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue