-
Notifications
You must be signed in to change notification settings - Fork 46
feat: Show offline indicator for files in conversation (WPB-23968) #4846
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
Open
ohassine
wants to merge
30
commits into
Make-files-available-offline
Choose a base branch
from
show-offline-indicator-for-files-in-conversation
base: Make-files-available-offline
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 24 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
15042f2
feat: display offline files
ohassine 0d713bc
feat: display offline files
ohassine c5225a5
Merge remote-tracking branch 'origin/Make-files-available-offline' in…
ohassine a334c17
feat: display offline files
ohassine af93b1d
feat: cleanup
ohassine b59a08f
feat: cleanup
ohassine c51175a
feat: support offline mode in search screen
ohassine 389525d
chore: cleanup
ohassine 6489c30
chore: kalium
ohassine 11509a2
Merge remote-tracking branch 'origin/develop' into display-offline-files
ohassine bb0cda9
Merge branch 'Make-files-available-offline' into display-offline-files
ohassine 785f817
chore: cleanup
ohassine 155c2d1
Merge remote-tracking branch 'origin/Make-files-available-offline' in…
ohassine 0d26300
Merge branch 'Make-files-available-offline' into display-offline-files
ohassine 3965331
chore: detekt
ohassine 6125be1
chore: kalium
ohassine e44bd6f
Merge branch 'Make-files-available-offline' into display-offline-files
ohassine c69e635
Merge remote-tracking branch 'origin/Make-files-available-offline' in…
ohassine 92c9caa
chore: cleanup
ohassine 7bedbad
refactor: add mimeType
ohassine dffb611
feat: show offline indicator for files in conversation
ohassine 8f60e28
Merge remote-tracking branch 'origin/Make-files-available-offline' in…
ohassine aac5ec9
chore: cleanup
ohassine 5bba7d3
chore: pass conversationId using savedStateHandle instead of Assisted…
ohassine 5f92202
Merge remote-tracking branch 'origin/Make-files-available-offline' in…
ohassine 1f60146
Merge remote-tracking branch 'origin/Make-files-available-offline' in…
ohassine 3ef3638
refactor: move mapping to viewmodel
ohassine e63df09
refactor: address comments
ohassine 63a0e33
feat: use case for observing offline files by conversationId
ohassine d1ba210
feat: cleanup
ohassine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,15 +25,17 @@ import androidx.compose.foundation.lazy.grid.GridCells | |
| import androidx.compose.foundation.lazy.grid.LazyVerticalGrid | ||
| import androidx.compose.foundation.lazy.grid.items | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.getValue | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.layout.onVisibilityChanged | ||
| import androidx.compose.ui.platform.LocalConfiguration | ||
| import androidx.compose.ui.platform.LocalContext | ||
| import androidx.compose.ui.platform.LocalInspectionMode | ||
| import androidx.hilt.navigation.compose.hiltViewModel | ||
| import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel | ||
| import coil3.decode.Decoder | ||
| import coil3.request.ImageRequest | ||
| import coil3.request.crossfade | ||
| import androidx.lifecycle.compose.collectAsStateWithLifecycle | ||
| import com.wire.android.ui.common.colorsScheme | ||
| import com.wire.android.ui.common.dimensions | ||
| import com.wire.android.ui.common.multipart.MultipartAttachmentUi | ||
|
|
@@ -43,7 +45,6 @@ import com.wire.android.ui.home.conversations.model.messagetypes.multipart.grid. | |
| import com.wire.android.ui.home.conversations.model.messagetypes.multipart.standalone.AssetPreview | ||
| import com.wire.kalium.logic.data.asset.AssetTransferStatus | ||
| import com.wire.kalium.logic.data.asset.isFailed | ||
| import com.wire.kalium.logic.data.id.ConversationId | ||
| import com.wire.kalium.logic.data.message.MessageAttachment | ||
|
|
||
| /** | ||
|
|
@@ -52,20 +53,21 @@ import com.wire.kalium.logic.data.message.MessageAttachment | |
| */ | ||
| @Composable | ||
| fun MultipartAttachmentsView( | ||
| conversationId: ConversationId, | ||
| attachments: List<MessageAttachment>, | ||
| messageStyle: MessageStyle, | ||
| onImageAttachmentClick: (String) -> Unit, | ||
| modifier: Modifier = Modifier, | ||
| viewModel: MultipartAttachmentsViewModel = when { | ||
| LocalInspectionMode.current -> MultipartAttachmentsViewModelPreview | ||
| else -> hiltViewModel<MultipartAttachmentsViewModelImpl>(key = conversationId.value) | ||
| else -> hiltViewModel<MultipartAttachmentsViewModelImpl>() | ||
|
ohassine marked this conversation as resolved.
Outdated
|
||
| } | ||
| ) { | ||
| val offlineAttachmentIds by viewModel.offlineAttachmentIds.collectAsStateWithLifecycle() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: do not expose offlineAttachmentIds outside of viewmodel just for mapping. |
||
|
|
||
| // TODO I found out that empty attachments list is not handled here and it shows empty message with no information | ||
| if (attachments.size == 1) { | ||
| attachments.first().toUiModel().let { | ||
| val attachment = attachments.first() | ||
| attachment.toUiModel(isAvailableOffline = attachment.assetId() in offlineAttachmentIds).let { | ||
| AssetPreview( | ||
| modifier = modifier | ||
| .onVisibilityChanged { visible -> | ||
|
|
@@ -86,7 +88,10 @@ fun MultipartAttachmentsView( | |
| ) | ||
| } | ||
| } else { | ||
| val groups = viewModel.mapAttachments(attachments) | ||
| val groups = viewModel.mapAttachments( | ||
| attachments = attachments, | ||
| offlineAttachmentIds = offlineAttachmentIds, | ||
| ) | ||
|
|
||
| Column( | ||
| modifier = modifier | ||
|
|
@@ -130,6 +135,7 @@ fun MultipartAttachmentsView( | |
| } | ||
| } | ||
|
|
||
|
|
||
| @Composable | ||
| private fun AttachmentsList( | ||
| attachments: List<MultipartAttachmentUi>, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why the conversationId cannot be passed via view parameters anymore?