From 29bcc5371a595b06dea4fd6eee3694420f0ec287 Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Wed, 20 Sep 2023 13:53:34 +0300 Subject: [PATCH] #1246 - Prevent timeline items from being computed on the main thread when instantiating the RoomTimelineController; speed up the room selection animation. --- .../Sources/Screens/HomeScreen/View/HomeScreenRoomCell.swift | 2 +- .../Timeline/TimelineController/RoomTimelineController.swift | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRoomCell.swift b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRoomCell.swift index 05d57eec3..45a874e27 100644 --- a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRoomCell.swift +++ b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRoomCell.swift @@ -169,7 +169,7 @@ struct HomeScreenRoomCellButtonStyle: ButtonStyle { configuration.label .background(isSelected ? Color.compound.bgSubtleSecondary : Color.compound.bgCanvasDefault) .contentShape(Rectangle()) - .animation(.elementDefault, value: isSelected) + .animation(isSelected ? .none : .easeOut(duration: 0.1), value: isSelected) } } diff --git a/ElementX/Sources/Services/Timeline/TimelineController/RoomTimelineController.swift b/ElementX/Sources/Services/Timeline/TimelineController/RoomTimelineController.swift index 63d73c3b1..62f8da2a0 100644 --- a/ElementX/Sources/Services/Timeline/TimelineController/RoomTimelineController.swift +++ b/ElementX/Sources/Services/Timeline/TimelineController/RoomTimelineController.swift @@ -62,7 +62,9 @@ class RoomTimelineController: RoomTimelineControllerProtocol { } .store(in: &cancellables) - updateTimelineItems() + serialDispatchQueue.async { + self.updateTimelineItems() + } NotificationCenter.default.addObserver(self, selector: #selector(contentSizeCategoryDidChange), name: UIContentSizeCategory.didChangeNotification, object: nil) }