mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Prepare for event focus and forward pagination (#2745)
Neither are available yet.
This commit is contained in:
@@ -51,59 +51,11 @@ class RoomProxy: RoomProxyProtocol {
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
lazy var id: String = room.id()
|
||||
|
||||
var ownUserID: String {
|
||||
room.ownUserId()
|
||||
}
|
||||
|
||||
init?(roomListItem: RoomListItemProtocol,
|
||||
room: RoomProtocol) async {
|
||||
self.roomListItem = roomListItem
|
||||
self.room = room
|
||||
|
||||
do {
|
||||
timeline = try await TimelineProxy(timeline: room.timeline())
|
||||
} catch {
|
||||
MXLog.error("Failed creating timeline with error: \(error)")
|
||||
return nil
|
||||
}
|
||||
|
||||
Task {
|
||||
await updateMembers()
|
||||
}
|
||||
}
|
||||
|
||||
func subscribeForUpdates() async {
|
||||
guard !subscribedForUpdates else {
|
||||
MXLog.warning("Room already subscribed for updates")
|
||||
return
|
||||
}
|
||||
|
||||
subscribedForUpdates = true
|
||||
let settings = RoomSubscription(requiredState: [RequiredState(key: "m.room.name", value: ""),
|
||||
RequiredState(key: "m.room.topic", value: ""),
|
||||
RequiredState(key: "m.room.avatar", value: ""),
|
||||
RequiredState(key: "m.room.canonical_alias", value: ""),
|
||||
RequiredState(key: "m.room.join_rules", value: "")],
|
||||
timelineLimit: UInt32(SlidingSyncConstants.defaultTimelineLimit))
|
||||
roomListItem.subscribe(settings: settings)
|
||||
Self.subscriptionCountPerRoom[roomListItem.id()] = (Self.subscriptionCountPerRoom[roomListItem.id()] ?? 0) + 1
|
||||
|
||||
await timeline.subscribeForUpdates()
|
||||
|
||||
subscribeToRoomInfoUpdates()
|
||||
|
||||
subscribeToTypingNotifications()
|
||||
}
|
||||
|
||||
func unsubscribeFromUpdates() {
|
||||
Self.subscriptionCountPerRoom[roomListItem.id()] = max(0, (Self.subscriptionCountPerRoom[roomListItem.id()] ?? 0) - 1)
|
||||
|
||||
if Self.subscriptionCountPerRoom[roomListItem.id()] ?? 0 <= 0 {
|
||||
roomListItem.unsubscribe()
|
||||
}
|
||||
}
|
||||
|
||||
lazy var id: String = room.id()
|
||||
|
||||
var name: String? {
|
||||
roomListItem.name()
|
||||
@@ -158,6 +110,65 @@ class RoomProxy: RoomProxyProtocol {
|
||||
var activeMembersCount: Int {
|
||||
Int(room.activeMembersCount())
|
||||
}
|
||||
|
||||
init?(roomListItem: RoomListItemProtocol,
|
||||
room: RoomProtocol) async {
|
||||
self.roomListItem = roomListItem
|
||||
self.room = room
|
||||
|
||||
do {
|
||||
timeline = try await TimelineProxy(timeline: room.timeline(), isLive: true)
|
||||
} catch {
|
||||
MXLog.error("Failed creating timeline with error: \(error)")
|
||||
return nil
|
||||
}
|
||||
|
||||
Task {
|
||||
await updateMembers()
|
||||
}
|
||||
}
|
||||
|
||||
func subscribeForUpdates() async {
|
||||
guard !subscribedForUpdates else {
|
||||
MXLog.warning("Room already subscribed for updates")
|
||||
return
|
||||
}
|
||||
|
||||
subscribedForUpdates = true
|
||||
let settings = RoomSubscription(requiredState: [RequiredState(key: "m.room.name", value: ""),
|
||||
RequiredState(key: "m.room.topic", value: ""),
|
||||
RequiredState(key: "m.room.avatar", value: ""),
|
||||
RequiredState(key: "m.room.canonical_alias", value: ""),
|
||||
RequiredState(key: "m.room.join_rules", value: "")],
|
||||
timelineLimit: UInt32(SlidingSyncConstants.defaultTimelineLimit))
|
||||
roomListItem.subscribe(settings: settings)
|
||||
Self.subscriptionCountPerRoom[roomListItem.id()] = (Self.subscriptionCountPerRoom[roomListItem.id()] ?? 0) + 1
|
||||
|
||||
await timeline.subscribeForUpdates()
|
||||
|
||||
subscribeToRoomInfoUpdates()
|
||||
|
||||
subscribeToTypingNotifications()
|
||||
}
|
||||
|
||||
func unsubscribeFromUpdates() {
|
||||
Self.subscriptionCountPerRoom[roomListItem.id()] = max(0, (Self.subscriptionCountPerRoom[roomListItem.id()] ?? 0) - 1)
|
||||
|
||||
if Self.subscriptionCountPerRoom[roomListItem.id()] ?? 0 <= 0 {
|
||||
roomListItem.unsubscribe()
|
||||
}
|
||||
}
|
||||
|
||||
func timelineFocusedOnEvent(eventID: String, numberOfEvents: UInt16) async -> Result<TimelineProxyProtocol, RoomProxyError> {
|
||||
.failure(.sdkError(RoomProxyMockError.generic))
|
||||
// do {
|
||||
// let timeline = try await room.timelineFocusedOnEvent(eventId: eventID, numContextEvents: numberOfEvents, internalIdPrefix: UUID().uuidString)
|
||||
// return .success(TimelineProxy(timeline: timeline, isLive: false))
|
||||
// } catch {
|
||||
// MXLog.error("Failed to create a timeline focussed on: \(eventID) with error: \(error)")
|
||||
// return .failure(.sdkError(error))
|
||||
// }
|
||||
}
|
||||
|
||||
func redact(_ eventID: String) async -> Result<Void, RoomProxyError> {
|
||||
await Task.dispatch(on: userInitiatedDispatchQueue) {
|
||||
|
||||
@@ -64,6 +64,8 @@ protocol RoomProxyProtocol {
|
||||
|
||||
func unsubscribeFromUpdates()
|
||||
|
||||
func timelineFocusedOnEvent(eventID: String, numberOfEvents: UInt16) async -> Result<TimelineProxyProtocol, RoomProxyError>
|
||||
|
||||
func redact(_ eventID: String) async -> Result<Void, RoomProxyError>
|
||||
|
||||
func reportContent(_ eventID: String, reason: String?) async -> Result<Void, RoomProxyError>
|
||||
|
||||
@@ -227,7 +227,7 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
|
||||
var lastMessageFormattedTimestamp: String?
|
||||
|
||||
if let latestRoomMessage = roomInfo.latestEvent {
|
||||
let lastMessage = EventTimelineItemProxy(item: latestRoomMessage, id: 0)
|
||||
let lastMessage = EventTimelineItemProxy(item: latestRoomMessage, id: "0")
|
||||
lastMessageFormattedTimestamp = lastMessage.timestamp.formattedMinimal()
|
||||
attributedLastMessage = eventStringBuilder.buildAttributedString(for: lastMessage)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user