Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read receipts details #1341

Merged
merged 14 commits into from
Jun 30, 2017
Merged

Conversation

aramsargsyan
Copy link

No description provided.


@interface ReadReceiptsViewController : UIViewController

+ (void)openInViewController:(UIViewController *)viewController withRestClient:(MXRestClient *)restClient withRoomMembers:(NSArray <MXRoomMember *> *)roomMembers placeholders:(NSArray <UIImage *> *)placeholders receiptDescriptions:(NSArray <NSString *> *)receiptDescriptions;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

withRestClient and withRoomMembers

*/

#import <UIKit/UIKit.h>
#import <MatrixKit/MatrixKit.h>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to use forward declaration rather than import everything

[self configureViews];
[self configureReceiptsTableView];
[self addOverlayViewGesture];
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest you to put code from this functions into viewDidLoad and separate code with comments. These functions are really short and it looks like an overhead to create function for 2 lines of code.

Copy link

@morozkin morozkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feedback

@@ -19,6 +19,6 @@

@interface ReadReceiptsViewController : UIViewController

+ (void)openInViewController:(UIViewController *)viewController withRestClient:(MXRestClient *)restClient withRoomMembers:(NSArray <MXRoomMember *> *)roomMembers placeholders:(NSArray <UIImage *> *)placeholders receiptDescriptions:(NSArray <NSString *> *)receiptDescriptions;
+ (void)openInViewController:(UIViewController *)viewController withRestClient:(MXRestClient *)restClient session:(MXSession *)session withRoomMembers:(NSArray <MXRoomMember *> *)roomMembers placeholders:(NSArray <UIImage *> *)placeholders receipts:(NSArray <MXReceiptData *> *)receipts;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer split this operation in 2:

  • one to create and return a new ReadReceiptsViewController object:
    + (instancetype)readReceiptsViewControllerBasedOnReceiptSendersContainer:(MXKReceiptSendersContainer*)receiptSendersContainer andSession:(MXSession *)session;

Note: the REST client will be deduced from the provided session. The receiptSendersContainer instance will provide all the other inputs.

  • another to handle its display: - (void)showInViewController:(UIViewController*)viewController;

@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please increase the margin of the container view with its superview

NSString *avatarUrl = self.roomMembers[indexPath.row].avatarUrl;
if (self.restClient && avatarUrl)
{
CGFloat side = CGRectGetWidth(cell.imageView.frame);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use cell. avatarImageView instead of cell.imageView, shouldn't you?

@@ -148,7 +149,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
// Some vertical whitespaces are added in message text view (see RoomBubbleCellData class) to insert correctly multiple receipts.
bubbleCell.bubbleOverlayContainer.backgroundColor = [UIColor clearColor];
bubbleCell.bubbleOverlayContainer.alpha = 1;
bubbleCell.bubbleOverlayContainer.userInteractionEnabled = NO;
bubbleCell.bubbleOverlayContainer.userInteractionEnabled = YES;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, I agree we have to enable the user interaction here on bubble overlay to catch the tap on RR container.
Unfortunately this change will break the message selection in the room history for the bubbles with RR. Don't worry about this, I will take this in charge.

@@ -17,6 +17,7 @@

#import "RoomDataSource.h"

#import "AppDelegate.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need to import AppDelegate here?

#import <UIKit/UIKit.h>
#import <MatrixKit/MatrixKit.h>

@interface ReadReceiptsViewController : UIViewController
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please inherit of MXKViewController instead of UIViewController


@interface ReadReceiptsViewController : UIViewController

+ (void)openInViewController:(UIViewController *)viewController withRestClient:(MXRestClient *)restClient session:(MXSession *)session withRoomMembers:(NSArray <MXRoomMember *> *)roomMembers placeholders:(NSArray <UIImage *> *)placeholders receipts:(NSArray <MXReceiptData *> *)receipts;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reduce the number of parameters by passing directly the MXKReceiptSendersContainer instance

- (void)configureViews
{
self.containerView.layer.cornerRadius = 20;
self.titleLabel.text = @"Read Receipts List";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Define a new key-value in Vector.strings to handle translation of this title.
Then use the macro:
NSLocalizedStringFromTable(@"xxx", @"Vector", nil), where xxx is your key.

if (indexPath.row < self.receipts.count)
{
NSString *receiptDescription = [(MXKEventFormatter*)self.session.roomSummaryUpdateDelegate dateStringFromTimestamp:self.receipts[indexPath.row].ts withTime:YES];
cell.receiptDescriptionLabel.text = receiptDescription;
Copy link
Member

@giomfo giomfo Jun 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may use attributed string to include the prefix "Read:" in this description.
(see https://github.com/vector-im/riot-ios/blob/master/Riot/Model/Contact/ContactsDataSource.m#L658 for an example of NSMutableAttributedString use)

Copy link
Member

@giomfo giomfo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just few remarks
Please sign off

@@ -2405,7 +2414,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please find the reason of this change on shellScript. Which pod version are you using? FYI we use 1.2.1.
Discard this change from your PR if this is simple for you. Don't waste time on this, I can handle it on my side.


#pragma mark - Public

+ (void)openInViewController:(UIViewController *)viewController fromContainer:(MXKReceiptSendersContainer *)receiptSendersContainer withsession:(MXSession *)session
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo withSession instead of withsession

}
if (indexPath.row < self.receipts.count)
{
NSString *receiptReadText = [NSBundle mxk_localizedStringForKey:@"receipt_status_read"];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use NSLocalizedStringFromTable(@"receipt_status_read", @"Vector", nil) when you will have moved the key-value receipt_status_read=xxx in Vector.strings

{
NSString *receiptReadText = [NSBundle mxk_localizedStringForKey:@"receipt_status_read"];
NSString *receiptTimeText = [(MXKEventFormatter*)self.session.roomSummaryUpdateDelegate dateStringFromTimestamp:self.receipts[indexPath.row].ts withTime:YES];
cell.receiptDescriptionLabel.text = receiptTimeText;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this line, you don't have to set cell.receiptDescriptionLabel.text.

@giomfo giomfo merged commit 3fac2a0 into element-hq:develop Jun 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants