diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/Loaders.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/Loaders.kt index 076e62093..6ada3dda7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/Loaders.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/Loaders.kt @@ -31,7 +31,9 @@ import androidx.compose.runtime.produceState import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.vitorpamplona.amethyst.Amethyst import com.vitorpamplona.amethyst.model.AddressableNote +import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.amethyst.model.Note import com.vitorpamplona.amethyst.model.User import com.vitorpamplona.amethyst.model.emphChat.EphemeralChatChannel @@ -44,7 +46,9 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel import com.vitorpamplona.quartz.experimental.ephemChat.chat.RoomId import com.vitorpamplona.quartz.nip01Core.tags.addressables.Address import kotlinx.collections.immutable.ImmutableList +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.suspendCancellableCoroutine +import kotlinx.coroutines.withContext import kotlin.coroutines.CoroutineContext @Composable @@ -129,7 +133,14 @@ fun LoadOts( val noteStatus by observeNoteOts(note, accountViewModel) LaunchedEffect(key1 = noteStatus) { - val newOts = accountViewModel.findOtsEventsForNote(noteStatus?.note ?: note) + val newOts = + withContext(Dispatchers.Default) { + LocalCache.findEarliestOtsForNote( + note = noteStatus?.note ?: note, + otsVerifCache = Amethyst.instance.otsVerifCache, + ) + } + earliestDate = if (newOts == null) { GenericLoadable.Empty() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt index 0949c3190..1596e1031 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt @@ -1010,16 +1010,6 @@ class AccountViewModel( fun getAddressableNoteIfExists(key: Address): AddressableNote? = LocalCache.getAddressableNoteIfExists(key) - suspend fun findStatusesForUser(myUser: User) = - withContext(Dispatchers.IO) { - LocalCache.findStatusesForUser(myUser) - } - - suspend fun findOtsEventsForNote(note: Note) = - withContext(Dispatchers.Default) { - LocalCache.findEarliestOtsForNote(note, account.otsResolverBuilder) - } - fun cachedModificationEventsForNote(note: Note) = LocalCache.cachedModificationEventsForNote(note) suspend fun findModificationEventsForNote(note: Note): List =