Change the Torch logo.
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 782 B |
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 526 B |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 7.7 KiB After Width: | Height: | Size: 4.8 KiB |
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 7.3 KiB |
@@ -1,12 +1,18 @@
|
||||
package at.torch.compose.database.dao
|
||||
|
||||
import androidx.room3.Dao
|
||||
import androidx.room3.Query
|
||||
import androidx.room3.Upsert
|
||||
import at.torch.compose.database.model.MarmotKeyPackage
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
import fr.acinq.bitcoin.PublicKey
|
||||
|
||||
@Dao
|
||||
interface MarmotKeyPackageDao {
|
||||
|
||||
@Query("SELECT * FROM MarmotKeyPackage WHERE publicKey = :publicKey")
|
||||
suspend fun getMarmotKeyPackageForPublicKey(publicKey: HexKey): MarmotKeyPackage?
|
||||
|
||||
@Upsert
|
||||
suspend fun upsert(marmotKeyPackage: MarmotKeyPackage)
|
||||
}
|
||||
@@ -3,7 +3,10 @@ package at.torch.compose.database.repository
|
||||
import at.torch.compose.database.model.ChatMessage
|
||||
import at.torch.compose.database.model.GiftWrapPayload
|
||||
import at.torch.compose.database.model.MarmotInnerEvent
|
||||
import at.torch.compose.database.model.MarmotKeyPackage
|
||||
import at.torch.compose.database.model.Participant
|
||||
import at.torch.compose.database.model.Profile
|
||||
import at.torch.compose.database.model.intermdiate.LocalProfile
|
||||
import co.touchlab.kermit.Logger
|
||||
import com.vitorpamplona.quartz.marmot.mls.group.MlsGroup
|
||||
import com.vitorpamplona.quartz.marmot.mls.group.MlsGroupState
|
||||
@@ -102,6 +105,14 @@ class DatabaseChatRepository(
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun getMarmotKeyPackageForPublicKey(publicKey: HexKey): MarmotKeyPackage? {
|
||||
return database.marmotKeyPackageDao().getMarmotKeyPackageForPublicKey(publicKey)
|
||||
}
|
||||
|
||||
override suspend fun getProfileWithPublicKey(publicKey: HexKey): Profile? {
|
||||
return database.profileDao().getProfileByPublicKey(publicKey)
|
||||
}
|
||||
|
||||
override suspend fun sendChatMessage(
|
||||
text: String,
|
||||
localChatRoom: at.torch.compose.database.model.intermdiate.LocalChatRoom,
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package at.torch.compose.repository
|
||||
|
||||
import at.torch.compose.database.model.MarmotKeyPackage
|
||||
import at.torch.compose.database.model.Participant
|
||||
import at.torch.compose.database.model.Profile
|
||||
import at.torch.compose.database.model.intermdiate.LocalChatMessage
|
||||
import at.torch.compose.database.model.intermdiate.LocalChatRoom
|
||||
import at.torch.compose.database.model.intermdiate.LocalProfile
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
import com.vitorpamplona.quartz.nip01Core.core.Kind
|
||||
import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerSync
|
||||
@@ -34,6 +37,10 @@ interface ChatRepository {
|
||||
|
||||
suspend fun getChatMessageRelayForPublicKey(publicKey: HexKey): ChatMessageRelayListEvent?
|
||||
|
||||
suspend fun getMarmotKeyPackageForPublicKey(publicKey: HexKey): MarmotKeyPackage?
|
||||
|
||||
suspend fun getProfileWithPublicKey(publicKey: HexKey): Profile?
|
||||
|
||||
suspend fun sendChatMessage(
|
||||
text: String,
|
||||
localChatRoom: LocalChatRoom,
|
||||
@@ -87,6 +94,14 @@ interface ChatRepository {
|
||||
return null
|
||||
}
|
||||
|
||||
override suspend fun getMarmotKeyPackageForPublicKey(publicKey: HexKey): MarmotKeyPackage? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override suspend fun getProfileWithPublicKey(publicKey: HexKey): Profile? {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override suspend fun sendChatMessage(
|
||||
text: String,
|
||||
localChatRoom: LocalChatRoom,
|
||||
|
||||
@@ -42,7 +42,10 @@ import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import androidx.lifecycle.viewmodel.initializer
|
||||
import androidx.lifecycle.viewmodel.viewModelFactory
|
||||
import at.torch.compose.database.model.NegentropySynchronizeRequest
|
||||
import at.torch.compose.database.model.types.SynchronizationFilter
|
||||
import at.torch.compose.extensions.toFormattedTimeAndDateString
|
||||
import at.torch.compose.nostr.Relays
|
||||
import at.torch.compose.ui.view.state.ChatRoomDetailMessageListUIState
|
||||
import co.touchlab.kermit.Logger
|
||||
import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent
|
||||
@@ -97,7 +100,7 @@ class ChatRoomDetailMessageListViewModel(
|
||||
// Sync messages from this relay...
|
||||
Pair(
|
||||
chatMessageRelayListEvent.relays(),
|
||||
_root_ide_package_.at.torch.compose.database.model.types.SynchronizationFilter(
|
||||
SynchronizationFilter(
|
||||
kinds = arrayOf(
|
||||
GiftWrapEvent.KIND,
|
||||
),
|
||||
@@ -113,8 +116,8 @@ class ChatRoomDetailMessageListViewModel(
|
||||
isReceiverChatMessageRelayListMissing.value = true
|
||||
// TODO: compute the timestamp for when list we sent messages and use that as since...
|
||||
Pair(
|
||||
at.torch.compose.nostr.Relays.DefaultDMRelayList,
|
||||
_root_ide_package_.at.torch.compose.database.model.types.SynchronizationFilter(
|
||||
Relays.DefaultDMRelayList,
|
||||
SynchronizationFilter(
|
||||
kinds = arrayOf(
|
||||
ChatMessageRelayListEvent.KIND,
|
||||
),
|
||||
@@ -129,8 +132,8 @@ class ChatRoomDetailMessageListViewModel(
|
||||
logger.i("GiftWrapFilter: ${relayAndSynchronizationFilter.second}")
|
||||
|
||||
val negentropySynchronizeRequests = relayAndSynchronizationFilter.first.map { normalizedRelayUrl ->
|
||||
_root_ide_package_.at.torch.compose.database.model.NegentropySynchronizeRequest(
|
||||
id = at.torch.compose.database.model.NegentropySynchronizeRequest.computeId(
|
||||
NegentropySynchronizeRequest(
|
||||
id = NegentropySynchronizeRequest.computeId(
|
||||
relayURL = normalizedRelayUrl.url,
|
||||
synchronizationFilter = relayAndSynchronizationFilter.second
|
||||
),
|
||||
|
||||
@@ -17,6 +17,7 @@ import co.touchlab.kermit.Logger
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.IO
|
||||
import kotlinx.coroutines.flow.firstOrNull
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class ChatRoomDetailViewModel(
|
||||
@@ -101,8 +102,16 @@ class ChatRoomDetailViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
logger.d("We should be creating a new chat...")
|
||||
chatRoomDetailUIState = ChatRoomDetailUIState.Error
|
||||
val localAccount = nostrRepository.observeProfile(chatRoomId).firstOrNull()
|
||||
|
||||
if (localAccount != null) {
|
||||
logger.d("Create chat with: $localAccount")
|
||||
// Check if we have a keyPackageEvent...
|
||||
chatRepository.getMarmotKeyPackageForPublicKey(chatRoomId)
|
||||
|
||||
} else {
|
||||
chatRoomDetailUIState = ChatRoomDetailUIState.Error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||