mirror of
https://github.com/ouchadam/small-talk.git
synced 2025-03-25 16:30:12 +01:00
converting share module to engine
This commit is contained in:
parent
b987d1e21c
commit
489f45056c
@ -205,7 +205,7 @@ internal class FeatureModules internal constructor(
|
||||
}
|
||||
|
||||
val shareEntryModule by unsafeLazy {
|
||||
ShareEntryModule(matrixModules.sync, matrixModules.room)
|
||||
ShareEntryModule(matrixModules.engine)
|
||||
}
|
||||
|
||||
val imageGalleryModule by unsafeLazy {
|
||||
@ -457,8 +457,6 @@ internal class MatrixModules(
|
||||
}
|
||||
}
|
||||
|
||||
val sync by unsafeLazy { matrix.syncService() }
|
||||
val room by unsafeLazy { matrix.roomService() }
|
||||
}
|
||||
|
||||
internal class DomainModules(
|
||||
|
@ -3,6 +3,7 @@ package app.dapk.st.engine
|
||||
import app.dapk.st.matrix.common.EventId
|
||||
import app.dapk.st.matrix.common.JsonString
|
||||
import app.dapk.st.matrix.common.RoomId
|
||||
import app.dapk.st.matrix.common.RoomMember
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import java.io.InputStream
|
||||
|
||||
@ -28,6 +29,8 @@ interface ChatEngine {
|
||||
|
||||
suspend fun rejectJoinRoom(roomId: RoomId)
|
||||
|
||||
suspend fun findMembersSummary(roomId: RoomId): List<RoomMember>
|
||||
|
||||
fun mediaDecrypter(): MediaDecrypter
|
||||
|
||||
fun pushHandler(): PushHandler
|
||||
|
@ -4,9 +4,7 @@ dependencies {
|
||||
implementation project(":domains:android:compose-core")
|
||||
implementation project(":domains:android:viewmodel")
|
||||
implementation project(':domains:store')
|
||||
implementation project(':matrix:services:sync')
|
||||
implementation project(':matrix:services:room')
|
||||
implementation project(':matrix:services:message')
|
||||
implementation project(':chat-engine')
|
||||
implementation project(":core")
|
||||
implementation project(":design-library")
|
||||
implementation project(":features:navigator")
|
||||
|
@ -1,21 +1,20 @@
|
||||
package app.dapk.st.share
|
||||
|
||||
import app.dapk.st.matrix.room.RoomService
|
||||
import app.dapk.st.matrix.sync.SyncService
|
||||
import app.dapk.st.engine.ChatEngine
|
||||
import kotlinx.coroutines.flow.first
|
||||
|
||||
class FetchRoomsUseCase(
|
||||
private val syncSyncService: SyncService,
|
||||
private val roomService: RoomService,
|
||||
private val chatEngine: ChatEngine,
|
||||
) {
|
||||
|
||||
suspend fun bar(): List<Item> {
|
||||
return syncSyncService.overview().first().map {
|
||||
suspend fun fetch(): List<Item> {
|
||||
return chatEngine.directory().first().map {
|
||||
val overview = it.overview
|
||||
Item(
|
||||
it.roomId,
|
||||
it.roomAvatarUrl,
|
||||
it.roomName ?: "",
|
||||
roomService.findMembersSummary(it.roomId).map { it.displayName ?: it.id.value }
|
||||
overview.roomId,
|
||||
overview.roomAvatarUrl,
|
||||
overview.roomName ?: "",
|
||||
chatEngine.findMembersSummary(overview.roomId).map { it.displayName ?: it.id.value }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,13 @@
|
||||
package app.dapk.st.share
|
||||
|
||||
import app.dapk.st.core.ProvidableModule
|
||||
import app.dapk.st.matrix.room.RoomService
|
||||
import app.dapk.st.matrix.sync.SyncService
|
||||
import app.dapk.st.engine.ChatEngine
|
||||
|
||||
class ShareEntryModule(
|
||||
private val syncService: SyncService,
|
||||
private val roomService: RoomService,
|
||||
private val chatEngine: ChatEngine,
|
||||
) : ProvidableModule {
|
||||
|
||||
fun shareEntryViewModel(): ShareEntryViewModel {
|
||||
return ShareEntryViewModel(FetchRoomsUseCase(syncService, roomService))
|
||||
return ShareEntryViewModel(FetchRoomsUseCase(chatEngine))
|
||||
}
|
||||
}
|
@ -22,7 +22,7 @@ class ShareEntryViewModel(
|
||||
|
||||
fun start() {
|
||||
syncJob = viewModelScope.launch {
|
||||
state = DirectoryScreenState.Content(fetchRoomsUseCase.bar())
|
||||
state = DirectoryScreenState.Content(fetchRoomsUseCase.fetch())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,6 +88,8 @@ class MatrixEngine internal constructor(
|
||||
matrix.value.roomService().rejectJoinRoom(roomId)
|
||||
}
|
||||
|
||||
override suspend fun findMembersSummary(roomId: RoomId) = matrix.value.roomService().findMembersSummary(roomId)
|
||||
|
||||
override fun mediaDecrypter(): MediaDecrypter {
|
||||
val mediaDecrypter = matrixMediaDecrypter.value
|
||||
return object : MediaDecrypter {
|
||||
|
Loading…
x
Reference in New Issue
Block a user