Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Mactrix/Views/ChatView/ChatView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@ struct TimelineGroupView: View {
}
}

private struct TimelineReadKey: Equatable {
let count: Int
let active: Bool
}

struct ChatJoinedRoom: View {
@Environment(AppState.self) private var appState
@Environment(\.appearsActive) private var appearsActive
@Bindable var timeline: LiveTimeline

var room: LiveRoom {
Expand Down Expand Up @@ -57,10 +63,10 @@ struct ChatJoinedRoom: View {
Logger.viewCycle.error("failed to mark room as recently visited: \(error)")
}
}
.task(id: timeline.timelineItems.count, priority: .background) {
.task(id: TimelineReadKey(count: timeline.timelineItems.count, active: appearsActive), priority: .background) {
guard appearsActive else { return }
do {
try await Task.sleep(for: .seconds(1))

Logger.viewCycle.debug("Mark room as read")
try await timeline.timeline?.markAsRead(receiptType: .read)
} catch is CancellationError {
Expand Down
Loading