-
Notifications
You must be signed in to change notification settings - Fork 187
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
Draft : add volatile storage when moving to edit mode. #3132
Conversation
📱 Scan the QR code below to install the build (arm64 only) for this PR. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3132 +/- ##
===========================================
- Coverage 75.95% 75.95% -0.01%
===========================================
Files 1638 1640 +2
Lines 38630 38663 +33
Branches 7464 7471 +7
===========================================
+ Hits 29343 29366 +23
- Misses 5399 5410 +11
+ Partials 3888 3887 -1 ☔ View full report in Codecov by Sentry. |
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, just a comment about docs. Thanks for the UX improvement!
import io.element.android.libraries.matrix.api.room.draft.ComposerDraft | ||
import javax.inject.Inject | ||
|
||
class VolatileComposerDraftStore @Inject constructor() : ComposerDraftStore { |
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.
Maybe add docs on the 2 draft stores?
if (isVolatile) { | ||
volatileComposerDraftStore.updateDraft(roomId, draft) | ||
} else { | ||
matrixComposerDraftStore.updateDraft(roomId, draft) |
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.
Maybe introduce a getStore
fun to be able to write:
override suspend fun loadDraft(roomId: RoomId, isVolatile: Boolean): ComposerDraft? {
return getStore(isVolatile).loadDraft(roomId)
}
override suspend fun updateDraft(roomId: RoomId, draft: ComposerDraft?, isVolatile: Boolean) {
getStore(isVolatile).updateDraft(roomId, draft)
}
private fun getStore(isVolatile: Boolean): ComposerDraftStore {
return if (isVolatile) {
volatileComposerDraftStore
} else {
matrixComposerDraftStore
}
}
|
* Currently it's used to store draft message when moving to edit mode. | ||
*/ | ||
class VolatileComposerDraftStore @Inject constructor() : ComposerDraftStore { | ||
private val drafts: MutableMap<RoomId, ComposerDraft> = mutableMapOf() |
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.
It's weird to store the draft in a map since a new VolatileComposerDraftStore
will be created for each room I think.
Type of change
Content
Add a volatile draft store when moving from NewMessage/Reply mode to Edit mode, so we don't loose our current composer text while moving to edit. It's then restored when :
If we manually switch to another Edit or another Reply from the timeline actions, then volatile draft is not restored.
Motivation and context
Screenshots / GIFs
Tests
Tested devices
Checklist