mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Use cached group details when rendering blocklist
This commit is contained in:
parent
1f15ba6dc5
commit
0f9b0936df
8 changed files with 110 additions and 8 deletions
|
@ -435,6 +435,7 @@
|
||||||
4C13C9F620E57BA30089A98B /* ColorPickerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C13C9F520E57BA30089A98B /* ColorPickerViewController.swift */; };
|
4C13C9F620E57BA30089A98B /* ColorPickerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C13C9F520E57BA30089A98B /* ColorPickerViewController.swift */; };
|
||||||
4C20B2B720CA0034001BAC90 /* ThreadViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4542DF51208B82E9007B4E76 /* ThreadViewModel.swift */; };
|
4C20B2B720CA0034001BAC90 /* ThreadViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4542DF51208B82E9007B4E76 /* ThreadViewModel.swift */; };
|
||||||
4C20B2B920CA10DE001BAC90 /* ConversationSearchViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C20B2B820CA10DE001BAC90 /* ConversationSearchViewController.swift */; };
|
4C20B2B920CA10DE001BAC90 /* ConversationSearchViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C20B2B820CA10DE001BAC90 /* ConversationSearchViewController.swift */; };
|
||||||
|
4C2F454F214C00E1004871FF /* AvatarTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C2F454E214C00E1004871FF /* AvatarTableViewCell.swift */; };
|
||||||
4C3EF7FD2107DDEE0007EBF7 /* ParamParserTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C3EF7FC2107DDEE0007EBF7 /* ParamParserTest.swift */; };
|
4C3EF7FD2107DDEE0007EBF7 /* ParamParserTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C3EF7FC2107DDEE0007EBF7 /* ParamParserTest.swift */; };
|
||||||
4C3EF802210918740007EBF7 /* SSKProtoEnvelopeTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C3EF801210918740007EBF7 /* SSKProtoEnvelopeTest.swift */; };
|
4C3EF802210918740007EBF7 /* SSKProtoEnvelopeTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C3EF801210918740007EBF7 /* SSKProtoEnvelopeTest.swift */; };
|
||||||
4C4AEC4520EC343B0020E72B /* DismissableTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C4AEC4420EC343B0020E72B /* DismissableTextField.swift */; };
|
4C4AEC4520EC343B0020E72B /* DismissableTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C4AEC4420EC343B0020E72B /* DismissableTextField.swift */; };
|
||||||
|
@ -1125,6 +1126,7 @@
|
||||||
4C11AA4F20FD59C700351FBD /* MessageStatusView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageStatusView.swift; sourceTree = "<group>"; };
|
4C11AA4F20FD59C700351FBD /* MessageStatusView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageStatusView.swift; sourceTree = "<group>"; };
|
||||||
4C13C9F520E57BA30089A98B /* ColorPickerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorPickerViewController.swift; sourceTree = "<group>"; };
|
4C13C9F520E57BA30089A98B /* ColorPickerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorPickerViewController.swift; sourceTree = "<group>"; };
|
||||||
4C20B2B820CA10DE001BAC90 /* ConversationSearchViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConversationSearchViewController.swift; sourceTree = "<group>"; };
|
4C20B2B820CA10DE001BAC90 /* ConversationSearchViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConversationSearchViewController.swift; sourceTree = "<group>"; };
|
||||||
|
4C2F454E214C00E1004871FF /* AvatarTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AvatarTableViewCell.swift; sourceTree = "<group>"; };
|
||||||
4C3EF7FC2107DDEE0007EBF7 /* ParamParserTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParamParserTest.swift; sourceTree = "<group>"; };
|
4C3EF7FC2107DDEE0007EBF7 /* ParamParserTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParamParserTest.swift; sourceTree = "<group>"; };
|
||||||
4C3EF801210918740007EBF7 /* SSKProtoEnvelopeTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SSKProtoEnvelopeTest.swift; sourceTree = "<group>"; };
|
4C3EF801210918740007EBF7 /* SSKProtoEnvelopeTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SSKProtoEnvelopeTest.swift; sourceTree = "<group>"; };
|
||||||
4C4AEC4420EC343B0020E72B /* DismissableTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DismissableTextField.swift; sourceTree = "<group>"; };
|
4C4AEC4420EC343B0020E72B /* DismissableTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DismissableTextField.swift; sourceTree = "<group>"; };
|
||||||
|
@ -2233,6 +2235,7 @@
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
452EA09D1EA7ABE00078744B /* AttachmentPointerView.swift */,
|
452EA09D1EA7ABE00078744B /* AttachmentPointerView.swift */,
|
||||||
|
4C2F454E214C00E1004871FF /* AvatarTableViewCell.swift */,
|
||||||
34E3E5671EC4B19400495BAC /* AudioProgressView.swift */,
|
34E3E5671EC4B19400495BAC /* AudioProgressView.swift */,
|
||||||
451764291DE939FD00EDB8B9 /* ContactCell.swift */,
|
451764291DE939FD00EDB8B9 /* ContactCell.swift */,
|
||||||
4523149F1F7E9E18003A428C /* DirectionalPanGestureRecognizer.swift */,
|
4523149F1F7E9E18003A428C /* DirectionalPanGestureRecognizer.swift */,
|
||||||
|
@ -3327,6 +3330,7 @@
|
||||||
451166C01FD86B98000739BA /* AccountManager.swift in Sources */,
|
451166C01FD86B98000739BA /* AccountManager.swift in Sources */,
|
||||||
34D2CCD220618B3000CB1A14 /* OWSBackupLazyRestoreJob.swift in Sources */,
|
34D2CCD220618B3000CB1A14 /* OWSBackupLazyRestoreJob.swift in Sources */,
|
||||||
3430FE181F7751D4000EC51B /* GiphyAPI.swift in Sources */,
|
3430FE181F7751D4000EC51B /* GiphyAPI.swift in Sources */,
|
||||||
|
4C2F454F214C00E1004871FF /* AvatarTableViewCell.swift in Sources */,
|
||||||
34A55F3720485465002CC6DE /* OWS2FARegistrationViewController.m in Sources */,
|
34A55F3720485465002CC6DE /* OWS2FARegistrationViewController.m in Sources */,
|
||||||
340FC8AD204DAC8D007AEB0F /* OWSLinkedDevicesTableViewController.m in Sources */,
|
340FC8AD204DAC8D007AEB0F /* OWSLinkedDevicesTableViewController.m in Sources */,
|
||||||
340FC8AA204DAC8D007AEB0F /* NotificationSettingsViewController.m in Sources */,
|
340FC8AA204DAC8D007AEB0F /* NotificationSettingsViewController.m in Sources */,
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#import "ContactsViewHelper.h"
|
#import "ContactsViewHelper.h"
|
||||||
#import "OWSTableViewController.h"
|
#import "OWSTableViewController.h"
|
||||||
#import "PhoneNumber.h"
|
#import "PhoneNumber.h"
|
||||||
|
#import "Signal-Swift.h"
|
||||||
#import "UIFont+OWS.h"
|
#import "UIFont+OWS.h"
|
||||||
#import "UIView+OWS.h"
|
#import "UIView+OWS.h"
|
||||||
#import <SignalMessaging/Environment.h>
|
#import <SignalMessaging/Environment.h>
|
||||||
|
@ -115,20 +116,25 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
blockedGroupsSection.headerTitle = NSLocalizedString(
|
blockedGroupsSection.headerTitle = NSLocalizedString(
|
||||||
@"BLOCK_LIST_BLOCKED_GROUPS_SECTION", @"Section header for groups that have been blocked");
|
@"BLOCK_LIST_BLOCKED_GROUPS_SECTION", @"Section header for groups that have been blocked");
|
||||||
for (NSData *groupId in blockedGroupIds) {
|
for (NSData *groupId in blockedGroupIds) {
|
||||||
TSGroupThread *groupThread = [TSGroupThread getOrCreateThreadWithGroupId:groupId];
|
TSGroupModel *_Nullable cachedGroup = [self.blockingManager cachedGroupDetailsWithGroupId:groupId];
|
||||||
|
OWSAssert(cachedGroup);
|
||||||
|
UIImage *image = cachedGroup.groupImage ?: OWSGroupAvatarBuilder.defaultGroupImage;
|
||||||
|
NSString *groupName = cachedGroup.groupName ?: TSGroupThread.defaultGroupName;
|
||||||
|
|
||||||
[blockedGroupsSection addItem:[OWSTableItem
|
[blockedGroupsSection addItem:[OWSTableItem
|
||||||
itemWithCustomCellBlock:^{
|
itemWithCustomCellBlock:^{
|
||||||
ContactTableViewCell *cell = [ContactTableViewCell new];
|
OWSAvatarTableViewCell *cell = [OWSAvatarTableViewCell new];
|
||||||
[cell configureWithThread:groupThread
|
[cell configureWithImage:image
|
||||||
contactsManager:helper.contactsManager];
|
text:groupName
|
||||||
|
detailText:nil];
|
||||||
return cell;
|
return cell;
|
||||||
}
|
}
|
||||||
customRowHeight:UITableViewAutomaticDimension
|
customRowHeight:UITableViewAutomaticDimension
|
||||||
actionBlock:^{
|
actionBlock:^{
|
||||||
[BlockListUIUtils showUnblockThreadActionSheet:groupThread
|
[BlockListUIUtils showUnblockGroupActionSheet:cachedGroup
|
||||||
|
displayName:groupName
|
||||||
fromViewController:weakSelf
|
fromViewController:weakSelf
|
||||||
blockingManager:helper.blockingManager
|
blockingManager:helper.blockingManager
|
||||||
contactsManager:helper.contactsManager
|
|
||||||
completionBlock:nil];
|
completionBlock:nil];
|
||||||
}]];
|
}]];
|
||||||
}
|
}
|
||||||
|
|
72
Signal/src/views/AvatarTableViewCell.swift
Normal file
72
Signal/src/views/AvatarTableViewCell.swift
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
//
|
||||||
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
@objc(OWSAvatarTableViewCell)
|
||||||
|
public class AvatarTableViewCell: UITableViewCell {
|
||||||
|
|
||||||
|
private let columns: UIStackView
|
||||||
|
private let textRows: UIStackView
|
||||||
|
private let avatarView: AvatarImageView
|
||||||
|
|
||||||
|
private let _textLabel: UILabel
|
||||||
|
override public var textLabel: UILabel? {
|
||||||
|
get {
|
||||||
|
return _textLabel
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private let _detailTextLabel: UILabel
|
||||||
|
override public var detailTextLabel: UILabel? {
|
||||||
|
get {
|
||||||
|
return _detailTextLabel
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc
|
||||||
|
public override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
|
||||||
|
self.avatarView = AvatarImageView()
|
||||||
|
avatarView.autoSetDimensions(to: CGSize(width: CGFloat(kContactCellAvatarSize), height: CGFloat(kContactCellAvatarSize)))
|
||||||
|
|
||||||
|
self._textLabel = UILabel()
|
||||||
|
self._detailTextLabel = UILabel()
|
||||||
|
|
||||||
|
self.textRows = UIStackView(arrangedSubviews: [_textLabel, _detailTextLabel])
|
||||||
|
textRows.axis = .vertical
|
||||||
|
|
||||||
|
self.columns = UIStackView(arrangedSubviews: [avatarView, textRows])
|
||||||
|
columns.axis = .horizontal
|
||||||
|
columns.spacing = CGFloat(kContactCellAvatarTextMargin)
|
||||||
|
|
||||||
|
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
||||||
|
|
||||||
|
self.contentView.addSubview(columns)
|
||||||
|
columns.autoPinEdgesToSuperviewMargins()
|
||||||
|
|
||||||
|
OWSTableItem.configureCell(self)
|
||||||
|
}
|
||||||
|
|
||||||
|
required public init?(coder aDecoder: NSCoder) {
|
||||||
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc
|
||||||
|
public func configure(image: UIImage?, text: String?, detailText: String?) {
|
||||||
|
self.avatarView.image = image
|
||||||
|
self.textLabel?.text = text
|
||||||
|
self.detailTextLabel?.text = detailText
|
||||||
|
|
||||||
|
OWSTableItem.configureCell(self)
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc
|
||||||
|
public override func prepareForReuse() {
|
||||||
|
super.prepareForReuse()
|
||||||
|
|
||||||
|
self.avatarView.image = nil
|
||||||
|
self.textLabel?.text = nil
|
||||||
|
self.detailTextLabel?.text = nil
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,6 +11,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
@class OWSContactsManager;
|
@class OWSContactsManager;
|
||||||
@class OWSMessageSender;
|
@class OWSMessageSender;
|
||||||
@class SignalAccount;
|
@class SignalAccount;
|
||||||
|
@class TSGroupModel;
|
||||||
@class TSThread;
|
@class TSThread;
|
||||||
|
|
||||||
typedef void (^BlockActionCompletionBlock)(BOOL isBlocked);
|
typedef void (^BlockActionCompletionBlock)(BOOL isBlocked);
|
||||||
|
@ -60,6 +61,12 @@ typedef void (^BlockActionCompletionBlock)(BOOL isBlocked);
|
||||||
contactsManager:(OWSContactsManager *)contactsManager
|
contactsManager:(OWSContactsManager *)contactsManager
|
||||||
completionBlock:(nullable BlockActionCompletionBlock)completionBlock;
|
completionBlock:(nullable BlockActionCompletionBlock)completionBlock;
|
||||||
|
|
||||||
|
+ (void)showUnblockGroupActionSheet:(TSGroupModel *)groupModel
|
||||||
|
displayName:(NSString *)displayName
|
||||||
|
fromViewController:(UIViewController *)fromViewController
|
||||||
|
blockingManager:(OWSBlockingManager *)blockingManager
|
||||||
|
completionBlock:(nullable BlockActionCompletionBlock)completionBlock;
|
||||||
|
|
||||||
#pragma mark - UI Utils
|
#pragma mark - UI Utils
|
||||||
|
|
||||||
+ (NSString *)formatDisplayNameForAlertTitle:(NSString *)displayName;
|
+ (NSString *)formatDisplayNameForAlertTitle:(NSString *)displayName;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
#import "OWSAvatarBuilder.h"
|
#import "OWSAvatarBuilder.h"
|
||||||
|
@ -11,6 +11,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
@interface OWSGroupAvatarBuilder : OWSAvatarBuilder
|
@interface OWSGroupAvatarBuilder : OWSAvatarBuilder
|
||||||
|
|
||||||
- (instancetype)initWithThread:(TSGroupThread *)thread;
|
- (instancetype)initWithThread:(TSGroupThread *)thread;
|
||||||
|
+ (UIImage *)defaultGroupImage;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,11 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
}
|
}
|
||||||
|
|
||||||
- (UIImage *)buildDefaultImage
|
- (UIImage *)buildDefaultImage
|
||||||
|
{
|
||||||
|
return self.class.defaultGroupImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (UIImage *)defaultGroupImage
|
||||||
{
|
{
|
||||||
static UIImage *defaultGroupImage;
|
static UIImage *defaultGroupImage;
|
||||||
static dispatch_once_t onceToken;
|
static dispatch_once_t onceToken;
|
||||||
|
|
|
@ -29,6 +29,8 @@ extern NSString *const TSGroupThread_NotificationKey_UniqueId;
|
||||||
|
|
||||||
+ (NSString *)threadIdFromGroupId:(NSData *)groupId;
|
+ (NSString *)threadIdFromGroupId:(NSData *)groupId;
|
||||||
|
|
||||||
|
+ (NSString *)defaultGroupName;
|
||||||
|
|
||||||
// all group threads containing recipient as a member
|
// all group threads containing recipient as a member
|
||||||
+ (NSArray<TSGroupThread *> *)groupThreadsWithRecipientId:(NSString *)recipientId
|
+ (NSArray<TSGroupThread *> *)groupThreadsWithRecipientId:(NSString *)recipientId
|
||||||
transaction:(YapDatabaseReadWriteTransaction *)transaction;
|
transaction:(YapDatabaseReadWriteTransaction *)transaction;
|
||||||
|
|
|
@ -175,7 +175,12 @@ NSString *const TSGroupThread_NotificationKey_UniqueId = @"TSGroupThread_Notific
|
||||||
|
|
||||||
- (NSString *)name
|
- (NSString *)name
|
||||||
{
|
{
|
||||||
return self.groupModel.groupName ? self.groupModel.groupName : NSLocalizedString(@"NEW_GROUP_DEFAULT_TITLE", @"");
|
return self.groupModel.groupName ?: self.class.defaultGroupName;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSString *)defaultGroupName
|
||||||
|
{
|
||||||
|
return NSLocalizedString(@"NEW_GROUP_DEFAULT_TITLE", @"");
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)leaveGroupWithSneakyTransaction
|
- (void)leaveGroupWithSneakyTransaction
|
||||||
|
|
Loading…
Reference in a new issue