Skip to content
This repository has been archived by the owner on Dec 12, 2022. It is now read-only.

Commit

Permalink
Render sticker events in the timeline
Browse files Browse the repository at this point in the history
- Remove the stickers from the attachments viewer and the files tab

element-hq/element-ios#1819
  • Loading branch information
giomfo committed Apr 11, 2018
1 parent 3ae65d9 commit 9872680
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 4 additions & 1 deletion MatrixKit/Controllers/MXKRoomViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -2040,6 +2040,7 @@ - (void)triggerAttachmentBackPagination:(NSString*)eventId
if (attachmentsViewer)
{
// Check whether some older attachments have been added.
// Note: the stickers are excluded from the attachments list returned by the room datasource.
BOOL isDone = NO;
NSArray *attachmentsWithThumbnail = self.roomDataSource.attachmentsWithThumbnail;
if (attachmentsWithThumbnail.count)
Expand Down Expand Up @@ -3552,8 +3553,10 @@ - (void)showAttachmentInCell:(UITableViewCell*)cell

if (bubbleData.isAttachmentWithThumbnail)
{
if (selectedAttachment.eventSentState == MXEventSentStateSent)
// The attachments viewer is opened only on a valid attachment. It does not display the stickers.
if (selectedAttachment.eventSentState == MXEventSentStateSent && selectedAttachment.type != MXKAttachmentTypeSticker)
{
// Note: the stickers are presently excluded from the attachments list returned by the room dataSource.
NSArray *attachmentsWithThumbnail = self.roomDataSource.attachmentsWithThumbnail;

// Present an attachment viewer
Expand Down
4 changes: 3 additions & 1 deletion MatrixKit/Models/Room/MXKRoomDataSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ extern NSString *const kMXKRoomDataSourceTimelineErrorErrorKey;

/**
The list of the attachments with thumbnail in the current available bubbles (MXKAttachment instances).
Note: the stickers are excluded from the returned list.
*/
@property (nonatomic, readonly) NSArray *attachmentsWithThumbnail;

Expand Down Expand Up @@ -209,7 +210,8 @@ extern NSString *const kMXKRoomDataSourceTimelineErrorErrorKey;
@property (nonatomic) NSUInteger paginationLimitAroundInitialEvent;

/**
Tell whether only the events with a url key in their content must be handled. NO by default.
Tell whether only the message events with an url key in their content must be handled. NO by default.
Note: The stickers are not retained by this filter.
*/
@property (nonatomic) BOOL filterMessagesWithURL;

Expand Down
4 changes: 2 additions & 2 deletions MatrixKit/Models/Room/MXKRoomDataSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ - (NSArray *)attachmentsWithThumbnail
{
for (id<MXKRoomBubbleCellDataStoring> bubbleData in bubbles)
{
if (bubbleData.isAttachmentWithThumbnail)
if (bubbleData.isAttachmentWithThumbnail && bubbleData.attachment.type != MXKAttachmentTypeSticker)
{
[attachments addObject:bubbleData.attachment];
}
Expand Down Expand Up @@ -994,7 +994,7 @@ - (void)paginate:(NSUInteger)numItems direction:(MXTimelineDirection)direction o
}

// Define a new listener for this pagination
paginationListener = [_timeline listenToEventsOfTypes:[MXKAppSettings standardAppSettings].allEventTypesForMessages onEvent:^(MXEvent *event, MXTimelineDirection direction2, MXRoomState *roomState) {
paginationListener = [_timeline listenToEventsOfTypes:(_filterMessagesWithURL ? @[kMXEventTypeStringRoomMessage] : [MXKAppSettings standardAppSettings].allEventTypesForMessages) onEvent:^(MXEvent *event, MXTimelineDirection direction2, MXRoomState *roomState) {

if (direction2 == direction)
{
Expand Down

0 comments on commit 9872680

Please sign in to comment.