Add developer option to hide media in the timeline. (#3366)

This commit is contained in:
Doug
2024-10-03 17:59:39 +01:00
committed by GitHub
parent 4f29821306
commit e6f4dd33a0
24 changed files with 325 additions and 65 deletions
@@ -125,6 +125,13 @@ class TimelineTableViewController: UIViewController {
}
}
var hideTimelineMedia = false {
didSet {
guard let snapshot = dataSource?.snapshot() else { return }
dataSource?.applySnapshotUsingReloadData(snapshot)
}
}
/// Used to hold an observable object that the typing indicator can use
let typingMembers = TypingMembersObservableObject(members: [])
@@ -260,21 +267,19 @@ class TimelineTableViewController: UIViewController {
let cell = tableView.dequeueReusableCell(withIdentifier: TimelineItemCell.reuseIdentifier, for: indexPath)
guard let self, let cell = cell as? TimelineItemCell else { return cell }
// A local reference to avoid capturing self in the cell configuration.
let coordinator = self.coordinator
let viewState = timelineItemsDictionary[id]
cell.item = viewState
guard let viewState else {
return cell
}
cell.contentConfiguration = UIHostingConfiguration {
cell.contentConfiguration = UIHostingConfiguration { [coordinator, hideTimelineMedia] in
RoomTimelineItemView(viewState: viewState)
.id(id)
.frame(maxWidth: .infinity, alignment: .leading)
.environmentObject(coordinator.context) // Attempted fix at a crash in TimelineItemContextMenu
.environment(\.timelineContext, coordinator.context)
.environment(\.shouldAutomaticallyLoadImages, !hideTimelineMedia)
}
.margins(.all, 0) // Margins are handled in the stylers
.minSize(height: 1)