Skip to content

Commit 3a09e01

Browse files
Merge pull request #6058 from vector-im/steve/6021_beacon_event
Location sharing: Support live location event in the timeline
2 parents 01e83bc + 9a8126d commit 3a09e01

File tree

5 files changed

+50
-4
lines changed

5 files changed

+50
-4
lines changed

Riot/Modules/MatrixKit/Models/MXKAppSettings.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ -(instancetype)init
147147
kMXEventTypeStringKeyVerificationCancel,
148148
kMXEventTypeStringKeyVerificationDone,
149149
kMXEventTypeStringPollStart,
150-
kMXEventTypeStringPollStartMSC3381
150+
kMXEventTypeStringPollStartMSC3381,
151+
kMXEventTypeStringBeaconInfo,
152+
kMXEventTypeStringBeaconInfoMSC3672
151153
].mutableCopy;
152154

153155

@@ -179,7 +181,9 @@ -(instancetype)init
179181
kMXEventTypeStringKeyVerificationCancel,
180182
kMXEventTypeStringKeyVerificationDone,
181183
kMXEventTypeStringPollStart,
182-
kMXEventTypeStringPollStartMSC3381
184+
kMXEventTypeStringPollStartMSC3381,
185+
kMXEventTypeStringBeaconInfo,
186+
kMXEventTypeStringBeaconInfoMSC3672
183187
].mutableCopy;
184188

185189
lastMessageEventTypesAllowList = @[

Riot/Modules/Room/CellData/RoomBubbleCellData.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
#import "MatrixKit.h"
1818

19+
@protocol MXBeaconInfoSummaryProtocol;
20+
1921
extern NSString *const URLPreviewDidUpdateNotification;
2022

2123
// Custom tags for MXKRoomBubbleCellDataStoring.tag
@@ -33,7 +35,8 @@ typedef NS_ENUM(NSInteger, RoomBubbleCellDataTag)
3335
RoomBubbleCellDataTagGroupCall,
3436
RoomBubbleCellDataTagRoomCreationIntro,
3537
RoomBubbleCellDataTagPoll,
36-
RoomBubbleCellDataTagLocation
38+
RoomBubbleCellDataTagLocation,
39+
RoomBubbleCellDataTagLiveLocation
3740
};
3841

3942
/**
@@ -92,6 +95,8 @@ typedef NS_ENUM(NSInteger, RoomBubbleCellDataTag)
9295
*/
9396
@property(nonatomic) BOOL isKeyVerificationOperationPending;
9497

98+
@property(nonatomic, strong, readonly) id<MXBeaconInfoSummaryProtocol> beaconInfoSummary;
99+
95100
/**
96101
Index of the component which needs a sent tick displayed. -1 if none.
97102
*/

Riot/Modules/Room/CellData/RoomBubbleCellData.m

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ @interface RoomBubbleCellData()
3838
// Flags to "Show All" reactions for an event
3939
@property(nonatomic) NSMutableSet<NSString* /* eventId */> *eventsToShowAllReactions;
4040

41+
@property(nonatomic, strong, readwrite) id<MXBeaconInfoSummaryProtocol> beaconInfoSummary;
42+
4143
@end
4244

4345
@implementation RoomBubbleCellData
@@ -159,6 +161,15 @@ - (instancetype)initWithEvent:(MXEvent *)event andRoomState:(MXRoomState *)roomS
159161

160162
break;
161163
}
164+
case MXEventTypeBeaconInfo:
165+
{
166+
self.tag = RoomBubbleCellDataTagLiveLocation;
167+
self.collapsable = NO;
168+
self.collapsed = NO;
169+
170+
[self updateBeaconInfoSummaryWithEventId:event.eventId];
171+
}
172+
break;
162173
case MXEventTypeCustom:
163174
{
164175
if ([event.type isEqualToString:kWidgetMatrixEventTypeString]
@@ -210,6 +221,11 @@ - (NSUInteger)updateEvent:(NSString *)eventId withEvent:(MXEvent *)event
210221

211222
// Update any URL preview data as necessary.
212223
[self refreshURLPreviewForEventId:event.eventId];
224+
225+
if (self.tag == RoomBubbleCellDataTagLiveLocation)
226+
{
227+
[self updateBeaconInfoSummaryWithEventId:eventId];
228+
}
213229

214230
return retVal;
215231
}
@@ -279,6 +295,17 @@ - (BOOL)hasNoDisplay
279295
return NO;
280296
}
281297

298+
if (self.tag == RoomBubbleCellDataTagLiveLocation)
299+
{
300+
// If the summary does not exist don't show the cell
301+
if (!self.beaconInfoSummary)
302+
{
303+
return YES;
304+
}
305+
306+
return NO;
307+
}
308+
282309
return [super hasNoDisplay];
283310
}
284311

@@ -983,6 +1010,9 @@ - (BOOL)addEvent:(MXEvent*)event andRoomState:(MXRoomState*)roomState
9831010
case RoomBubbleCellDataTagLocation:
9841011
shouldAddEvent = NO;
9851012
break;
1013+
case RoomBubbleCellDataTagLiveLocation:
1014+
shouldAddEvent = NO;
1015+
break;
9861016
default:
9871017
break;
9881018
}
@@ -1294,5 +1324,11 @@ - (void)refreshURLPreviewForEventId:(NSString *)eventId
12941324
}];
12951325
}
12961326

1327+
- (void)updateBeaconInfoSummaryWithEventId:(NSString *)eventId
1328+
{
1329+
MXBeaconInfoSummary *beaconInfoSummary = [self.mxSession.aggregations.beaconAggegations beaconInfoSummaryFor:eventId inRoomWithId:self.roomId];
1330+
1331+
self.beaconInfoSummary = beaconInfoSummary;
1332+
}
12971333

12981334
@end

Riot/Modules/Room/RoomViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2905,7 +2905,7 @@ - (RoomTimelineCellIdentifier)cellIdentifierForCellData:(MXKCellData*)cellData a
29052905
}
29062906
}
29072907
}
2908-
else if (bubbleData.tag == RoomBubbleCellDataTagLocation)
2908+
else if (bubbleData.tag == RoomBubbleCellDataTagLocation || bubbleData.tag == RoomBubbleCellDataTagLiveLocation)
29092909
{
29102910
if (bubbleData.isIncoming)
29112911
{

changelog.d/6057.wip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Location sharing: Support live location event in the timeline.

0 commit comments

Comments
 (0)