Merge branch 'charlesmchen/typingIndicators6'

pull/1/head
Matthew Chen 7 years ago
commit 13ab75fea9

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

@ -296,8 +296,9 @@ message SyncMessage {
} }
message Configuration { message Configuration {
optional bool readReceipts = 1; optional bool readReceipts = 1;
optional bool unidentifiedDeliveryIndicators = 2; optional bool unidentifiedDeliveryIndicators = 2;
optional bool typingIndicators = 3;
} }
optional Sent sent = 1; optional Sent sent = 1;

@ -11,7 +11,9 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)init NS_UNAVAILABLE; - (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithReadReceiptsEnabled:(BOOL)readReceiptsEnabled - (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; - (nullable instancetype)initWithCoder:(NSCoder *)coder NS_DESIGNATED_INITIALIZER;
@end @end

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

@ -4154,6 +4154,9 @@ extension SSKProtoSyncMessageRead.SSKProtoSyncMessageReadBuilder {
if hasUnidentifiedDeliveryIndicators { if hasUnidentifiedDeliveryIndicators {
builder.setUnidentifiedDeliveryIndicators(unidentifiedDeliveryIndicators) builder.setUnidentifiedDeliveryIndicators(unidentifiedDeliveryIndicators)
} }
if hasTypingIndicators {
builder.setTypingIndicators(typingIndicators)
}
return builder return builder
} }
@ -4171,6 +4174,10 @@ extension SSKProtoSyncMessageRead.SSKProtoSyncMessageReadBuilder {
proto.unidentifiedDeliveryIndicators = valueParam proto.unidentifiedDeliveryIndicators = valueParam
} }
@objc public func setTypingIndicators(_ valueParam: Bool) {
proto.typingIndicators = valueParam
}
@objc public func build() throws -> SSKProtoSyncMessageConfiguration { @objc public func build() throws -> SSKProtoSyncMessageConfiguration {
return try SSKProtoSyncMessageConfiguration.parseProto(proto) return try SSKProtoSyncMessageConfiguration.parseProto(proto)
} }
@ -4196,6 +4203,13 @@ extension SSKProtoSyncMessageRead.SSKProtoSyncMessageReadBuilder {
return proto.hasUnidentifiedDeliveryIndicators return proto.hasUnidentifiedDeliveryIndicators
} }
@objc public var typingIndicators: Bool {
return proto.typingIndicators
}
@objc public var hasTypingIndicators: Bool {
return proto.hasTypingIndicators
}
private init(proto: SignalServiceProtos_SyncMessage.Configuration) { private init(proto: SignalServiceProtos_SyncMessage.Configuration) {
self.proto = proto self.proto = proto
} }

@ -1741,12 +1741,22 @@ struct SignalServiceProtos_SyncMessage {
/// Clears the value of `unidentifiedDeliveryIndicators`. Subsequent reads from it will return its default value. /// Clears the value of `unidentifiedDeliveryIndicators`. Subsequent reads from it will return its default value.
mutating func clearUnidentifiedDeliveryIndicators() {self._unidentifiedDeliveryIndicators = nil} mutating func clearUnidentifiedDeliveryIndicators() {self._unidentifiedDeliveryIndicators = nil}
var typingIndicators: Bool {
get {return _typingIndicators ?? false}
set {_typingIndicators = newValue}
}
/// Returns true if `typingIndicators` has been explicitly set.
var hasTypingIndicators: Bool {return self._typingIndicators != nil}
/// Clears the value of `typingIndicators`. Subsequent reads from it will return its default value.
mutating func clearTypingIndicators() {self._typingIndicators = nil}
var unknownFields = SwiftProtobuf.UnknownStorage() var unknownFields = SwiftProtobuf.UnknownStorage()
init() {} init() {}
fileprivate var _readReceipts: Bool? = nil fileprivate var _readReceipts: Bool? = nil
fileprivate var _unidentifiedDeliveryIndicators: Bool? = nil fileprivate var _unidentifiedDeliveryIndicators: Bool? = nil
fileprivate var _typingIndicators: Bool? = nil
} }
init() {} init() {}
@ -4048,6 +4058,7 @@ extension SignalServiceProtos_SyncMessage.Configuration: SwiftProtobuf.Message,
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "readReceipts"), 1: .same(proto: "readReceipts"),
2: .same(proto: "unidentifiedDeliveryIndicators"), 2: .same(proto: "unidentifiedDeliveryIndicators"),
3: .same(proto: "typingIndicators"),
] ]
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws { mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
@ -4055,6 +4066,7 @@ extension SignalServiceProtos_SyncMessage.Configuration: SwiftProtobuf.Message,
switch fieldNumber { switch fieldNumber {
case 1: try decoder.decodeSingularBoolField(value: &self._readReceipts) case 1: try decoder.decodeSingularBoolField(value: &self._readReceipts)
case 2: try decoder.decodeSingularBoolField(value: &self._unidentifiedDeliveryIndicators) case 2: try decoder.decodeSingularBoolField(value: &self._unidentifiedDeliveryIndicators)
case 3: try decoder.decodeSingularBoolField(value: &self._typingIndicators)
default: break default: break
} }
} }
@ -4067,12 +4079,16 @@ extension SignalServiceProtos_SyncMessage.Configuration: SwiftProtobuf.Message,
if let v = self._unidentifiedDeliveryIndicators { if let v = self._unidentifiedDeliveryIndicators {
try visitor.visitSingularBoolField(value: v, fieldNumber: 2) try visitor.visitSingularBoolField(value: v, fieldNumber: 2)
} }
if let v = self._typingIndicators {
try visitor.visitSingularBoolField(value: v, fieldNumber: 3)
}
try unknownFields.traverse(visitor: &visitor) try unknownFields.traverse(visitor: &visitor)
} }
static func ==(lhs: SignalServiceProtos_SyncMessage.Configuration, rhs: SignalServiceProtos_SyncMessage.Configuration) -> Bool { static func ==(lhs: SignalServiceProtos_SyncMessage.Configuration, rhs: SignalServiceProtos_SyncMessage.Configuration) -> Bool {
if lhs._readReceipts != rhs._readReceipts {return false} if lhs._readReceipts != rhs._readReceipts {return false}
if lhs._unidentifiedDeliveryIndicators != rhs._unidentifiedDeliveryIndicators {return false} if lhs._unidentifiedDeliveryIndicators != rhs._unidentifiedDeliveryIndicators {return false}
if lhs._typingIndicators != rhs._typingIndicators {return false}
if lhs.unknownFields != rhs.unknownFields {return false} if lhs.unknownFields != rhs.unknownFields {return false}
return true return true
} }

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

Loading…
Cancel
Save