-
Notifications
You must be signed in to change notification settings - Fork 99
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
Add Draft Messages Support #775
base: develop
Are you sure you want to change the base?
Conversation
Generated by 🚫 Danger |
SDK Size
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good so far, left few comments
Sources/StreamChatSwiftUI/ChatChannel/Composer/MessageComposerViewModel.swift
Outdated
Show resolved
Hide resolved
Sources/StreamChatSwiftUI/ChatChannel/Composer/MessageComposerViewModel.swift
Outdated
Show resolved
Hide resolved
Sources/StreamChatSwiftUI/ChatChannel/Composer/MessageComposerViewModel.swift
Outdated
Show resolved
Hide resolved
Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageListConfig.swift
Show resolved
Hide resolved
… will clear the text, which will delete the draft
Sources/StreamChatSwiftUI/ChatChannel/Composer/MessageComposerViewModel.swift
Show resolved
Hide resolved
… a computed draftMessage property
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! ✅
3ed0352
to
767eedb
Compare
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ Looks good
🔗 Issue Link
https://linear.app/stream/issue/IOS-720/drafts-support-for-swiftui
🎯 Goal
Adds draft messages support.
🛠 Implementation
Summary
Details
Filling the composer with a draft message:
Editing of messages in SwiftUI is still not implemented, so I had to implement this from scratch. The good thing is that this will make it easier to implement IOS-648.
Improves the commands parsing logic:
This was required in order to fill a command message in the composer from a draft. With this, we can now paste a command ex: "/giphy hey" in the composer, and it will correctly parse the full command.
MessageComposerViewModel.quotedMessage:
Initially, I added the
ChatChannelViewModel
to theMessageComposerView
to have access to thequotedMessage
(1st commit). But then realised I could pass a binding quoted message to theMessageComposerViewModel
. So, I decided on the latter solution since it is less hacky.New APIs
Utils.messageListConfig.draftMessagesEnabled
MessageComposerViewModel.updateDraftMessage()
MessageComposerViewModel.draftMessage
MessageComposerViewModel.fillDraftMessage()
MessageComposerViewModel.updateDraftMessage()
ChatThreadListItemViewModel.draftReplyText
ChatChannel.draftMessageText
User Flow
🧪 Testing
Pre-condition:
Apply the following git patch to change the environment:
c2env.patch
Note: Draft List has not been implemented on SwiftUI Demo App since it has already been tested by UIKit.
Update a Channel Draft Message
Update a Thread Draft Reply
Deleting a Draft (Channel + Thread)
Updating a draft with composer open on another device
Offline Support
Note: On iOS, we added draft requests to our Offline Queue. So when the connection is back online, the Draft requests will be retried.
Drafts for Threads that do not exist yet
☑️ Checklist