A little clean up

This commit is contained in:
Kgothatso Ngako committed 2026-07-05 17:15:54 +02:00
1 parent 61a5e4c138
commit d44193bdab
4 files changed
+19 -33

No files matched your search

@@ -38,6 +38,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.IO
import kotlinx.coroutines.launch
import kotlin.math.log
import kotlin.time.Instant
class ChatRoomListViewModel(
initialChatRoomListUIState: at.torch.compose.ui.view.state.ChatRoomListUIState,
@@ -83,7 +84,7 @@ class ChatRoomListViewModel(
limit = 50
)
nostrRepository.queueNegentropySynchronizeRequest(
at.torch.compose.nostr.Relays.DefaultDMRelayList.shuffled().map { normalizedRelayUrl ->
Relays.DefaultDMRelayList.shuffled().map { normalizedRelayUrl ->
NegentropySynchronizeRequest(
id = NegentropySynchronizeRequest.computeId(
relayURL = normalizedRelayUrl.url,
@@ -101,27 +102,10 @@ class ChatRoomListViewModel(
val chatRooms = chatRepository.getChatRoomListByPublicKey(publicKey)
val relayChatRoomMaps = Relays.DefaultDMRelayList.map { dmRelay ->
dmRelay.url to chatRooms.map { localChatRoom ->
// TODO: Just return localChatRoom.chatRoom.id once we have nostrGroupId stored as the chatRoom primary id
if (localChatRoom.chatRoom.mlsGroupState != null) {
if (localChatRoom.chatRoom.id.length == 64) {
localChatRoom.chatRoom.id
} else {
val group = MlsGroup.restore(
MlsGroupState.decodeTls(
localChatRoom.chatRoom.mlsGroupState.hexToByteArray()
)
)
logger.d("chatRoomId: ${localChatRoom.chatRoom.id} vs nostrGroupId (${group.currentMarmotData()?.nostrGroupId})")
group.currentMarmotData()?.nostrGroupId ?: localChatRoom.chatRoom.id
}
} else {
localChatRoom.chatRoom.id
}
localChatRoom.chatRoom.id
}
}
// TODO: Get relay with chatGroups...
val negentropySyncRequests = relayChatRoomMaps.map { relayChatRoomMap ->
val mlsGroupMessageFilter = SynchronizationFilter(
kinds = arrayOf(GroupEvent.KIND),
@@ -5,6 +5,7 @@ import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.viewmodel.initializer
import androidx.lifecycle.viewmodel.viewModelFactory
import at.torch.compose.network.dto.toRelayDTO
import at.torch.compose.network.sockets.NostrIncomingMessage
import co.touchlab.kermit.Logger
import com.vitorpamplona.negentropy.Negentropy
import com.vitorpamplona.negentropy.storage.StorageVector
@@ -266,7 +267,7 @@ class SynchronizationViewModel(
)
}
}
is at.torch.compose.network.sockets.NostrIncomingMessage.EoseMessage -> {
is NostrIncomingMessage.EoseMessage -> {
logger.d("Sync request has been successfully processed (${negentropySynchronizeRequest.relayURL}): $nostrIncomingMessage")
relaysSocketManager.closeNegentropySync(
@@ -276,7 +277,7 @@ class SynchronizationViewModel(
return@collect
}
is at.torch.compose.network.sockets.NostrIncomingMessage.NegentropyError -> {
is NostrIncomingMessage.NegentropyError -> {
logger.d("Negentropy Error (need to synchronize like normal): ${nostrIncomingMessage.negentropyReason}")
// TODO: Don't schedule a sync when on mobile internet.
@@ -287,7 +288,7 @@ class SynchronizationViewModel(
)
return@collect
}
is at.torch.compose.network.sockets.NostrIncomingMessage.NegentropyMessage -> {
is NostrIncomingMessage.NegentropyMessage -> {
logger.d("NegentropyMessage: ${nostrIncomingMessage.negentropyMessage}")
val result = negentropy.reconcile(
@@ -336,7 +337,7 @@ class SynchronizationViewModel(
return@collect
}
is at.torch.compose.network.sockets.NostrIncomingMessage.NoticeMessage -> {
is NostrIncomingMessage.NoticeMessage -> {
logger.d("Notice message ${negentropySynchronizeRequest.relayURL}: $nostrIncomingMessage")
if (nostrIncomingMessage.subscriptionId?.contains("negentropy disabled") == true) {
nostrRepository.queueSynchronizeNostrEvent(