Fix review remarks

This commit is contained in:
ismailgulek
2022-01-25 23:59:19 +03:00
parent 48b99d6a2a
commit 785fe6b4e0
36 changed files with 205 additions and 223 deletions
@@ -113,14 +113,14 @@
@protocol RoomDataSourceDelegate <MXKDataSourceDelegate>
/**
Called when the room's encryption trust level did updated.
Called when the room's encryption trust level did update.
@param roomDataSource room data source instance
*/
- (void)roomDataSourceDidUpdateEncryptionTrustLevel:(RoomDataSource * _Nonnull)roomDataSource;
/**
Called when a thread summary view
Called when a thread summary view is tapped.
@param roomDataSource room data source instance
*/
@@ -464,6 +464,7 @@ const CGFloat kTypingCellHeight = 24;
{
threadSummaryView = [[ThreadSummaryView alloc] initWithThread:component.thread];
threadSummaryView.delegate = self;
threadSummaryView.tag = index;
[temporaryViews addObject:threadSummaryView];
UIView *upperDecorationView = reactionsView ?: urlPreviewView;
+1 -1
View File
@@ -134,7 +134,7 @@ final class RoomCoordinator: NSObject, RoomCoordinatorProtocol {
self.selectedEventId = eventId
if self.hasStartedOnce {
self.roomViewController.highlightEvent(eventId, completion: completion)
self.roomViewController.highlightAndDisplayEvent(eventId, completion: completion)
} else {
self.start(withCompletion: completion)
}
+1 -1
View File
@@ -106,7 +106,7 @@ extern NSNotificationName const RoomGroupCallTileTappedNotification;
@param eventId Identifier of the event to be highlighted.
@param completion Completion block to be called at the end of process. Optional.
*/
- (void)highlightEvent:(NSString *)eventId completion:(nullable void (^)(void))completion;
- (void)highlightAndDisplayEvent:(NSString *)eventId completion:(nullable void (^)(void))completion;
/**
Creates and returns a new `RoomViewController` object.
+22 -64
View File
@@ -93,7 +93,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
@interface RoomViewController () <UISearchBarDelegate, UIGestureRecognizerDelegate, UIScrollViewAccessibilityDelegate, RoomTitleViewTapGestureDelegate, RoomParticipantsViewControllerDelegate, MXKRoomMemberDetailsViewControllerDelegate, ContactsTableViewControllerDelegate, MXServerNoticesDelegate, RoomContextualMenuViewControllerDelegate,
ReactionsMenuViewModelCoordinatorDelegate, EditHistoryCoordinatorBridgePresenterDelegate, MXKDocumentPickerPresenterDelegate, EmojiPickerCoordinatorBridgePresenterDelegate,
ReactionHistoryCoordinatorBridgePresenterDelegate, CameraPresenterDelegate, MediaPickerCoordinatorBridgePresenterDelegate,
RoomDataSourceDelegate, RoomCreationModalCoordinatorBridgePresenterDelegate, RoomInfoCoordinatorBridgePresenterDelegate, DialpadViewControllerDelegate, RemoveJitsiWidgetViewDelegate, VoiceMessageControllerDelegate, SpaceDetailPresenterDelegate, UserSuggestionCoordinatorBridgeDelegate, RoomCoordinatorBridgePresenterDelegate, ThreadsCoordinatorBridgePresenterDelegate>
RoomDataSourceDelegate, RoomCreationModalCoordinatorBridgePresenterDelegate, RoomInfoCoordinatorBridgePresenterDelegate, DialpadViewControllerDelegate, RemoveJitsiWidgetViewDelegate, VoiceMessageControllerDelegate, SpaceDetailPresenterDelegate, UserSuggestionCoordinatorBridgeDelegate, ThreadsCoordinatorBridgePresenterDelegate>
{
// The preview header
@@ -197,9 +197,8 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
@property (nonatomic, strong) RoomMessageURLParser *roomMessageURLParser;
@property (nonatomic, strong) RoomCreationModalCoordinatorBridgePresenter *roomCreationModalCoordinatorBridgePresenter;
@property (nonatomic, strong) RoomInfoCoordinatorBridgePresenter *roomInfoCoordinatorBridgePresenter;
@property (nonatomic, strong) RoomCoordinatorBridgePresenter *threadBridgePresenter;
@property (nonatomic, strong) CustomSizedPresentationController *customSizedPresentationController;
@property (nonatomic, strong) ThreadsCoordinatorBridgePresenter *threadsCoordinatorBridgePresenter;
@property (nonatomic, strong) ThreadsCoordinatorBridgePresenter *threadsBridgePresenter;
@property (nonatomic, getter=isActivitiesViewExpanded) BOOL activitiesViewExpanded;
@property (nonatomic, getter=isScrollToBottomHidden) BOOL scrollToBottomHidden;
@property (nonatomic, getter=isMissedDiscussionsBadgeHidden) BOOL missedDiscussionsBadgeHidden;
@@ -4341,10 +4340,11 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
- (IBAction)onThreadListTapped:(id)sender
{
self.threadsCoordinatorBridgePresenter = [[ThreadsCoordinatorBridgePresenter alloc] initWithSession:self.mainSession
roomId:self.roomDataSource.roomId];
self.threadsCoordinatorBridgePresenter.delegate = self;
[self.threadsCoordinatorBridgePresenter pushFrom:self.navigationController animated:YES];
self.threadsBridgePresenter = [[ThreadsCoordinatorBridgePresenter alloc] initWithSession:self.mainSession
roomId:self.roomDataSource.roomId
threadId:nil];
self.threadsBridgePresenter.delegate = self;
[self.threadsBridgePresenter pushFrom:self.navigationController animated:YES];
}
- (IBAction)onIntegrationsPressed:(id)sender
@@ -4473,7 +4473,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
[super scrollViewWillBeginDragging:scrollView];
}
// if data source is highlighting an event, dismiss the highlight when user dragges the table view
// if data source is highlighting an event, dismiss the highlight when user drags the table view
if (customizedRoomDataSource.highlightedEventId)
{
NSInteger row = [self.roomDataSource indexOfCellDataWithEventId:customizedRoomDataSource.highlightedEventId];
@@ -6352,25 +6352,20 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
- (void)openThreadWithId:(NSString *)threadId
{
if (self.threadBridgePresenter)
if (self.threadsBridgePresenter)
{
[self.threadBridgePresenter dismissWithAnimated:YES completion:nil];
self.threadBridgePresenter = nil;
[self.threadsBridgePresenter dismissWithAnimated:YES completion:nil];
self.threadsBridgePresenter = nil;
}
RoomDisplayConfiguration *configuration = RoomDisplayConfiguration.forThreads;
RoomCoordinatorBridgePresenterParameters *parameters = [[RoomCoordinatorBridgePresenterParameters alloc] initWithSession:self.mainSession
roomId:self.roomDataSource.roomId
eventId:nil
threadId:threadId
displayConfiguration:configuration
previewData:nil];
self.threadBridgePresenter = [[RoomCoordinatorBridgePresenter alloc] initWithParameters:parameters];
self.threadBridgePresenter.delegate = self;
[self.threadBridgePresenter pushFrom:self.navigationController animated:YES];
self.threadsBridgePresenter = [[ThreadsCoordinatorBridgePresenter alloc] initWithSession:self.mainSession
roomId:self.roomDataSource.roomId
threadId:threadId];
self.threadsBridgePresenter.delegate = self;
[self.threadsBridgePresenter pushFrom:self.navigationController animated:YES];
}
- (void)highlightEvent:(NSString *)eventId completion:(void (^)(void))completion
- (void)highlightAndDisplayEvent:(NSString *)eventId completion:(void (^)(void))completion
{
NSInteger row = [self.roomDataSource indexOfCellDataWithEventId:eventId];
if (row == NSNotFound)
@@ -6816,66 +6811,29 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
[self mention:member];
}
#pragma mark - RoomCoordinatorBridgePresenterDelegate
- (void)roomCoordinatorBridgePresenterDidLeaveRoom:(RoomCoordinatorBridgePresenter *)bridgePresenter
{
}
- (void)roomCoordinatorBridgePresenterDidCancelRoomPreview:(RoomCoordinatorBridgePresenter *)bridgePresenter
{
}
- (void)roomCoordinatorBridgePresenter:(RoomCoordinatorBridgePresenter *)bridgePresenter
didSelectRoomWithId:(NSString *)roomId
eventId:(NSString*)eventId
{
if (bridgePresenter == self.threadBridgePresenter && [roomId isEqualToString:self.roomDataSource.roomId] && eventId)
{
// thread view wants to highlight an event in the timeline
// dismiss thread view first
MXWeakify(self);
[self.threadBridgePresenter dismissWithAnimated:YES completion:^{
MXStrongifyAndReturnIfNil(self);
[self highlightEvent:eventId completion:nil];
}];
}
}
- (void)roomCoordinatorBridgePresenterDidDismissInteractively:(RoomCoordinatorBridgePresenter *)bridgePresenter
{
if (bridgePresenter == self.threadBridgePresenter)
{
self.threadBridgePresenter = nil;
}
}
#pragma mark - ThreadsCoordinatorBridgePresenterDelegate
- (void)threadsCoordinatorBridgePresenterDelegateDidComplete:(ThreadsCoordinatorBridgePresenter *)coordinatorBridgePresenter
{
self.threadsCoordinatorBridgePresenter = nil;
self.threadsBridgePresenter = nil;
}
- (void)threadsCoordinatorBridgePresenterDelegateDidSelect:(ThreadsCoordinatorBridgePresenter *)coordinatorBridgePresenter roomId:(NSString *)roomId eventId:(NSString *)eventId
{
MXWeakify(self);
[self.threadsCoordinatorBridgePresenter dismissWithAnimated:YES completion:^{
[self.threadsBridgePresenter dismissWithAnimated:YES completion:^{
MXStrongifyAndReturnIfNil(self);
if (eventId)
{
[self highlightEvent:eventId completion:nil];
[self highlightAndDisplayEvent:eventId completion:nil];
}
}];
}
- (void)threadsCoordinatorBridgePresenterDidDismissInteractively:(ThreadsCoordinatorBridgePresenter *)coordinatorBridgePresenter
{
self.threadsCoordinatorBridgePresenter = nil;
self.threadsBridgePresenter = nil;
}
@end
@@ -16,8 +16,8 @@
import Foundation
struct ThreadSummaryViewModel {
var numberOfReplies: Int
var lastMessageSenderAvatar: AvatarViewDataProtocol?
var lastMessageText: String?
struct ThreadSummaryModel {
let numberOfReplies: Int
let lastMessageSenderAvatar: AvatarViewDataProtocol?
let lastMessageText: String?
}
@@ -37,7 +37,7 @@ class ThreadSummaryView: UIView {
@IBOutlet private weak var lastMessageAvatarView: UserAvatarView!
@IBOutlet private weak var lastMessageContentLabel: UILabel!
private(set) var thread: MXThread!
private(set) var thread: MXThread?
private lazy var tapGestureRecognizer: UITapGestureRecognizer = {
return UITapGestureRecognizer(target: self, action: #selector(tapped(_:)))
@@ -57,7 +57,7 @@ class ThreadSummaryView: UIView {
configure()
}
static func contentViewHeight(forThread thread: MXThread, fitting maxWidth: CGFloat) -> CGFloat {
static func contentViewHeight(forThread thread: MXThread?, fitting maxWidth: CGFloat) -> CGFloat {
return Constants.viewHeight
}
@@ -66,7 +66,7 @@ class ThreadSummaryView: UIView {
loadNibContent()
}
@nonobjc func configure(withViewModel viewModel: ThreadSummaryViewModel) {
@nonobjc func configure(withViewModel viewModel: ThreadSummaryModel) {
numberOfRepliesLabel.text = String(viewModel.numberOfReplies)
if let avatar = viewModel.lastMessageSenderAvatar {
lastMessageAvatarView.fill(with: avatar)
@@ -105,7 +105,7 @@ class ThreadSummaryView: UIView {
let formatterError = UnsafeMutablePointer<MXKEventFormatterError>.allocate(capacity: 1)
let lastMessageText = eventFormatter.string(from: lastMessage, with: roomState, error: formatterError)
let viewModel = ThreadSummaryViewModel(numberOfReplies: thread.numberOfReplies,
let viewModel = ThreadSummaryModel(numberOfReplies: thread.numberOfReplies,
lastMessageSenderAvatar: avatarViewData,
lastMessageText: lastMessageText)
self.configure(withViewModel: viewModel)
@@ -121,8 +121,6 @@ class ThreadSummaryView: UIView {
}
}
// extension ThreadSummaryView: NibLoadable {}
extension ThreadSummaryView: NibOwnerLoadable {}
extension ThreadSummaryView: Themable {
@@ -16,12 +16,12 @@
import Foundation
struct ThreadRoomTitleViewModel {
var roomAvatar: AvatarViewDataProtocol?
var roomEncryptionBadge: UIImage?
var roomDisplayName: String?
struct ThreadRoomTitleModel {
let roomAvatar: AvatarViewDataProtocol?
let roomEncryptionBadge: UIImage?
let roomDisplayName: String?
static let empty = ThreadRoomTitleViewModel(roomAvatar: nil,
roomEncryptionBadge: nil,
roomDisplayName: nil)
static let empty = ThreadRoomTitleModel(roomAvatar: nil,
roomEncryptionBadge: nil,
roomDisplayName: nil)
}
@@ -44,7 +44,7 @@ class ThreadRoomTitleView: RoomTitleView {
// MARK: - Methods
func configure(withViewModel viewModel: ThreadRoomTitleViewModel) {
func configure(withViewModel viewModel: ThreadRoomTitleModel) {
if let avatarViewData = viewModel.roomAvatar {
roomAvatarView.fill(with: avatarViewData)
} else {
@@ -87,9 +87,9 @@ class ThreadRoomTitleView: RoomTitleView {
encrpytionBadge = nil
}
let viewModel = ThreadRoomTitleViewModel(roomAvatar: avatarViewData,
roomEncryptionBadge: encrpytionBadge,
roomDisplayName: room.displayName)
let viewModel = ThreadRoomTitleModel(roomAvatar: avatarViewData,
roomEncryptionBadge: encrpytionBadge,
roomDisplayName: room.displayName)
configure(withViewModel: viewModel)
}