osx: mark as read when hovering over window
This commit is contained in:
@@ -23,5 +23,10 @@ struct ConversationView: View
|
|||||||
entryModel.handleDroppedProviders(providers)
|
entryModel.handleDroppedProviders(providers)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.onHover { isHovering in
|
||||||
|
guard isHovering else { return }
|
||||||
|
transcriptModel.setNeedsMarkAsRead()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,6 +131,9 @@ struct TranscriptView: View
|
|||||||
internal var messages: [Display.Message]
|
internal var messages: [Display.Message]
|
||||||
internal let client = XPCClient()
|
internal let client = XPCClient()
|
||||||
|
|
||||||
|
private var needsMarkAsRead: Bool = false
|
||||||
|
private var lastMarkAsRead: Date = .now
|
||||||
|
|
||||||
init(messages: [Display.Message] = []) {
|
init(messages: [Display.Message] = []) {
|
||||||
self.messages = messages
|
self.messages = messages
|
||||||
rebuildDisplayItems()
|
rebuildDisplayItems()
|
||||||
@@ -148,6 +151,19 @@ struct TranscriptView: View
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setNeedsMarkAsRead() {
|
||||||
|
guard needsMarkAsRead == false else { return }
|
||||||
|
guard Date.now.timeIntervalSince(lastMarkAsRead) > 5.0 else { return }
|
||||||
|
|
||||||
|
needsMarkAsRead = true
|
||||||
|
Task { @MainActor [weak self] in
|
||||||
|
guard let self else { return }
|
||||||
|
await markAsRead()
|
||||||
|
needsMarkAsRead = false
|
||||||
|
lastMarkAsRead = .now
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func attachmentDownloaded(id: String) {
|
func attachmentDownloaded(id: String) {
|
||||||
// TODO: should be smarter here
|
// TODO: should be smarter here
|
||||||
setNeedsReload(animated: false)
|
setNeedsReload(animated: false)
|
||||||
|
|||||||
Reference in New Issue
Block a user