Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
3b353bd
feat: new loading behavior
ohassine Apr 23, 2026
6704b01
Merge remote-tracking branch 'origin/develop' into new-loading-behavior
ohassine Apr 24, 2026
5d97f06
Merge remote-tracking branch 'origin/develop' into new-loading-behavior
ohassine Apr 24, 2026
43c0418
feat: remove download to external storage option
ohassine Apr 27, 2026
9ea06e7
feat: cleanup
ohassine Apr 28, 2026
fa81683
feat: detekt
ohassine Apr 28, 2026
dcf676f
Merge remote-tracking branch 'origin/develop' into new-loading-behavior
ohassine Apr 28, 2026
ca33415
Merge remote-tracking branch 'origin/develop' into new-loading-behavior
ohassine Apr 28, 2026
ff7f3b5
feat: cleanup
ohassine Apr 28, 2026
8d57c00
feat: cleanup
ohassine Apr 28, 2026
5296036
feat: cleanup
ohassine Apr 28, 2026
add26ee
fix: cleanup
ohassine Apr 29, 2026
942a6e2
fix: cleanup
ohassine Apr 29, 2026
a9e6d8c
feat: refactor
ohassine Apr 29, 2026
2bb96f2
feat: unit test
ohassine Apr 29, 2026
d403848
Merge branch 'develop' into new-loading-behavior
ohassine Apr 29, 2026
771b73d
feat: detekt
ohassine Apr 29, 2026
3f458b1
Merge remote-tracking branch 'origin/new-loading-behavior' into new-l…
ohassine Apr 30, 2026
784c3d3
feat: detekt
ohassine Apr 30, 2026
24a0eea
Merge branch 'develop' into new-loading-behavior
ohassine Apr 30, 2026
f8a0d11
Merge branch 'develop' into new-loading-behavior
ohassine May 4, 2026
d76da05
chore: test
ohassine May 4, 2026
1a25574
Merge branch 'develop' into new-loading-behavior
ohassine May 4, 2026
defa808
feat(drive): Make files available offline
ohassine May 6, 2026
57eb842
Merge remote-tracking branch 'origin/develop' into Make-files-availab…
ohassine May 6, 2026
ed03ad9
feat(drive): Make files available offline
ohassine May 7, 2026
e45ce22
Merge remote-tracking branch 'origin/develop' into Make-files-availab…
ohassine May 7, 2026
e629614
chore: cleanup
ohassine May 7, 2026
a6852d9
chore: cleanup
ohassine May 7, 2026
5db198b
chore: detekt
ohassine May 7, 2026
2a1bd5f
chore: detekt
ohassine May 8, 2026
fcd8bb1
chore: cleanup
ohassine May 8, 2026
e7589b7
Merge remote-tracking branch 'origin/develop' into Make-files-availab…
ohassine May 8, 2026
66771b7
feat: modifiedAt from String to Long
ohassine May 12, 2026
6576a50
feat: cleanup
ohassine May 12, 2026
6343f92
Merge branch 'develop' into Make-files-available-offline
ohassine May 12, 2026
c4c8be5
feat: cleanup
ohassine May 12, 2026
22fd15f
feat: kalium reference
ohassine May 12, 2026
d050772
feat: cleanup
ohassine May 12, 2026
d2d0998
feat: test
ohassine May 12, 2026
b9ff6a8
Merge branch 'develop' into Make-files-available-offline
ohassine May 12, 2026
12e6365
fix: incorrect icon usage
ohassine May 12, 2026
a30de5a
Merge remote-tracking branch 'origin/Make-files-available-offline' in…
ohassine May 12, 2026
204ae28
fix: detekt
ohassine May 12, 2026
bd1a0df
fix: lint
ohassine May 12, 2026
15042f2
feat: display offline files
ohassine May 12, 2026
0d713bc
feat: display offline files
ohassine May 13, 2026
c5225a5
Merge remote-tracking branch 'origin/Make-files-available-offline' in…
ohassine May 13, 2026
a334c17
feat: display offline files
ohassine May 13, 2026
af93b1d
feat: cleanup
ohassine May 13, 2026
b59a08f
feat: cleanup
ohassine May 13, 2026
c51175a
feat: support offline mode in search screen
ohassine May 13, 2026
389525d
chore: cleanup
ohassine May 13, 2026
6489c30
chore: kalium
ohassine May 13, 2026
11509a2
Merge remote-tracking branch 'origin/develop' into display-offline-files
ohassine May 13, 2026
952a1ae
chore: lint
ohassine May 13, 2026
1ebbcbd
Merge remote-tracking branch 'origin/develop' into Make-files-availab…
ohassine May 13, 2026
bb0cda9
Merge branch 'Make-files-available-offline' into display-offline-files
ohassine May 13, 2026
785f817
chore: cleanup
ohassine May 13, 2026
065917d
chore: add conversationId
ohassine May 13, 2026
bea8de1
chore: add conversationId
ohassine May 13, 2026
9cc0b51
chore: kalium reference
ohassine May 13, 2026
b9cdfef
chore: test
ohassine May 13, 2026
e4aadf2
chore: detekt
ohassine May 13, 2026
3cc3b57
Merge branch 'develop' into Make-files-available-offline
ohassine May 13, 2026
155c2d1
Merge remote-tracking branch 'origin/Make-files-available-offline' in…
ohassine May 13, 2026
0d26300
Merge branch 'Make-files-available-offline' into display-offline-files
ohassine May 13, 2026
3965331
chore: detekt
ohassine May 13, 2026
6125be1
chore: kalium
ohassine May 13, 2026
27f686e
chore: test
ohassine May 13, 2026
e44bd6f
Merge branch 'Make-files-available-offline' into display-offline-files
ohassine May 13, 2026
d4c75c1
chore: test
ohassine May 13, 2026
8c63ab4
chore: detekt
ohassine May 13, 2026
c69e635
Merge remote-tracking branch 'origin/Make-files-available-offline' in…
ohassine May 13, 2026
92c9caa
chore: cleanup
ohassine May 13, 2026
7bedbad
refactor: add mimeType
ohassine May 18, 2026
dffb611
feat: show offline indicator for files in conversation
ohassine May 18, 2026
6776d9b
feat: Display offline files (WPB-23968) (#4822)
ohassine May 20, 2026
e7cddfc
Merge remote-tracking branch 'origin/develop' into Make-files-availab…
ohassine May 20, 2026
de22055
Merge remote-tracking branch 'origin/develop' into Make-files-availab…
ohassine May 20, 2026
9b8a5bb
chore: detekt
ohassine May 20, 2026
8f60e28
Merge remote-tracking branch 'origin/Make-files-available-offline' in…
ohassine May 20, 2026
aac5ec9
chore: cleanup
ohassine May 20, 2026
5bba7d3
chore: pass conversationId using savedStateHandle instead of Assisted…
ohassine May 20, 2026
d867d23
chore: kalium
ohassine May 20, 2026
addc7c8
feat: test
ohassine May 21, 2026
5f92202
Merge remote-tracking branch 'origin/Make-files-available-offline' in…
ohassine May 21, 2026
9400085
Merge remote-tracking branch 'origin/develop' into Make-files-availab…
ohassine May 21, 2026
a409487
feat: kalium ref
ohassine May 21, 2026
1f60146
Merge remote-tracking branch 'origin/Make-files-available-offline' in…
ohassine May 21, 2026
3ef3638
refactor: move mapping to viewmodel
ohassine May 21, 2026
e63df09
refactor: address comments
ohassine May 21, 2026
63a0e33
feat: use case for observing offline files by conversationId
ohassine May 21, 2026
d1ba210
feat: cleanup
ohassine May 21, 2026
ce7922f
Merge remote-tracking branch 'origin/develop' into Make-files-availab…
ohassine Jun 2, 2026
8a97919
Merge remote-tracking branch 'origin/Make-files-available-offline' in…
ohassine Jun 2, 2026
b90294c
chore: conflicts
ohassine Jun 3, 2026
4060c21
Merge remote-tracking branch 'origin/develop' into show-offline-indic…
ohassine Jun 4, 2026
cb0adc6
chore: merge conflicts
ohassine Jun 4, 2026
94bf45b
chore: cleanup
ohassine Jun 4, 2026
9624bba
feat: cleanup
ohassine Jun 5, 2026
5db0d61
Merge branch 'develop' into show-offline-indicator-for-files-in-conve…
ohassine Jun 5, 2026
ba854dd
Merge remote-tracking branch 'origin/develop' into show-offline-indic…
ohassine Jun 5, 2026
55a332e
feat: kalium
ohassine Jun 5, 2026
4b61197
feat: kalium
ohassine Jun 5, 2026
f9c1607
feat: test
ohassine Jun 5, 2026
b265e47
feat: test
ohassine Jun 5, 2026
f40e306
feat: test
ohassine Jun 5, 2026
6fc9d3b
feat: test
ohassine Jun 5, 2026
d8caed8
feat: test
ohassine Jun 5, 2026
9a508a0
feat: detekt
ohassine Jun 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import com.wire.kalium.cells.domain.usecase.GetConversationNameUseCase
import com.wire.kalium.cells.domain.usecase.GetUserNameUseCase
import com.wire.kalium.cells.domain.usecase.offline.DeleteOfflineFileUseCase
import com.wire.kalium.cells.domain.usecase.offline.GetOfflineFileUseCase
import com.wire.kalium.cells.domain.usecase.offline.ObserveOfflineFilesByConversationUseCase
import com.wire.kalium.cells.domain.usecase.offline.ObserveOfflineFilesUseCase
import com.wire.kalium.cells.domain.usecase.offline.SaveOfflineFileUseCase
import com.wire.kalium.cells.paginatedConversationsFlowUseCase
Expand Down Expand Up @@ -235,6 +236,10 @@ class CellsModule {
@Provides
fun provideObserveOfflineFilesUseCase(cellsScope: CellsScope): ObserveOfflineFilesUseCase = cellsScope.observeOfflineFiles

@Provides
fun provideObserveOfflineFilesByConversationUseCase(cellsScope: CellsScope): ObserveOfflineFilesByConversationUseCase =
cellsScope.observeOfflineFilesByConversation

@Provides
fun provideGetOfflineFileUseCase(cellsScope: CellsScope): GetOfflineFileUseCase = cellsScope.getOfflineFile

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,19 @@ data class MultipartAttachmentUi(
val transferStatus: AssetTransferStatus,
val progress: Float? = null,
val isEditSupported: Boolean = false,
val isAvailableOffline: Boolean = false,
)

enum class AssetSource {
CELL, ASSET_STORAGE
}

fun MessageAttachment.toUiModel(progress: Float? = null) = when (this) {
is AssetContent -> this.toUiModel(progress)
is CellAssetContent -> this.toUiModel(progress)
fun MessageAttachment.toUiModel(progress: Float? = null, isAvailableOffline: Boolean = false) = when (this) {
is AssetContent -> this.toUiModel(progress, isAvailableOffline)
is CellAssetContent -> this.toUiModel(progress, isAvailableOffline)
}

fun CellAssetContent.toUiModel(progress: Float?) = MultipartAttachmentUi(
fun CellAssetContent.toUiModel(progress: Float?, isAvailableOffline: Boolean = false) = MultipartAttachmentUi(
uuid = this.id,
source = AssetSource.CELL,
fileName = this.assetPath?.substringAfterLast("/"),
Expand All @@ -67,9 +68,10 @@ fun CellAssetContent.toUiModel(progress: Float?) = MultipartAttachmentUi(
progress = progress,
contentHash = contentHash,
isEditSupported = isEditSupported,
isAvailableOffline = isAvailableOffline,
)

fun AssetContent.toUiModel(progress: Float?) = MultipartAttachmentUi(
fun AssetContent.toUiModel(progress: Float?, isAvailableOffline: Boolean = false) = MultipartAttachmentUi(
uuid = this.remoteData.assetId,
source = AssetSource.ASSET_STORAGE,
fileName = this.name,
Expand All @@ -84,4 +86,5 @@ fun AssetContent.toUiModel(progress: Float?) = MultipartAttachmentUi(
contentHash = null,
contentUrl = null,
isEditSupported = false,
isAvailableOffline = isAvailableOffline,
)
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@
import com.wire.kalium.cells.domain.usecase.ObserveAttachmentDraftsUseCase
import com.wire.kalium.cells.domain.usecase.RemoveAttachmentDraftUseCase
import com.wire.kalium.cells.domain.usecase.RetryAttachmentUploadUseCase
import com.wire.kalium.cells.domain.usecase.offline.ObserveOfflineFilesByConversationUseCase
import com.wire.kalium.logic.data.id.QualifiedIdMapper
import com.wire.kalium.logic.data.id.ConversationId
import com.wire.kalium.logic.data.asset.KaliumFileSystem
import com.wire.kalium.logic.data.user.UserId
import com.wire.kalium.logic.feature.asset.GetMessageAssetUseCase
Expand Down Expand Up @@ -192,6 +194,7 @@
private val onlineEditor: OnlineEditor,
private val featureFlags: KaliumConfigs,
private val getWireCellsConfig: GetWireCellConfigurationUseCase,
private val observeOfflineFilesByConversation: ObserveOfflineFilesByConversationUseCase,

Check warning on line 197 in app/src/main/kotlin/com/wire/android/ui/home/conversations/ConversationCoreViewModelFactory.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/ui/home/conversations/ConversationCoreViewModelFactory.kt#L197

Added line #L197 was not covered by tests
private val networkStateObserver: NetworkStateObserver,
@CurrentAccount private val selfUserId: UserId,
) {
Expand Down Expand Up @@ -346,7 +349,8 @@
selfUserId = selfUserId,
)

fun multipartAttachmentsViewModel() = MultipartAttachmentsViewModelImpl(
fun multipartAttachmentsViewModel(conversationId: ConversationId) = MultipartAttachmentsViewModelImpl(
conversationId = conversationId,

Check warning on line 353 in app/src/main/kotlin/com/wire/android/ui/home/conversations/ConversationCoreViewModelFactory.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/ui/home/conversations/ConversationCoreViewModelFactory.kt#L352-L353

Added lines #L352 - L353 were not covered by tests
refreshHelper = refreshHelper,
download = downloadCellFile,
getEditorUrl = getEditorUrl,
Expand All @@ -355,5 +359,6 @@
kaliumFileSystem = kaliumFileSystem,
featureFlags = featureFlags,
getWireCellsConfig = getWireCellsConfig,
observeOfflineFilesByConversation = observeOfflineFilesByConversation

Check warning on line 362 in app/src/main/kotlin/com/wire/android/ui/home/conversations/ConversationCoreViewModelFactory.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/ui/home/conversations/ConversationCoreViewModelFactory.kt#L362

Added line #L362 was not covered by tests
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import androidx.lifecycle.ViewModel
import com.wire.android.di.metro.MetroViewModelGraph
import com.wire.android.di.metro.metroSavedStateViewModel
import com.wire.android.di.metro.metroViewModel
import com.wire.kalium.logic.data.id.ConversationId
import com.wire.android.ui.home.conversations.attachment.MessageAttachmentsViewModel
import com.wire.android.ui.home.conversations.banner.ConversationBannerViewModel
import com.wire.android.ui.home.conversations.composer.MessageComposerViewModel
Expand Down Expand Up @@ -115,9 +116,9 @@ fun conversationInfoViewModel(): ConversationInfoViewModel =
conversationSavedStateViewModel { this.conversationInfoViewModel(it) }

@Composable
fun multipartAttachmentsViewModel(conversationKey: String): MultipartAttachmentsViewModel =
conversationViewModel<MultipartAttachmentsViewModelImpl>(key = conversationKey) {
this.multipartAttachmentsViewModel()
fun multipartAttachmentsViewModel(conversationId: ConversationId): MultipartAttachmentsViewModel =
conversationViewModel<MultipartAttachmentsViewModelImpl>(key = conversationId.value) {
this.multipartAttachmentsViewModel(conversationId)
}

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,20 @@ 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.runtime.remember
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.lifecycle.compose.collectAsStateWithLifecycle
import coil3.decode.Decoder
import coil3.request.ImageRequest
import coil3.request.crossfade
import com.wire.android.ui.common.colorsScheme
import com.wire.android.ui.common.dimensions
import com.wire.android.ui.common.multipart.MultipartAttachmentUi
import com.wire.android.ui.common.multipart.toUiModel
import com.wire.android.ui.home.conversations.multipartAttachmentsViewModel
import com.wire.android.ui.home.conversations.messages.item.MessageStyle
import com.wire.android.ui.home.conversations.model.messagetypes.multipart.grid.AssetGridPreview
Expand All @@ -59,13 +61,19 @@ fun MultipartAttachmentsView(
modifier: Modifier = Modifier,
viewModel: MultipartAttachmentsViewModel = when {
LocalInspectionMode.current -> MultipartAttachmentsViewModelPreview
else -> multipartAttachmentsViewModel(conversationId.value)
else -> multipartAttachmentsViewModel(conversationId)
}
) {
// Collect to trigger recomposition when offline availability changes.
val offlineAttachmentIds by viewModel.offlineAttachmentIds.collectAsStateWithLifecycle()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: do not expose offlineAttachmentIds outside of viewmodel just for mapping.
Add mapAttachment(attachment) method for mapping one attachment and then both mapAttachment/mapAttachments can do the mapping using private offlineAttachmentIds in viewmodel.


// 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()
val item = remember(attachment, offlineAttachmentIds) {
viewModel.mapAttachment(attachment)
}
item.let {
AssetPreview(
modifier = modifier
.onVisibilityChanged { visible ->
Expand All @@ -86,7 +94,9 @@ fun MultipartAttachmentsView(
)
}
} else {
val groups = viewModel.mapAttachments(attachments)
val groups = remember(attachments, offlineAttachmentIds) {
viewModel.mapAttachments(attachments = attachments)
}

Column(
modifier = modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,44 +32,65 @@
import com.wire.kalium.cells.domain.usecase.GetEditorUrlUseCase
import com.wire.kalium.cells.domain.usecase.GetWireCellConfigurationUseCase
import com.wire.kalium.cells.domain.usecase.download.DownloadCellFileUseCase
import com.wire.kalium.cells.domain.usecase.offline.ObserveOfflineFilesByConversationUseCase
import com.wire.kalium.common.functional.onSuccess
import com.wire.kalium.logic.data.asset.AssetTransferStatus
import com.wire.kalium.logic.data.asset.KaliumFileSystem
import com.wire.kalium.logic.data.featureConfig.CollaboraEdition
import com.wire.kalium.logic.data.id.ConversationId
import com.wire.kalium.logic.data.message.AssetContent
import com.wire.kalium.logic.data.message.CellAssetContent
import com.wire.kalium.logic.data.message.MessageAttachment
import com.wire.kalium.logic.featureFlags.KaliumConfigs
import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.launch
import okio.Path.Companion.toPath

interface MultipartAttachmentsViewModel {
val offlineAttachmentIds: StateFlow<Set<String>>
fun onClick(attachment: MultipartAttachmentUi, openInImageViewer: (String) -> Unit)
fun mapAttachment(attachment: MessageAttachment): MultipartAttachmentUi {
val isAvailableOffline = attachment.assetId() in offlineAttachmentIds.value
return attachment.toUiModel(isAvailableOffline = isAvailableOffline)

Check warning on line 59 in app/src/main/kotlin/com/wire/android/ui/home/conversations/model/messagetypes/multipart/MultipartAttachmentsViewModel.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/ui/home/conversations/model/messagetypes/multipart/MultipartAttachmentsViewModel.kt#L57-L59

Added lines #L57 - L59 were not covered by tests
}

fun mapAttachments(
attachments: List<MessageAttachment>
attachments: List<MessageAttachment>,
): List<MultipartAttachmentGroup> {
val offlineIds = offlineAttachmentIds.value

val result = mutableListOf<MultipartAttachmentGroup>()
var group: MultipartAttachmentGroup? = null

attachments.forEach {
val isAvailableOffline = it.assetId() in offlineIds
if (it.isMediaAttachment()) {
group = when (group) {
null -> MultipartAttachmentGroup.Media(listOf(it.toUiModel()))
is MultipartAttachmentGroup.Media -> group.copy(group.attachments + it.toUiModel())
null -> MultipartAttachmentGroup.Media(listOf(it.toUiModel(isAvailableOffline = isAvailableOffline)))
is MultipartAttachmentGroup.Media -> {
val newAttachment = it.toUiModel(isAvailableOffline = isAvailableOffline)
group.copy(attachments = group.attachments + newAttachment)
}
else -> {
result.add(group)
MultipartAttachmentGroup.Media(listOf(it.toUiModel()))
MultipartAttachmentGroup.Media(listOf(it.toUiModel(isAvailableOffline = isAvailableOffline)))
}
}
} else {
group = when (group) {
null -> MultipartAttachmentGroup.Files(listOf(it.toUiModel()))
is MultipartAttachmentGroup.Files -> group.copy(group.attachments + it.toUiModel())
null -> MultipartAttachmentGroup.Files(listOf(it.toUiModel(isAvailableOffline = isAvailableOffline)))
is MultipartAttachmentGroup.Files -> {
val newAttachment = it.toUiModel(isAvailableOffline = isAvailableOffline)
group.copy(attachments = group.attachments + newAttachment)
}
else -> {
result.add(group)
MultipartAttachmentGroup.Files(listOf(it.toUiModel()))
MultipartAttachmentGroup.Files(listOf(it.toUiModel(isAvailableOffline = isAvailableOffline)))
}
}
}
Expand All @@ -93,12 +114,15 @@

@Suppress("EmptyFunctionBlock")
object MultipartAttachmentsViewModelPreview : MultipartAttachmentsViewModel {
override val offlineAttachmentIds: StateFlow<Set<String>> = MutableStateFlow(emptySet<String>())

Check warning on line 117 in app/src/main/kotlin/com/wire/android/ui/home/conversations/model/messagetypes/multipart/MultipartAttachmentsViewModel.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/ui/home/conversations/model/messagetypes/multipart/MultipartAttachmentsViewModel.kt#L117

Added line #L117 was not covered by tests
override fun onClick(attachment: MultipartAttachmentUi, openInImageViewer: (String) -> Unit) {}
override fun onAttachmentsVisible(attachments: List<MessageAttachment>) {}
override fun onAttachmentsHidden(attachments: List<MessageAttachment>) {}
}

@Suppress("LongParameterList")
class MultipartAttachmentsViewModelImpl(
private val conversationId: ConversationId,
private val refreshHelper: CellAssetRefreshHelper,
private val download: DownloadCellFileUseCase,
private val getEditorUrl: GetEditorUrlUseCase,
Expand All @@ -107,17 +131,24 @@
private val kaliumFileSystem: KaliumFileSystem,
private val featureFlags: KaliumConfigs,
private val getWireCellsConfig: GetWireCellConfigurationUseCase,
observeOfflineFilesByConversation: ObserveOfflineFilesByConversationUseCase,
) : ViewModel(), MultipartAttachmentsViewModel {

private val uploadProgress = mutableStateMapOf<String, Float>()
override val offlineAttachmentIds: StateFlow<Set<String>> = observeOfflineFilesByConversation(conversationId)
.map { offlineFiles -> offlineFiles.mapTo(mutableSetOf()) { it.id } }
.stateIn(viewModelScope, SharingStarted.Eagerly, emptySet())

private var isCollaboraEnabled: Boolean = false

init {
loadWireCellConfig()
}

override fun onClick(attachment: MultipartAttachmentUi, openInImageViewer: (String) -> Unit) {
override fun onClick(
attachment: MultipartAttachmentUi,
openInImageViewer: (String) -> Unit,
) {
when {
attachment.isImage() && !attachment.fileNotFound() -> openInImageViewer(attachment.uuid)
attachment.isEditSupported && isCollaboraEnabled && featureFlags.collaboraIntegration ->
Expand Down Expand Up @@ -171,7 +202,7 @@

download(
assetId = attachment.uuid,
conversationId = null, // TODO to replace with real conversation id in next PR
conversationId = conversationId.value,

Check warning on line 205 in app/src/main/kotlin/com/wire/android/ui/home/conversations/model/messagetypes/multipart/MultipartAttachmentsViewModel.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/ui/home/conversations/model/messagetypes/multipart/MultipartAttachmentsViewModel.kt#L205

Added line #L205 was not covered by tests
outFilePath = path,
assetSize = attachment.assetSize ?: 0,
) { progress ->
Expand Down Expand Up @@ -205,7 +236,7 @@
}
}

private fun MessageAttachment.assetId() =
internal fun MessageAttachment.assetId() =
when (this) {
is AssetContent -> remoteData.assetId
is CellAssetContent -> id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import com.wire.android.feature.cells.R
import com.wire.android.feature.cells.domain.model.AttachmentFileType
import com.wire.android.ui.common.applyIf
import com.wire.android.ui.common.colorsScheme
Expand Down Expand Up @@ -92,6 +95,20 @@ internal fun AssetGridPreview(
}
}

if (item.isAvailableOffline) {
Icon(
modifier = Modifier
.padding(
end = dimensions().spacing6x,
top = dimensions().spacing6x
)
.align(Alignment.TopEnd),
painter = painterResource(R.drawable.ic_downloaded),
contentDescription = null,
tint = colorsScheme().secondaryText,
)
}

item.progress?.let {
CircularProgressIndicator(
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,17 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.Dp
import com.wire.android.feature.cells.R
import com.wire.android.feature.cells.domain.model.AttachmentFileType
import com.wire.android.ui.common.applyIf
import com.wire.android.ui.common.colorsScheme
Expand Down Expand Up @@ -76,6 +81,19 @@ fun AssetPreview(
item.isEditSupported -> EditableAssetPreview(item, messageStyle)
else -> FileAssetPreview(item, messageStyle)
}
if (item.isAvailableOffline) {
Icon(
modifier = Modifier
.padding(
end = dimensions().spacing6x,
top = dimensions().spacing6x
)
.align(Alignment.TopEnd),
painter = painterResource(R.drawable.ic_downloaded),
contentDescription = null,
tint = colorsScheme().secondaryText,
)
}
} else {
AssetNotAvailablePreview(messageStyle = messageStyle)
}
Expand Down
Loading
Loading