Permalink Tweaks 2 (#2766)

* Missing changelog.

* Parse bare room aliases as permalinks.

Update the SDK.

* Fix tapping the same permalink twice.

Add a test.

Don't clear the focussed item when reaching the bottom of the timeline.

* Make sure sending a message returns to live.
This commit is contained in:
Doug
2024-04-29 17:32:16 +01:00
committed by GitHub
parent aaa8af2996
commit 7c94ed98a5
18 changed files with 111 additions and 52 deletions
@@ -88,7 +88,8 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
roomAvatarURL: roomProxy.avatarURL,
timelineStyle: appSettings.timelineStyle,
isEncryptedOneToOneRoom: roomProxy.isEncryptedOneToOneRoom,
timelineViewState: TimelineViewState(focussedEventID: focussedEventID),
timelineViewState: TimelineViewState(focussedEventID: focussedEventID,
focussedEventNeedsDisplay: focussedEventID != nil),
ownUserID: roomProxy.ownUserID,
hasOngoingCall: roomProxy.hasOngoingCall,
bindings: .init(reactionsCollapsed: [:])),
@@ -175,6 +176,8 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
paginateBackwards()
case .paginateForwards:
paginateForwards()
case .scrollToBottom:
scrollToBottom()
case .poll(let pollAction):
processPollAction(pollAction)
case .audio(let audioAction):
@@ -187,8 +190,9 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
Task { await focusOnEvent(eventID: eventID) }
case .focusLive:
focusLive()
case .clearFocussedEvent:
state.timelineViewState.focussedEventID = nil
case .scrolledToFocussedItem:
// Use a Task to mutate view state after the current view update.
Task { state.timelineViewState.focussedEventNeedsDisplay = false }
}
}
@@ -365,7 +369,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
.filter { $0 == .sentMessage }
.receive(on: DispatchQueue.main)
.sink { [weak self] _ in
self?.state.timelineViewState.scrollToBottomPublisher.send(())
self?.scrollToBottom()
}
.store(in: &cancellables)
@@ -488,6 +492,14 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
}
}
private func scrollToBottom() {
if state.timelineViewState.isLive {
state.timelineViewState.scrollToBottomPublisher.send(())
} else {
focusLive()
}
}
private func sendReadReceiptIfNeeded(for lastVisibleItemID: TimelineItemIdentifier) async {
guard appMediator.appState == .active else { return }