From 2509b5e7c8f36a9abfbee5f72442d936d98e7fc0 Mon Sep 17 00:00:00 2001 From: MaximeE Date: Mon, 9 May 2022 14:41:04 +0200 Subject: [PATCH] 6099: Fix bad interaction between static and live location cell --- .../Room/Location/RoomTimelineLocationView.swift | 3 +++ .../Plain/Cells/Location/LocationPlainCell.swift | 13 +++++++++---- changelog.d/6099.bugfix | 1 + 3 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 changelog.d/6099.bugfix diff --git a/Riot/Modules/Room/Location/RoomTimelineLocationView.swift b/Riot/Modules/Room/Location/RoomTimelineLocationView.swift index e467a8242..322e9ef1e 100644 --- a/Riot/Modules/Room/Location/RoomTimelineLocationView.swift +++ b/Riot/Modules/Room/Location/RoomTimelineLocationView.swift @@ -163,6 +163,7 @@ class RoomTimelineLocationView: UIView, NibLoadable, Themable, MGLMapViewDelegat bannerViewData: LiveLocationBannerViewData? = nil) { if let location = location { + mapView.isHidden = false mapView.styleURL = mapStyleURL annotationView = LocationMarkerView.loadFromNib() @@ -188,6 +189,8 @@ class RoomTimelineLocationView: UIView, NibLoadable, Themable, MGLMapViewDelegat // Configure live location banner guard let bannerViewData = bannerViewData else { liveLocationContainerView.isHidden = true + placeholderBackground.isHidden = true + placeholderIcon.isHidden = true return } diff --git a/Riot/Modules/Room/TimelineCells/Styles/Plain/Cells/Location/LocationPlainCell.swift b/Riot/Modules/Room/TimelineCells/Styles/Plain/Cells/Location/LocationPlainCell.swift index a6bba7b80..7e9a2a1bc 100644 --- a/Riot/Modules/Room/TimelineCells/Styles/Plain/Cells/Location/LocationPlainCell.swift +++ b/Riot/Modules/Room/TimelineCells/Styles/Plain/Cells/Location/LocationPlainCell.swift @@ -26,17 +26,17 @@ class LocationPlainCell: SizableBaseRoomCell, RoomCellReactionsDisplayable, Room super.render(cellData) guard #available(iOS 14.0, *), - let bubbleData = cellData as? RoomBubbleCellData + let bubbleData = cellData as? RoomBubbleCellData, + let event = bubbleData.events.last else { return } locationView.update(theme: ThemeService.shared().theme) locationView.delegate = self + self.event = event - if bubbleData.cellDataTag == .location, - let event = bubbleData.events.last { - self.event = event + if bubbleData.cellDataTag == .location { renderStaticLocation(event) } else if bubbleData.cellDataTag == .liveLocation, let beaconInfoSummary = bubbleData.beaconInfoSummary { @@ -127,6 +127,11 @@ class LocationPlainCell: SizableBaseRoomCell, RoomCellReactionsDisplayable, Room contentView.vc_addSubViewMatchingParent(locationView) } + + override func prepareForReuse() { + super.prepareForReuse() + self.event = nil + } } extension LocationPlainCell: RoomTimelineLocationViewDelegate { diff --git a/changelog.d/6099.bugfix b/changelog.d/6099.bugfix new file mode 100644 index 000000000..d087dc1a2 --- /dev/null +++ b/changelog.d/6099.bugfix @@ -0,0 +1 @@ +Location sharing: fix bad interaction between static and live location cell