Skip to content

Commit 1f001e6

Browse files
authored
feat: support search in cells conversation (WPB-21649) (#3772)
* feat: support search in cells conversation * feat: test * feat: lint
1 parent 9aefdc7 commit 1f001e6

7 files changed

Lines changed: 23 additions & 5 deletions

File tree

domain/cells/src/commonMain/kotlin/com/wire/kalium/cells/data/CellsApiImpl.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ internal class CellsApiImpl(
115115
}.mapSuccess { response -> response.toDto() }
116116

117117
override suspend fun getNodesForPath(
118+
query: String,
118119
path: String,
119120
limit: Int?,
120121
offset: Int?,
@@ -145,7 +146,11 @@ internal class CellsApiImpl(
145146
} else {
146147
TreeNodeType.UNKNOWN
147148
},
148-
metadata = lookupTags
149+
metadata = lookupTags,
150+
text = LookupFilterTextSearch(
151+
searchIn = LookupFilterTextSearchIn.BaseName,
152+
term = query.ifEmpty { null }
153+
),
149154
),
150155
flags = listOf(RestFlag.WithPreSignedURLs)
151156
)

domain/cells/src/commonMain/kotlin/com/wire/kalium/cells/data/CellsDataSource.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ internal class CellsDataSource internal constructor(
104104
)
105105
} else {
106106
cellsApi.getNodesForPath(
107+
query = query,
107108
path = path,
108109
limit = limit,
109110
offset = offset,
@@ -125,11 +126,12 @@ internal class CellsDataSource internal constructor(
125126
}
126127

127128
override suspend fun getNodesByPath(
129+
query: String,
128130
path: String,
129131
onlyFolders: Boolean
130132
): Either<NetworkFailure, List<CellNode>> = withContext(dispatchers.io) {
131133
wrapApiRequest {
132-
cellsApi.getNodesForPath(path = path, onlyFolders = onlyFolders).mapSuccess { response ->
134+
cellsApi.getNodesForPath(query = query, path = path, onlyFolders = onlyFolders).mapSuccess { response ->
133135
response.nodes.map { it.toModel() }
134136
}
135137
}

domain/cells/src/commonMain/kotlin/com/wire/kalium/cells/domain/CellsApi.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@ internal interface CellsApi {
3131
suspend fun getNode(uuid: String): NetworkResponse<CellNodeDTO>
3232
suspend fun getNodes(query: String, limit: Int, offset: Int, tags: List<String>): NetworkResponse<GetNodesResponseDTO>
3333
suspend fun getNodesForPath(
34+
query: String,
3435
path: String,
3536
limit: Int? = null,
3637
offset: Int? = null,
3738
onlyDeleted: Boolean = false,
3839
onlyFolders: Boolean = false,
39-
tags: List<String> = emptyList()
40+
tags: List<String> = emptyList(),
4041
): NetworkResponse<GetNodesResponseDTO>
4142

4243
suspend fun getAllTags(): NetworkResponse<List<String>>

domain/cells/src/commonMain/kotlin/com/wire/kalium/cells/domain/CellsRepository.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ internal interface CellsRepository {
4646
): Either<NetworkFailure, PaginatedList<CellNode>>
4747

4848
suspend fun getNodesByPath(
49+
query: String,
4950
path: String,
5051
onlyFolders: Boolean
5152
): Either<NetworkFailure, List<CellNode>>

domain/cells/src/commonMain/kotlin/com/wire/kalium/cells/domain/usecase/GetFoldersUseCase.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,15 @@ internal class GetFoldersUseCaseImpl(
3535
) : GetFoldersUseCase {
3636

3737
override suspend operator fun invoke(conversationId: String): Either<CoreFailure, List<Node.Folder>> =
38-
cellsRepository.getNodesByPath(path = conversationId, onlyFolders = true).map { nodes ->
38+
cellsRepository.getNodesByPath(
39+
path = conversationId,
40+
onlyFolders = true,
41+
query = EMPTY
42+
).map { nodes ->
3943
nodes.map { it.toFolderModel() }
4044
}
45+
46+
companion object {
47+
private const val EMPTY = ""
48+
}
4149
}

domain/cells/src/commonTest/kotlin/com/wire/kalium/cells/domain/FakeCellsRepository.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class FakeCellsRepository : CellsRepository {
6969
}
7070

7171
override suspend fun getNodesByPath(
72+
query: String,
7273
path: String,
7374
onlyFolders: Boolean
7475
): Either<NetworkFailure, List<CellNode>> {

domain/cells/src/commonTest/kotlin/com/wire/kalium/cells/domain/NodeUploadManagerTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ private class TestRepository : CellsRepository {
307307
pagination = null
308308
).right()
309309

310-
override suspend fun getNodesByPath(path: String, onlyFolders: Boolean): Either<NetworkFailure, List<CellNode>> {
310+
override suspend fun getNodesByPath(query: String, path: String, onlyFolders: Boolean): Either<NetworkFailure, List<CellNode>> {
311311
TODO("Not yet implemented")
312312
}
313313

0 commit comments

Comments
 (0)