Skip to content

Commit

Permalink
Allow users to send messages to contacts marked as pending approval
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisballinger committed Jan 24, 2017
1 parent 8734189 commit eb2ae3e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 23 deletions.
10 changes: 10 additions & 0 deletions ChatSecure/Classes/Model/Yap Storage/OTRXMPPBuddy.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#import "OTRXMPPBuddy.h"
#import "OTRBuddyCache.h"
@import XMPPFramework;
@import OTRAssets;

@implementation OTRXMPPBuddy
@synthesize vCardTemp = _vCardTemp;
Expand Down Expand Up @@ -59,6 +60,15 @@ - (BOOL) waitingForvCardTempFetch {
return [[OTRBuddyCache sharedInstance] waitingForvCardTempFetchForBuddy:self];
}

- (NSString *)threadName
{
NSString *threadName = [super threadName];
if (self.pendingApproval) {
threadName = [NSString stringWithFormat:@"%@ - %@", threadName, PENDING_APPROVAL_STRING()];
}
return threadName;
}

#pragma - mark Class Methods

+ (NSString *)collection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,6 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
}];
cell = approvalCell;
cell.selectionStyle = UITableViewCellSelectionStyleNone;

} else if ([thread isKindOfClass:[OTRXMPPBuddy class]] &&
((OTRXMPPBuddy*)thread).pendingApproval) {
cell = [tableView dequeueReusableCellWithIdentifier:[OTRBuddyInfoCell reuseIdentifier] forIndexPath:indexPath];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
} else {
cell = [tableView dequeueReusableCellWithIdentifier:[OTRConversationCell reuseIdentifier] forIndexPath:indexPath];
cell.selectionStyle = UITableViewCellSelectionStyleDefault;
Expand Down Expand Up @@ -380,10 +375,9 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
{
id <OTRThreadOwner> thread = [self threadForIndexPath:indexPath];

// Bail out if it's a subscription request or pending approval
// Bail out if it's a subscription request
if ([thread isKindOfClass:[OTRXMPPBuddy class]] &&
(((OTRXMPPBuddy*)thread).hasIncomingSubscriptionRequest ||
((OTRXMPPBuddy*)thread).pendingApproval)) {
((OTRXMPPBuddy*)thread).hasIncomingSubscriptionRequest) {
return;
}

Expand Down
7 changes: 0 additions & 7 deletions ChatSecure/Classes/Views/Cells/OTRBuddyInfoCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,6 @@ - (void)setThread:(id<OTRThreadOwner>)thread

self.nameLabel.text = name;
self.identifierLabel.text = nil;

if ([thread isKindOfClass:[OTRXMPPBuddy class]]) {
if(((OTRXMPPBuddy *)thread).pendingApproval) {
NSString *pendingString = [NSString stringWithFormat:@" - %@",PENDING_APPROVAL_STRING()];
self.nameLabel.text = [self.nameLabel.text stringByAppendingString:pendingString];
}
}
}

- (void)updateConstraints
Expand Down
13 changes: 5 additions & 8 deletions ChatSecure/Classes/Views/Cells/UserInfoProfileCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,17 @@ public class UserInfoProfileCell: XLFormBaseCell {
@IBOutlet weak var displayNameLabel: UILabel!
@IBOutlet weak var avatarImageView: UIImageView!

public override func awakeFromNib() {
super.awakeFromNib()



}

public override func update() {
super.update()
guard let userInfo = rowDescriptor.value as? OTRUserInfoProfile else {
return
}
var displayName = userInfo.displayName
if let userInfo = userInfo as? OTRThreadOwner {
displayName = userInfo.threadName()
}
usernameLabel.text = userInfo.username
displayNameLabel.text = userInfo.displayName
displayNameLabel.text = displayName
avatarImageView.image = userInfo.avatarImage
avatarImageView.layer.cornerRadius = CGRectGetHeight(self.avatarImageView.frame)/2
avatarImageView.layer.masksToBounds = true
Expand Down

0 comments on commit eb2ae3e

Please sign in to comment.