Use the new @Entry macro everywhere.

Fix analytics service optionality.
This commit is contained in:
Doug 2024-10-01 13:34:16 +01:00 committed by Doug
parent e0ee4be834
commit 77e4fae2fb
4 changed files with 4 additions and 45 deletions

View File

@ -203,15 +203,3 @@ extension RoomScreenViewModel {
analyticsService: ServiceLocator.shared.analytics)
}
}
private struct RoomContextKey: EnvironmentKey {
@MainActor static let defaultValue: RoomScreenViewModel.Context? = nil
}
extension EnvironmentValues {
/// Used to access and inject the room context without observing it
var roomContext: RoomScreenViewModel.Context? {
get { self[RoomContextKey.self] }
set { self[RoomContextKey.self] = newValue }
}
}

View File

@ -865,26 +865,11 @@ extension TimelineViewModel {
analyticsService: ServiceLocator.shared.analytics)
}
private struct TimelineContextKey: EnvironmentKey {
@MainActor static let defaultValue: TimelineViewModel.Context? = nil
}
private struct FocussedEventID: EnvironmentKey {
static let defaultValue: String? = nil
}
extension EnvironmentValues {
/// Used to access and inject the room context without observing it
var timelineContext: TimelineViewModel.Context? {
get { self[TimelineContextKey.self] }
set { self[TimelineContextKey.self] = newValue }
}
@Entry var timelineContext: TimelineViewModel.Context?
/// An event ID which will be non-nil when a timeline item should show as focussed.
var focussedEventID: String? {
get { self[FocussedEventID.self] }
set { self[FocussedEventID.self] = newValue }
}
@Entry var focussedEventID: String?
}
private enum SlashCommand: String, CaseIterable {

View File

@ -26,13 +26,6 @@ enum TimelineGroupStyle: Hashable {
// MARK: - Environment
private struct TimelineGroupStyleKey: EnvironmentKey {
static let defaultValue = TimelineGroupStyle.single
}
extension EnvironmentValues {
var timelineGroupStyle: TimelineGroupStyle {
get { self[TimelineGroupStyleKey.self] }
set { self[TimelineGroupStyleKey.self] = newValue }
}
@Entry var timelineGroupStyle: TimelineGroupStyle = .single
}

View File

@ -7,13 +7,6 @@
import SwiftUI
private struct AnalyticsServiceKey: EnvironmentKey {
static let defaultValue: AnalyticsService = ServiceLocator.shared.analytics
}
extension EnvironmentValues {
var analyticsService: AnalyticsService {
get { self[AnalyticsServiceKey.self] }
set { self[AnalyticsServiceKey.self] = newValue }
}
@Entry var analyticsService: AnalyticsService = ServiceLocator.shared.analytics
}