diff --git a/Sources/PulseUI/Features/Inspector/Cells/NetworkRequestStatusCell.swift b/Sources/PulseUI/Features/Inspector/Cells/NetworkRequestStatusCell.swift index 8f203f067..0c86bf9f3 100644 --- a/Sources/PulseUI/Features/Inspector/Cells/NetworkRequestStatusCell.swift +++ b/Sources/PulseUI/Features/Inspector/Cells/NetworkRequestStatusCell.swift @@ -58,7 +58,7 @@ struct NetworkRequestStatusCellModel { let isMock: Bool fileprivate let duration: DurationViewModel? - init(task: NetworkTaskEntity, store: LoggerStore) { + init(task: NetworkTaskEntity, store: LoggerStore?) { self.status = StatusLabelViewModel(task: task, store: store) self.duration = DurationViewModel(task: task) self.isMock = task.isMocked @@ -135,7 +135,7 @@ struct NetworkRequestStatusCell_Previews: PreviewProvider { NavigationView { List { ForEach(MockTask.allEntities, id: \.objectID) { task in - NetworkRequestStatusCell(viewModel: .init(task: task, store: .mock)) + NetworkRequestStatusCell(viewModel: .init(task: task, store: LoggerStore.mock)) } } #if os(macOS) diff --git a/Sources/PulseUI/Helpers/FileViewModelContext.swift b/Sources/PulseUI/Helpers/FileViewModelContext.swift index 77df4dff9..39b229800 100644 --- a/Sources/PulseUI/Helpers/FileViewModelContext.swift +++ b/Sources/PulseUI/Helpers/FileViewModelContext.swift @@ -35,9 +35,9 @@ extension NetworkTaskEntity { /// - returns `nil` if the task is an unknown state. It may happen if the /// task is pending, but it's from the previous app run. - func state(in store: LoggerStore) -> NetworkTaskEntity.State? { + func state(in store: LoggerStore?) -> NetworkTaskEntity.State? { let state = self.state - if state == .pending && self.session != store.session.id { + if state == .pending, let store, self.session != store.session.id { return nil } return state diff --git a/Sources/PulseUI/Helpers/StatusLabelViewModel.swift b/Sources/PulseUI/Helpers/StatusLabelViewModel.swift index f7c6634c2..547555144 100644 --- a/Sources/PulseUI/Helpers/StatusLabelViewModel.swift +++ b/Sources/PulseUI/Helpers/StatusLabelViewModel.swift @@ -11,7 +11,7 @@ struct StatusLabelViewModel { let tint: Color let title: String - init(task: NetworkTaskEntity, store: LoggerStore) { + init(task: NetworkTaskEntity, store: LoggerStore?) { guard let state = task.state(in: store) else { self.systemImage = "questionmark.diamond.fill" self.tint = .secondary