Moves channels to commons and removes the dependency in the cache from Note
This commit is contained in:
@@ -1658,7 +1658,7 @@ class Account(
|
|||||||
|
|
||||||
fun isAllHidden(users: Set<HexKey>): Boolean = users.all { isHidden(it) }
|
fun isAllHidden(users: Set<HexKey>): Boolean = users.all { isHidden(it) }
|
||||||
|
|
||||||
fun isHidden(user: User) = isHidden(user.pubkeyHex)
|
override fun isHidden(user: User) = isHidden(user.pubkeyHex)
|
||||||
|
|
||||||
fun isHidden(userHex: String): Boolean = hiddenUsers.flow.value.isUserHidden(userHex)
|
fun isHidden(userHex: String): Boolean = hiddenUsers.flow.value.isUserHidden(userHex)
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ package com.vitorpamplona.amethyst.model
|
|||||||
import android.util.LruCache
|
import android.util.LruCache
|
||||||
import androidx.compose.runtime.Stable
|
import androidx.compose.runtime.Stable
|
||||||
import com.vitorpamplona.amethyst.Amethyst
|
import com.vitorpamplona.amethyst.Amethyst
|
||||||
|
import com.vitorpamplona.amethyst.commons.model.Channel
|
||||||
import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider
|
import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider
|
||||||
import com.vitorpamplona.amethyst.commons.model.cache.IChannel
|
|
||||||
import com.vitorpamplona.amethyst.isDebug
|
import com.vitorpamplona.amethyst.isDebug
|
||||||
import com.vitorpamplona.amethyst.model.emphChat.EphemeralChatChannel
|
import com.vitorpamplona.amethyst.model.emphChat.EphemeralChatChannel
|
||||||
import com.vitorpamplona.amethyst.model.nip28PublicChats.PublicChatChannel
|
import com.vitorpamplona.amethyst.model.nip28PublicChats.PublicChatChannel
|
||||||
@@ -332,17 +332,6 @@ object LocalCache : ILocalCache, ICacheProvider {
|
|||||||
return count
|
return count
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getAnyChannel(note: Any?): IChannel? {
|
|
||||||
val channelNote = note as? Note ?: return null
|
|
||||||
val channel = getAnyChannel(channelNote)
|
|
||||||
// Wrap Channel to implement IChannel interface
|
|
||||||
return channel?.let {
|
|
||||||
object : IChannel {
|
|
||||||
override fun relays(): List<Any>? = it.relays().toList()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getAddressableNoteIfExists(key: String): AddressableNote? = Address.parse(key)?.let { addressables.get(it) }
|
fun getAddressableNoteIfExists(key: String): AddressableNote? = Address.parse(key)?.let { addressables.get(it) }
|
||||||
|
|
||||||
fun getAddressableNoteIfExists(address: Address): AddressableNote? = addressables.get(address)
|
fun getAddressableNoteIfExists(address: Address): AddressableNote? = addressables.get(address)
|
||||||
@@ -1409,7 +1398,7 @@ object LocalCache : ILocalCache, ICacheProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getAnyChannel(note: Note): Channel? = note.event?.let { getAnyChannel(it) }
|
override fun getAnyChannel(note: Note): Channel? = note.event?.let { getAnyChannel(it) }
|
||||||
|
|
||||||
fun getAnyChannel(noteEvent: Event): Channel? =
|
fun getAnyChannel(noteEvent: Event): Channel? =
|
||||||
when (noteEvent) {
|
when (noteEvent) {
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@
|
|||||||
package com.vitorpamplona.amethyst.model.emphChat
|
package com.vitorpamplona.amethyst.model.emphChat
|
||||||
|
|
||||||
import androidx.compose.runtime.Stable
|
import androidx.compose.runtime.Stable
|
||||||
import com.vitorpamplona.amethyst.model.Channel
|
import com.vitorpamplona.amethyst.commons.model.Channel
|
||||||
import com.vitorpamplona.quartz.experimental.ephemChat.chat.RoomId
|
import com.vitorpamplona.quartz.experimental.ephemChat.chat.RoomId
|
||||||
|
|
||||||
@Stable
|
@Stable
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@
|
|||||||
package com.vitorpamplona.amethyst.model.nip28PublicChats
|
package com.vitorpamplona.amethyst.model.nip28PublicChats
|
||||||
|
|
||||||
import androidx.compose.runtime.Stable
|
import androidx.compose.runtime.Stable
|
||||||
import com.vitorpamplona.amethyst.model.Channel
|
import com.vitorpamplona.amethyst.commons.model.Channel
|
||||||
import com.vitorpamplona.amethyst.model.Note
|
import com.vitorpamplona.amethyst.model.Note
|
||||||
import com.vitorpamplona.amethyst.model.User
|
import com.vitorpamplona.amethyst.model.User
|
||||||
import com.vitorpamplona.amethyst.ui.note.toShortDisplay
|
import com.vitorpamplona.amethyst.ui.note.toShortDisplay
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@
|
|||||||
package com.vitorpamplona.amethyst.model.nip53LiveActivities
|
package com.vitorpamplona.amethyst.model.nip53LiveActivities
|
||||||
|
|
||||||
import androidx.compose.runtime.Stable
|
import androidx.compose.runtime.Stable
|
||||||
import com.vitorpamplona.amethyst.model.Channel
|
import com.vitorpamplona.amethyst.commons.model.Channel
|
||||||
import com.vitorpamplona.amethyst.model.Note
|
import com.vitorpamplona.amethyst.model.Note
|
||||||
import com.vitorpamplona.amethyst.model.User
|
import com.vitorpamplona.amethyst.model.User
|
||||||
import com.vitorpamplona.amethyst.ui.note.toShortDisplay
|
import com.vitorpamplona.amethyst.ui.note.toShortDisplay
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
package com.vitorpamplona.amethyst.model.privateChats
|
package com.vitorpamplona.amethyst.model.privateChats
|
||||||
|
|
||||||
import androidx.compose.runtime.Stable
|
import androidx.compose.runtime.Stable
|
||||||
import com.vitorpamplona.amethyst.model.ListChange
|
import com.vitorpamplona.amethyst.commons.model.ListChange
|
||||||
import com.vitorpamplona.amethyst.model.Note
|
import com.vitorpamplona.amethyst.model.Note
|
||||||
import com.vitorpamplona.amethyst.model.NotesGatherer
|
import com.vitorpamplona.amethyst.model.NotesGatherer
|
||||||
import com.vitorpamplona.amethyst.model.User
|
import com.vitorpamplona.amethyst.model.User
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.vitorpamplona.amethyst.service.relayClient.reqCommand.channel
|
package com.vitorpamplona.amethyst.service.relayClient.reqCommand.channel
|
||||||
|
|
||||||
import com.vitorpamplona.amethyst.model.Channel
|
import com.vitorpamplona.amethyst.commons.model.Channel
|
||||||
import com.vitorpamplona.amethyst.service.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager
|
import com.vitorpamplona.amethyst.service.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager
|
||||||
import com.vitorpamplona.amethyst.service.relayClient.reqCommand.channel.mixChatsLive.ChannelMetadataAndLiveActivityWatcherSubAssembler
|
import com.vitorpamplona.amethyst.service.relayClient.reqCommand.channel.mixChatsLive.ChannelMetadataAndLiveActivityWatcherSubAssembler
|
||||||
import com.vitorpamplona.amethyst.service.relayClient.reqCommand.channel.nip28PublicChats.ChannelLoaderSubAssembler
|
import com.vitorpamplona.amethyst.service.relayClient.reqCommand.channel.nip28PublicChats.ChannelLoaderSubAssembler
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ package com.vitorpamplona.amethyst.service.relayClient.reqCommand.channel
|
|||||||
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import com.vitorpamplona.amethyst.model.Channel
|
import com.vitorpamplona.amethyst.commons.model.Channel
|
||||||
import com.vitorpamplona.amethyst.service.relayClient.KeyDataSourceSubscription
|
import com.vitorpamplona.amethyst.service.relayClient.KeyDataSourceSubscription
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -24,8 +24,8 @@ import androidx.compose.runtime.Composable
|
|||||||
import androidx.compose.runtime.State
|
import androidx.compose.runtime.State
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import com.vitorpamplona.amethyst.model.Channel
|
import com.vitorpamplona.amethyst.commons.model.Channel
|
||||||
import com.vitorpamplona.amethyst.model.ChannelState
|
import com.vitorpamplona.amethyst.commons.model.ChannelState
|
||||||
import com.vitorpamplona.amethyst.model.User
|
import com.vitorpamplona.amethyst.model.User
|
||||||
import com.vitorpamplona.amethyst.model.nip28PublicChats.PublicChatChannel
|
import com.vitorpamplona.amethyst.model.nip28PublicChats.PublicChatChannel
|
||||||
import com.vitorpamplona.amethyst.model.nip53LiveActivities.LiveActivitiesChannel
|
import com.vitorpamplona.amethyst.model.nip53LiveActivities.LiveActivitiesChannel
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.vitorpamplona.amethyst.service.relayClient.reqCommand.channel.nip28PublicChats
|
package com.vitorpamplona.amethyst.service.relayClient.reqCommand.channel.nip28PublicChats
|
||||||
|
|
||||||
import com.vitorpamplona.amethyst.model.Channel
|
import com.vitorpamplona.amethyst.commons.model.Channel
|
||||||
import com.vitorpamplona.amethyst.model.nip28PublicChats.PublicChatChannel
|
import com.vitorpamplona.amethyst.model.nip28PublicChats.PublicChatChannel
|
||||||
import com.vitorpamplona.amethyst.service.relayClient.eoseManagers.PerUniqueIdEoseManager
|
import com.vitorpamplona.amethyst.service.relayClient.eoseManagers.PerUniqueIdEoseManager
|
||||||
import com.vitorpamplona.amethyst.service.relayClient.reqCommand.channel.ChannelFinderQueryState
|
import com.vitorpamplona.amethyst.service.relayClient.reqCommand.channel.ChannelFinderQueryState
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.vitorpamplona.amethyst.service.relayClient.reqCommand.channel.nip53LiveActivities
|
package com.vitorpamplona.amethyst.service.relayClient.reqCommand.channel.nip53LiveActivities
|
||||||
|
|
||||||
import com.vitorpamplona.amethyst.model.Channel
|
import com.vitorpamplona.amethyst.commons.model.Channel
|
||||||
import com.vitorpamplona.amethyst.model.nip53LiveActivities.LiveActivitiesChannel
|
import com.vitorpamplona.amethyst.model.nip53LiveActivities.LiveActivitiesChannel
|
||||||
import com.vitorpamplona.amethyst.service.relayClient.eoseManagers.PerUniqueIdEoseManager
|
import com.vitorpamplona.amethyst.service.relayClient.eoseManagers.PerUniqueIdEoseManager
|
||||||
import com.vitorpamplona.amethyst.service.relayClient.reqCommand.channel.ChannelFinderQueryState
|
import com.vitorpamplona.amethyst.service.relayClient.reqCommand.channel.ChannelFinderQueryState
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.vitorpamplona.amethyst.ui.dal
|
package com.vitorpamplona.amethyst.ui.dal
|
||||||
|
|
||||||
import com.vitorpamplona.amethyst.model.ListChange
|
import com.vitorpamplona.amethyst.commons.model.ListChange
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||||
|
|
||||||
interface ChangesFlowFilter<T> : IAdditiveFeedFilter<T> {
|
interface ChangesFlowFilter<T> : IAdditiveFeedFilter<T> {
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ package com.vitorpamplona.amethyst.ui.feeds
|
|||||||
import androidx.compose.runtime.MutableState
|
import androidx.compose.runtime.MutableState
|
||||||
import androidx.compose.runtime.Stable
|
import androidx.compose.runtime.Stable
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import com.vitorpamplona.amethyst.model.Channel
|
import com.vitorpamplona.amethyst.commons.model.Channel
|
||||||
import com.vitorpamplona.amethyst.model.Note
|
import com.vitorpamplona.amethyst.model.Note
|
||||||
import com.vitorpamplona.amethyst.service.BundledInsert
|
import com.vitorpamplona.amethyst.service.BundledInsert
|
||||||
import com.vitorpamplona.amethyst.service.BundledUpdate
|
import com.vitorpamplona.amethyst.service.BundledUpdate
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
package com.vitorpamplona.amethyst.ui.feeds
|
package com.vitorpamplona.amethyst.ui.feeds
|
||||||
|
|
||||||
import androidx.compose.runtime.Stable
|
import androidx.compose.runtime.Stable
|
||||||
import com.vitorpamplona.amethyst.model.Channel
|
import com.vitorpamplona.amethyst.commons.model.Channel
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
|
|
||||||
@Stable
|
@Stable
|
||||||
|
|||||||
+1
-1
@@ -24,10 +24,10 @@ import androidx.compose.runtime.Stable
|
|||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import com.vitorpamplona.amethyst.commons.model.ListChange
|
||||||
import com.vitorpamplona.amethyst.commons.ui.feeds.FeedContentState
|
import com.vitorpamplona.amethyst.commons.ui.feeds.FeedContentState
|
||||||
import com.vitorpamplona.amethyst.commons.ui.feeds.InvalidatableContent
|
import com.vitorpamplona.amethyst.commons.ui.feeds.InvalidatableContent
|
||||||
import com.vitorpamplona.amethyst.model.Account
|
import com.vitorpamplona.amethyst.model.Account
|
||||||
import com.vitorpamplona.amethyst.model.ListChange
|
|
||||||
import com.vitorpamplona.amethyst.model.LocalCache
|
import com.vitorpamplona.amethyst.model.LocalCache
|
||||||
import com.vitorpamplona.amethyst.model.Note
|
import com.vitorpamplona.amethyst.model.Note
|
||||||
import com.vitorpamplona.amethyst.ui.dal.ChangesFlowFilter
|
import com.vitorpamplona.amethyst.ui.dal.ChangesFlowFilter
|
||||||
|
|||||||
+1
-1
@@ -20,8 +20,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.dal
|
package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.dal
|
||||||
|
|
||||||
|
import com.vitorpamplona.amethyst.commons.model.Channel
|
||||||
import com.vitorpamplona.amethyst.model.Account
|
import com.vitorpamplona.amethyst.model.Account
|
||||||
import com.vitorpamplona.amethyst.model.Channel
|
|
||||||
import com.vitorpamplona.amethyst.model.Note
|
import com.vitorpamplona.amethyst.model.Note
|
||||||
import com.vitorpamplona.amethyst.ui.dal.AdditiveFeedFilter
|
import com.vitorpamplona.amethyst.ui.dal.AdditiveFeedFilter
|
||||||
import com.vitorpamplona.amethyst.ui.dal.ChangesFlowFilter
|
import com.vitorpamplona.amethyst.ui.dal.ChangesFlowFilter
|
||||||
|
|||||||
+1
-1
@@ -22,8 +22,8 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.dal
|
|||||||
|
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
|
import com.vitorpamplona.amethyst.commons.model.Channel
|
||||||
import com.vitorpamplona.amethyst.model.Account
|
import com.vitorpamplona.amethyst.model.Account
|
||||||
import com.vitorpamplona.amethyst.model.Channel
|
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.privateDM.dal.ListChangeFeedViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.privateDM.dal.ListChangeFeedViewModel
|
||||||
|
|
||||||
class ChannelFeedViewModel(
|
class ChannelFeedViewModel(
|
||||||
|
|||||||
+1
-1
@@ -20,8 +20,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.datasource
|
package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.datasource
|
||||||
|
|
||||||
|
import com.vitorpamplona.amethyst.commons.model.Channel
|
||||||
import com.vitorpamplona.amethyst.model.Account
|
import com.vitorpamplona.amethyst.model.Account
|
||||||
import com.vitorpamplona.amethyst.model.Channel
|
|
||||||
import com.vitorpamplona.amethyst.service.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager
|
import com.vitorpamplona.amethyst.service.relayClient.composeSubscriptionManagers.ComposeSubscriptionManager
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.datasource.subassemblies.ChannelFromUserFilterSubAssembler
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.datasource.subassemblies.ChannelFromUserFilterSubAssembler
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.datasource.subassemblies.ChannelPublicFilterSubAssembler
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.datasource.subassemblies.ChannelPublicFilterSubAssembler
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.datas
|
|||||||
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import com.vitorpamplona.amethyst.model.Channel
|
import com.vitorpamplona.amethyst.commons.model.Channel
|
||||||
import com.vitorpamplona.amethyst.service.relayClient.KeyDataSourceSubscription
|
import com.vitorpamplona.amethyst.service.relayClient.KeyDataSourceSubscription
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.datasource.subassemblies
|
package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.datasource.subassemblies
|
||||||
|
|
||||||
import com.vitorpamplona.amethyst.model.Channel
|
import com.vitorpamplona.amethyst.commons.model.Channel
|
||||||
import com.vitorpamplona.amethyst.model.emphChat.EphemeralChatChannel
|
import com.vitorpamplona.amethyst.model.emphChat.EphemeralChatChannel
|
||||||
import com.vitorpamplona.amethyst.model.nip28PublicChats.PublicChatChannel
|
import com.vitorpamplona.amethyst.model.nip28PublicChats.PublicChatChannel
|
||||||
import com.vitorpamplona.amethyst.model.nip53LiveActivities.LiveActivitiesChannel
|
import com.vitorpamplona.amethyst.model.nip53LiveActivities.LiveActivitiesChannel
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.datasource.subassemblies
|
package com.vitorpamplona.amethyst.ui.screen.loggedIn.chats.publicChannels.datasource.subassemblies
|
||||||
|
|
||||||
import com.vitorpamplona.amethyst.model.Channel
|
import com.vitorpamplona.amethyst.commons.model.Channel
|
||||||
import com.vitorpamplona.amethyst.model.emphChat.EphemeralChatChannel
|
import com.vitorpamplona.amethyst.model.emphChat.EphemeralChatChannel
|
||||||
import com.vitorpamplona.amethyst.model.nip28PublicChats.PublicChatChannel
|
import com.vitorpamplona.amethyst.model.nip28PublicChats.PublicChatChannel
|
||||||
import com.vitorpamplona.amethyst.model.nip53LiveActivities.LiveActivitiesChannel
|
import com.vitorpamplona.amethyst.model.nip53LiveActivities.LiveActivitiesChannel
|
||||||
|
|||||||
+1
-1
@@ -33,9 +33,9 @@ import com.vitorpamplona.amethyst.R
|
|||||||
import com.vitorpamplona.amethyst.commons.compose.currentWord
|
import com.vitorpamplona.amethyst.commons.compose.currentWord
|
||||||
import com.vitorpamplona.amethyst.commons.compose.insertUrlAtCursor
|
import com.vitorpamplona.amethyst.commons.compose.insertUrlAtCursor
|
||||||
import com.vitorpamplona.amethyst.commons.compose.replaceCurrentWord
|
import com.vitorpamplona.amethyst.commons.compose.replaceCurrentWord
|
||||||
|
import com.vitorpamplona.amethyst.commons.model.Channel
|
||||||
import com.vitorpamplona.amethyst.commons.richtext.RichTextParser
|
import com.vitorpamplona.amethyst.commons.richtext.RichTextParser
|
||||||
import com.vitorpamplona.amethyst.model.Account
|
import com.vitorpamplona.amethyst.model.Account
|
||||||
import com.vitorpamplona.amethyst.model.Channel
|
|
||||||
import com.vitorpamplona.amethyst.model.LocalCache
|
import com.vitorpamplona.amethyst.model.LocalCache
|
||||||
import com.vitorpamplona.amethyst.model.Note
|
import com.vitorpamplona.amethyst.model.Note
|
||||||
import com.vitorpamplona.amethyst.model.User
|
import com.vitorpamplona.amethyst.model.User
|
||||||
|
|||||||
+1
-1
@@ -20,8 +20,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.vitorpamplona.amethyst.ui.screen.loggedIn.home.dal
|
package com.vitorpamplona.amethyst.ui.screen.loggedIn.home.dal
|
||||||
|
|
||||||
|
import com.vitorpamplona.amethyst.commons.model.Channel
|
||||||
import com.vitorpamplona.amethyst.model.Account
|
import com.vitorpamplona.amethyst.model.Account
|
||||||
import com.vitorpamplona.amethyst.model.Channel
|
|
||||||
import com.vitorpamplona.amethyst.model.LocalCache
|
import com.vitorpamplona.amethyst.model.LocalCache
|
||||||
import com.vitorpamplona.amethyst.model.Note
|
import com.vitorpamplona.amethyst.model.Note
|
||||||
import com.vitorpamplona.amethyst.model.emphChat.EphemeralChatChannel
|
import com.vitorpamplona.amethyst.model.emphChat.EphemeralChatChannel
|
||||||
|
|||||||
+1
-1
@@ -29,7 +29,7 @@ import androidx.compose.runtime.produceState
|
|||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.vitorpamplona.amethyst.model.Channel
|
import com.vitorpamplona.amethyst.commons.model.Channel
|
||||||
import com.vitorpamplona.amethyst.model.emphChat.EphemeralChatChannel
|
import com.vitorpamplona.amethyst.model.emphChat.EphemeralChatChannel
|
||||||
import com.vitorpamplona.amethyst.model.nip53LiveActivities.LiveActivitiesChannel
|
import com.vitorpamplona.amethyst.model.nip53LiveActivities.LiveActivitiesChannel
|
||||||
import com.vitorpamplona.amethyst.service.OnlineChecker
|
import com.vitorpamplona.amethyst.service.OnlineChecker
|
||||||
|
|||||||
+7
-3
@@ -18,10 +18,9 @@
|
|||||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
package com.vitorpamplona.amethyst.model
|
package com.vitorpamplona.amethyst.commons.model
|
||||||
|
|
||||||
import androidx.compose.runtime.Stable
|
import androidx.compose.runtime.Stable
|
||||||
import com.vitorpamplona.amethyst.ui.dal.DefaultFeedOrder
|
|
||||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||||
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
|
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
|
||||||
import com.vitorpamplona.quartz.utils.cache.LargeCache
|
import com.vitorpamplona.quartz.utils.cache.LargeCache
|
||||||
@@ -32,6 +31,11 @@ import java.lang.ref.WeakReference
|
|||||||
|
|
||||||
@Stable
|
@Stable
|
||||||
abstract class Channel : NotesGatherer {
|
abstract class Channel : NotesGatherer {
|
||||||
|
companion object {
|
||||||
|
val DefaultFeedOrder: Comparator<Note> =
|
||||||
|
compareByDescending<Note> { it.createdAt() }.thenBy { it.idHex }
|
||||||
|
}
|
||||||
|
|
||||||
val notes = LargeCache<HexKey, Note>()
|
val notes = LargeCache<HexKey, Note>()
|
||||||
var lastNote: Note? = null
|
var lastNote: Note? = null
|
||||||
|
|
||||||
@@ -143,7 +147,7 @@ abstract class Channel : NotesGatherer {
|
|||||||
return toBeRemoved.toSet()
|
return toBeRemoved.toSet()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun pruneHiddenMessages(account: Account): Set<Note> {
|
fun pruneHiddenMessages(account: IAccount): Set<Note> {
|
||||||
val hidden =
|
val hidden =
|
||||||
notes
|
notes
|
||||||
.filter { key, it ->
|
.filter { key, it ->
|
||||||
@@ -84,4 +84,6 @@ interface IAccount {
|
|||||||
|
|
||||||
/** Set of followed user pubkeys (for feed ordering/highlighting) */
|
/** Set of followed user pubkeys (for feed ordering/highlighting) */
|
||||||
fun followingKeySet(): Set<String>
|
fun followingKeySet(): Set<String>
|
||||||
|
|
||||||
|
fun isHidden(user: User): Boolean
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@
|
|||||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
package com.vitorpamplona.amethyst.model
|
package com.vitorpamplona.amethyst.commons.model
|
||||||
|
|
||||||
sealed class ListChange<out T> {
|
sealed class ListChange<out T> {
|
||||||
data class Addition<T>(
|
data class Addition<T>(
|
||||||
@@ -22,13 +22,13 @@ package com.vitorpamplona.amethyst.commons.model
|
|||||||
|
|
||||||
import androidx.compose.runtime.Immutable
|
import androidx.compose.runtime.Immutable
|
||||||
import androidx.compose.runtime.Stable
|
import androidx.compose.runtime.Stable
|
||||||
import com.vitorpamplona.amethyst.commons.model.cache.ICacheProvider
|
|
||||||
import com.vitorpamplona.amethyst.commons.threading.checkNotInMainThread
|
import com.vitorpamplona.amethyst.commons.threading.checkNotInMainThread
|
||||||
import com.vitorpamplona.amethyst.commons.util.firstFullCharOrEmoji
|
import com.vitorpamplona.amethyst.commons.util.firstFullCharOrEmoji
|
||||||
import com.vitorpamplona.amethyst.commons.util.replace
|
import com.vitorpamplona.amethyst.commons.util.replace
|
||||||
import com.vitorpamplona.amethyst.commons.util.toShortDisplay
|
import com.vitorpamplona.amethyst.commons.util.toShortDisplay
|
||||||
import com.vitorpamplona.quartz.experimental.bounties.addedRewardValue
|
import com.vitorpamplona.quartz.experimental.bounties.addedRewardValue
|
||||||
import com.vitorpamplona.quartz.experimental.bounties.hasAdditionalReward
|
import com.vitorpamplona.quartz.experimental.bounties.hasAdditionalReward
|
||||||
|
import com.vitorpamplona.quartz.experimental.ephemChat.chat.EphemeralChatEvent
|
||||||
import com.vitorpamplona.quartz.lightning.LnInvoiceUtil
|
import com.vitorpamplona.quartz.lightning.LnInvoiceUtil
|
||||||
import com.vitorpamplona.quartz.nip01Core.core.Address
|
import com.vitorpamplona.quartz.nip01Core.core.Address
|
||||||
import com.vitorpamplona.quartz.nip01Core.core.Event
|
import com.vitorpamplona.quartz.nip01Core.core.Event
|
||||||
@@ -57,6 +57,7 @@ import com.vitorpamplona.quartz.nip47WalletConnect.LnZapPaymentResponseEvent
|
|||||||
import com.vitorpamplona.quartz.nip47WalletConnect.PayInvoiceMethod
|
import com.vitorpamplona.quartz.nip47WalletConnect.PayInvoiceMethod
|
||||||
import com.vitorpamplona.quartz.nip47WalletConnect.PayInvoiceSuccessResponse
|
import com.vitorpamplona.quartz.nip47WalletConnect.PayInvoiceSuccessResponse
|
||||||
import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent
|
import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent
|
||||||
|
import com.vitorpamplona.quartz.nip53LiveActivities.streaming.LiveActivitiesEvent
|
||||||
import com.vitorpamplona.quartz.nip56Reports.ReportEvent
|
import com.vitorpamplona.quartz.nip56Reports.ReportEvent
|
||||||
import com.vitorpamplona.quartz.nip56Reports.ReportType
|
import com.vitorpamplona.quartz.nip56Reports.ReportType
|
||||||
import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent
|
import com.vitorpamplona.quartz.nip57Zaps.LnZapEvent
|
||||||
@@ -109,7 +110,6 @@ class AddressableNote(
|
|||||||
@Stable
|
@Stable
|
||||||
open class Note(
|
open class Note(
|
||||||
val idHex: String,
|
val idHex: String,
|
||||||
private val cacheProvider: ICacheProvider? = null,
|
|
||||||
) : NotesGatherer {
|
) : NotesGatherer {
|
||||||
// These fields are only available after the Text Note event is received.
|
// These fields are only available after the Text Note event is received.
|
||||||
// They are immutable after that.
|
// They are immutable after that.
|
||||||
@@ -196,15 +196,28 @@ open class Note(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun relayHintUrl(): NormalizedRelayUrl? {
|
fun relayHintUrl(): NormalizedRelayUrl? {
|
||||||
val noteEvent = event
|
// checks Community Events first
|
||||||
val communityPostRelays =
|
when (val noteEvent = event) {
|
||||||
when (noteEvent) {
|
is CommunityDefinitionEvent -> noteEvent.relayUrls().firstOrNull()?.let { return it }
|
||||||
is CommunityDefinitionEvent -> noteEvent.relayUrls().ifEmpty { null }?.toSet()
|
is IsInPublicChatChannel -> {
|
||||||
is IsInPublicChatChannel -> cacheProvider?.getAnyChannel(this)?.relays()
|
inGatherers?.forEach {
|
||||||
else -> null
|
if (it is com.vitorpamplona.amethyst.commons.model.Channel) {
|
||||||
|
it.relays().firstOrNull()?.let { return it }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
is LiveActivitiesEvent -> {
|
||||||
if (!communityPostRelays.isNullOrEmpty()) return (communityPostRelays as? Collection<NormalizedRelayUrl?>)?.firstOrNull()
|
noteEvent.relays().ifEmpty { null }?.toSet()
|
||||||
|
}
|
||||||
|
is LiveActivitiesChatMessageEvent -> {
|
||||||
|
inGatherers?.forEach {
|
||||||
|
if (it is com.vitorpamplona.amethyst.commons.model.Channel) {
|
||||||
|
it.relays().firstOrNull()?.let { return it }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is EphemeralChatEvent -> noteEvent.roomId()?.let { return it.relayUrl }
|
||||||
|
}
|
||||||
|
|
||||||
val currentOutbox = author?.outboxRelays()?.toSet()
|
val currentOutbox = author?.outboxRelays()?.toSet()
|
||||||
|
|
||||||
|
|||||||
Vendored
+3
-14
@@ -20,6 +20,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.vitorpamplona.amethyst.commons.model.cache
|
package com.vitorpamplona.amethyst.commons.model.cache
|
||||||
|
|
||||||
|
import com.vitorpamplona.amethyst.commons.model.Channel
|
||||||
|
import com.vitorpamplona.amethyst.commons.model.Note
|
||||||
import com.vitorpamplona.amethyst.commons.model.User
|
import com.vitorpamplona.amethyst.commons.model.User
|
||||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||||
|
|
||||||
@@ -43,7 +45,7 @@ interface ICacheProvider {
|
|||||||
* @param note The note to look up channel for
|
* @param note The note to look up channel for
|
||||||
* @return The channel if found, null otherwise
|
* @return The channel if found, null otherwise
|
||||||
*/
|
*/
|
||||||
fun getAnyChannel(note: Any?): IChannel?
|
fun getAnyChannel(note: Note): Channel?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a User by public key hex.
|
* Gets a User by public key hex.
|
||||||
@@ -98,16 +100,3 @@ interface ICacheProvider {
|
|||||||
*/
|
*/
|
||||||
fun hasBeenDeleted(event: Any): Boolean
|
fun hasBeenDeleted(event: Any): Boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Minimal channel interface for relay resolution.
|
|
||||||
* Full channel implementations (PublicChatChannel, LiveActivitiesChannel)
|
|
||||||
* implement this interface.
|
|
||||||
*/
|
|
||||||
interface IChannel {
|
|
||||||
/**
|
|
||||||
* Gets the relay URLs for this channel.
|
|
||||||
* @return List of relay URLs or null if none configured
|
|
||||||
*/
|
|
||||||
fun relays(): List<Any>?
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user