mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Pin/Unpin Logic (#3084)
This commit is contained in:
@@ -100,6 +100,10 @@ class MockRoomTimelineController: RoomTimelineControllerProtocol {
|
||||
|
||||
func redact(_ itemID: TimelineItemIdentifier) async { }
|
||||
|
||||
func pin(eventID: String) async { }
|
||||
|
||||
func unpin(eventID: String) async { }
|
||||
|
||||
func messageEventContent(for itemID: TimelineItemIdentifier) -> RoomMessageEventContentWithoutRelation? {
|
||||
.init(noPointer: .init())
|
||||
}
|
||||
|
||||
@@ -237,6 +237,36 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
func pin(eventID: String) async {
|
||||
MXLog.info("Pinning event \(eventID) in \(roomID)")
|
||||
|
||||
switch await activeTimeline.pin(eventID: eventID) {
|
||||
case .success(let value):
|
||||
if value {
|
||||
MXLog.info("Finished pinning event \(eventID)")
|
||||
} else {
|
||||
MXLog.error("Failed pinning event \(eventID) because is already pinned")
|
||||
}
|
||||
case .failure(let error):
|
||||
MXLog.error("Failed pinning event \(eventID) with error: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
func unpin(eventID: String) async {
|
||||
MXLog.info("Unpinning event \(eventID) in \(roomID)")
|
||||
|
||||
switch await activeTimeline.unpin(eventID: eventID) {
|
||||
case .success(let value):
|
||||
if value {
|
||||
MXLog.info("Finished unpinning event \(eventID)")
|
||||
} else {
|
||||
MXLog.error("Failed unpinning event \(eventID) because is not pinned")
|
||||
}
|
||||
case .failure(let error):
|
||||
MXLog.error("Failed unpinning event \(eventID) with error: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
func messageEventContent(for timelineItemID: TimelineItemIdentifier) async -> RoomMessageEventContentWithoutRelation? {
|
||||
await activeTimeline.messageEventContent(for: timelineItemID)
|
||||
}
|
||||
|
||||
+4
@@ -68,6 +68,10 @@ protocol RoomTimelineControllerProtocol {
|
||||
|
||||
func redact(_ itemID: TimelineItemIdentifier) async
|
||||
|
||||
func pin(eventID: String) async
|
||||
|
||||
func unpin(eventID: String) async
|
||||
|
||||
func messageEventContent(for itemID: TimelineItemIdentifier) async -> RoomMessageEventContentWithoutRelation?
|
||||
|
||||
func debugInfo(for itemID: TimelineItemIdentifier) -> TimelineItemDebugInfo
|
||||
|
||||
Reference in New Issue
Block a user