-
Notifications
You must be signed in to change notification settings - Fork 114
Fix message thread reply footnote view not shown if parent message not in cache #681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
cfb4b2e
9ac0aef
ec13e93
4ddf3a4
6c96cc1
51543d2
3f11dfa
a9247a8
5e2ba52
f81cf5d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -116,3 +116,42 @@ | |
| } | ||
| } | ||
| } | ||
|
|
||
| /// Lazy view that uses the message controller to fetch the parent message before creating message replies view. | ||
| /// This is needed when the parent message is not available in the local cache. | ||
| /// Changing the `parentMessage` to `nil` in the `MessageRepliesView` would case multiple changes including breaking changes. | ||
| struct LazyMessageRepliesView<Factory: ViewFactory>: View { | ||
| @State private var parentMessageObserver: ChatMessageController.ObservableObject | ||
|
|
||
| var factory: Factory | ||
| var channel: ChatChannel | ||
| var message: ChatMessage | ||
|
|
||
| init( | ||
| factory: Factory, | ||
| channel: ChatChannel, | ||
| message: ChatMessage, | ||
| parentMessageController: ChatMessageController | ||
| ) { | ||
| parentMessageObserver = parentMessageController.observableObject | ||
|
Check failure on line 136 in Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageRepliesView.swift
|
||
| self.factory = factory | ||
| self.channel = channel | ||
| self.message = message | ||
| parentMessageObserver.controller.synchronize() | ||
|
||
| } | ||
|
|
||
| var body: some View { | ||
| Group { | ||
| if let parentMessage = parentMessageObserver.message { | ||
| factory.makeMessageRepliesShownInChannelView( | ||
| channel: channel, | ||
| message: message, | ||
| parentMessage: parentMessage, | ||
| replyCount: parentMessage.replyCount | ||
| ) | ||
| } else { | ||
| EmptyView() | ||
| } | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.