Disable input if a friend request is pending

pull/14/head
Niels Andriesse 7 years ago
parent d91dc5f045
commit e3e7788219

@ -217,15 +217,9 @@ NS_ASSUME_NONNULL_BEGIN
}
if (self.isFriendRequest) {
NSString *rawKind;
switch (self.friendRequestState) {
case TSThreadFriendRequestStateRequestReceived:
rawKind = @"incoming";
break;
case TSThreadFriendRequestStateRequestSent:
rawKind = @"outgoing";
break;
}
// At this point, self.friendRequestState should be either TSThreadFriendRequestStateRequestReceived,
// TSThreadFriendRequestStatePendingSend or TSThreadFriendRequestStateRequestSent
NSString *rawKind = self.friendRequestState == TSThreadFriendRequestStateRequestReceived ? @"incoming" : @"outgoing";
self.friendRequestView = [[FriendRequestView alloc] initWithRawKind:rawKind];
self.friendRequestView.message = self.message;
self.friendRequestView.delegate = self.friendRequestViewDelegate;

@ -627,6 +627,7 @@ typedef enum : NSUInteger {
self.inputToolbar.inputToolbarDelegate = self;
self.inputToolbar.inputTextViewDelegate = self;
SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _inputToolbar);
[self updateIsInputToolbarInteractionEnabled];
self.loadMoreHeader = [UILabel new];
self.loadMoreHeader.text = NSLocalizedString(@"CONVERSATION_VIEW_LOADING_MORE_MESSAGES",
@ -1582,6 +1583,12 @@ typedef enum : NSUInteger {
self.headerView.attributedSubtitle = subtitleText;
}
#pragma mark - Updating
- (void)updateIsInputToolbarInteractionEnabled {
// TODO: Listen to friend request updates and call this accordingly
[self.inputToolbar setUserInteractionEnabled:!self.thread.isPendingFriendRequest];
}
#pragma mark - Identity

@ -298,7 +298,7 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error);
OWSLogVerbose(@"Updating local profile on service with no avatar.");
tryToUpdateService(nil, nil);
/* ========== Original Code ===============
/* ========== Original code ===============
if (avatarImage) {
// If we have a new avatar image, we must first:
//
@ -538,7 +538,7 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error);
// Loki: We don't need to make any server calls so succeed automatically
successBlock();
/* ============ Original Code ============
/* ============ Original code ============
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSData *_Nullable encryptedPaddedName = [self encryptProfileNameWithUnpaddedName:localProfileName];

@ -79,9 +79,9 @@ public class ProfileFetcherJob: NSObject {
public func run(recipientIds: [String]) {
AssertIsOnMainThread()
/* Loki: Original Code
/* Loki: Original code
* Disabled as we don't have an endpoint for fetching profiles
* =========================
* ================
guard CurrentAppContext().isMainApp else {
// Only refresh profiles in the MainApp to decrease the chance of missed SN notifications
// in the AppExtension for our users who choose not to verify contacts.

@ -39,8 +39,8 @@ public class CreatePreKeysOperation: OWSOperation {
Logger.debug("[CreatePreKeysOperation] done")
self.reportSuccess()
/* Loki: Original Code
* ==================
/* Loki: Original code
* ================
let identityKey: Data = self.identityKeyManager.identityKeyPair()!.publicKey
let signedPreKeyRecord: SignedPreKeyRecord = self.primaryStorage.generateRandomSignedRecord()
let preKeyRecords: [PreKeyRecord] = self.primaryStorage.generatePreKeyRecords()

@ -56,8 +56,8 @@ public class RefreshPreKeysOperation: OWSOperation {
self.reportSuccess()
}
/* Loki: Original Code
* =============
/* Loki: Original code
* ================
firstly {
self.accountServiceClient.getPreKeysCount()
}.then(on: DispatchQueue.global()) { preKeysCount -> Promise<Void> in

@ -41,8 +41,8 @@ public class RotateSignedPreKeyOperation: OWSOperation {
self.reportSuccess()
}
/* Loki: Original Code
* =========
/* Loki: Original code
* ================
let signedPreKeyRecord: SignedPreKeyRecord = self.primaryStorage.generateRandomSignedRecord()
self.primaryStorage.storeSignedPreKey(signedPreKeyRecord.id, signedPreKeyRecord: signedPreKeyRecord)

@ -30,11 +30,11 @@ NS_ASSUME_NONNULL_BEGIN
/**
Generate a `PreKeyBundle` for the given contact.
This doesn't store the pre key bundle, and you shouldn't store this bundle.
This doesn't store the prekey bundle, and you shouldn't store this bundle.
It's used for generating bundles to send to other users.
@param pubKey The hex encoded public key of the contact.
@return A pre key bundle for the contact.
@return A prekey bundle for the contact.
*/
- (PreKeyBundle *)generatePreKeyBundleForContact:(NSString *)pubKey;
@ -42,14 +42,14 @@ NS_ASSUME_NONNULL_BEGIN
Get the `PreKeyBundle` associated with the given contact.
@param pubKey The hex encoded public key of the contact.
@return The pre key bundle or `nil` if it doesn't exist.
@return The prekey bundle or `nil` if it doesn't exist.
*/
- (PreKeyBundle *_Nullable)getPreKeyBundleForContact:(NSString *)pubKey;
/**
Set the `PreKeyBundle` for the given contact.
@param bundle The pre key bundle.
@param bundle The prekey bundle.
@param transaction A `YapDatabaseReadWriteTransaction`.
@param pubKey The hex encoded public key of the contact.
*/

@ -39,7 +39,7 @@
return [self generateAndStorePreKeyForContact:pubKey];
}
// Load the pre key otherwise just generate a new one
// Load the prekey otherwise just generate a new one
@try {
return [self throws_loadPreKey:preKeyId];
} @catch (NSException *exception) {
@ -71,7 +71,7 @@
ECKeyPair *_Nullable keyPair = self.identityManager.identityKeyPair;
OWSAssertDebug(keyPair);
SignedPreKeyRecord *_Nullable signedPreKey = [self currentSignedPreKey];
SignedPreKeyRecord *_Nullable signedPreKey = self.currentSignedPreKey;
if (!signedPreKey) {
OWSFailDebug(@"Signed prekey is null");
}

@ -11,7 +11,7 @@
PreKeyBundle *bundle = [OWSPrimaryStorage.sharedManager generatePreKeyBundleForContact:recipient.recipientId];
SSKProtoPrekeyBundleMessageBuilder *preKeyBuilder = [SSKProtoPrekeyBundleMessage builderFromPreKeyBundle:bundle];
// Build the pre key bundle message
// Build the prekey bundle message
NSError *error;
SSKProtoPrekeyBundleMessage *_Nullable message = [preKeyBuilder buildAndReturnError:&error];
if (error || !message) {

@ -51,10 +51,10 @@ NS_ASSUME_NONNULL_BEGIN
- (SSKProtoContentBuilder *)contentBuilder:(SignalRecipient *)recipient {
SSKProtoContentBuilder *builder = [super contentBuilder:recipient];
PreKeyBundle *bundle = [[OWSPrimaryStorage sharedManager] generatePreKeyBundleForContact:recipient.recipientId];
PreKeyBundle *bundle = [OWSPrimaryStorage.sharedManager generatePreKeyBundleForContact:recipient.recipientId];
SSKProtoPrekeyBundleMessageBuilder *preKeyBuilder = [SSKProtoPrekeyBundleMessage builderFromPreKeyBundle:bundle];
// Build the pre key bundle message
// Build the prekey bundle message
NSError *error;
SSKProtoPrekeyBundleMessage *_Nullable message = [preKeyBuilder buildAndReturnError:&error];
if (error || !message) {

@ -1648,7 +1648,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
if (exception) {
@throw exception;
}
*============
* ================
*/
if (!bundle) {

@ -81,7 +81,7 @@ NS_ASSUME_NONNULL_BEGIN
- (nullable PreKeyBundle *)preKeyBundleForKey:(NSString *)key inCollection:(NSString *)collection
{
return [self objectForKey:key inCollection:collection ofExpectedType:[PreKeyBundle class]];
return [self objectForKey:key inCollection:collection ofExpectedType:PreKeyBundle.class];
}
- (nullable SignedPreKeyRecord *)signedPreKeyRecordForKey:(NSString *)key inCollection:(NSString *)collection

@ -72,7 +72,7 @@ NS_ASSUME_NONNULL_BEGIN
- (nullable PreKeyBundle *)preKeyBundleForKey:(NSString *)key inCollection:(NSString *)collection
{
return [self objectForKey:key inCollection:collection ofExpectedType:[PreKeyBundle class]];
return [self objectForKey:key inCollection:collection ofExpectedType:PreKeyBundle.class];
}
- (nullable SignedPreKeyRecord *)signedPreKeyRecordForKey:(NSString *)key inCollection:(NSString *)collection

Loading…
Cancel
Save