Moves away from calling relay feeds "favorites"
This commit is contained in:
@@ -53,8 +53,8 @@ import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListEvent
|
|||||||
import com.vitorpamplona.quartz.nip51Lists.hashtagList.HashtagListEvent
|
import com.vitorpamplona.quartz.nip51Lists.hashtagList.HashtagListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent
|
import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent
|
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent
|
||||||
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayFeedsListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent
|
import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip72ModCommunities.follow.CommunityListEvent
|
import com.vitorpamplona.quartz.nip72ModCommunities.follow.CommunityListEvent
|
||||||
@@ -102,7 +102,7 @@ private object PrefKeys {
|
|||||||
const val LATEST_NIP65_RELAY_LIST = "latestNIP65RelayList"
|
const val LATEST_NIP65_RELAY_LIST = "latestNIP65RelayList"
|
||||||
const val LATEST_SEARCH_RELAY_LIST = "latestSearchRelayList"
|
const val LATEST_SEARCH_RELAY_LIST = "latestSearchRelayList"
|
||||||
const val LATEST_INDEX_RELAY_LIST = "latestIndexRelayList"
|
const val LATEST_INDEX_RELAY_LIST = "latestIndexRelayList"
|
||||||
const val LATEST_FAVORITE_RELAY_LIST = "latestFavoriteRelayList"
|
const val LATEST_RELAY_FEEDS_LIST = "latestRelayFeedsList"
|
||||||
const val LATEST_BLOCKED_RELAY_LIST = "latestBlockedRelayList"
|
const val LATEST_BLOCKED_RELAY_LIST = "latestBlockedRelayList"
|
||||||
const val LATEST_TRUSTED_RELAY_LIST = "latestTrustedRelayList"
|
const val LATEST_TRUSTED_RELAY_LIST = "latestTrustedRelayList"
|
||||||
const val LATEST_MUTE_LIST = "latestMuteList"
|
const val LATEST_MUTE_LIST = "latestMuteList"
|
||||||
@@ -336,7 +336,7 @@ object LocalPreferences {
|
|||||||
putOrRemove(PrefKeys.LATEST_NIP65_RELAY_LIST, settings.backupNIP65RelayList)
|
putOrRemove(PrefKeys.LATEST_NIP65_RELAY_LIST, settings.backupNIP65RelayList)
|
||||||
putOrRemove(PrefKeys.LATEST_SEARCH_RELAY_LIST, settings.backupSearchRelayList)
|
putOrRemove(PrefKeys.LATEST_SEARCH_RELAY_LIST, settings.backupSearchRelayList)
|
||||||
putOrRemove(PrefKeys.LATEST_INDEX_RELAY_LIST, settings.backupIndexRelayList)
|
putOrRemove(PrefKeys.LATEST_INDEX_RELAY_LIST, settings.backupIndexRelayList)
|
||||||
putOrRemove(PrefKeys.LATEST_FAVORITE_RELAY_LIST, settings.backupIndexRelayList)
|
putOrRemove(PrefKeys.LATEST_RELAY_FEEDS_LIST, settings.backupIndexRelayList)
|
||||||
putOrRemove(PrefKeys.LATEST_BLOCKED_RELAY_LIST, settings.backupBlockedRelayList)
|
putOrRemove(PrefKeys.LATEST_BLOCKED_RELAY_LIST, settings.backupBlockedRelayList)
|
||||||
putOrRemove(PrefKeys.LATEST_TRUSTED_RELAY_LIST, settings.backupTrustedRelayList)
|
putOrRemove(PrefKeys.LATEST_TRUSTED_RELAY_LIST, settings.backupTrustedRelayList)
|
||||||
|
|
||||||
@@ -471,7 +471,7 @@ object LocalPreferences {
|
|||||||
val latestNip65RelayList = parseEventOrNull<AdvertisedRelayListEvent>(PrefKeys.LATEST_NIP65_RELAY_LIST)
|
val latestNip65RelayList = parseEventOrNull<AdvertisedRelayListEvent>(PrefKeys.LATEST_NIP65_RELAY_LIST)
|
||||||
val latestSearchRelayList = parseEventOrNull<SearchRelayListEvent>(PrefKeys.LATEST_SEARCH_RELAY_LIST)
|
val latestSearchRelayList = parseEventOrNull<SearchRelayListEvent>(PrefKeys.LATEST_SEARCH_RELAY_LIST)
|
||||||
val latestIndexRelayList = parseEventOrNull<IndexerRelayListEvent>(PrefKeys.LATEST_INDEX_RELAY_LIST)
|
val latestIndexRelayList = parseEventOrNull<IndexerRelayListEvent>(PrefKeys.LATEST_INDEX_RELAY_LIST)
|
||||||
val latestFavoriteRelayList = parseEventOrNull<FavoriteRelayListEvent>(PrefKeys.LATEST_FAVORITE_RELAY_LIST)
|
val latestRelayFeedsList = parseEventOrNull<RelayFeedsListEvent>(PrefKeys.LATEST_RELAY_FEEDS_LIST)
|
||||||
val latestBlockedRelayList = parseEventOrNull<BlockedRelayListEvent>(PrefKeys.LATEST_BLOCKED_RELAY_LIST)
|
val latestBlockedRelayList = parseEventOrNull<BlockedRelayListEvent>(PrefKeys.LATEST_BLOCKED_RELAY_LIST)
|
||||||
val latestTrustedRelayList = parseEventOrNull<TrustedRelayListEvent>(PrefKeys.LATEST_TRUSTED_RELAY_LIST)
|
val latestTrustedRelayList = parseEventOrNull<TrustedRelayListEvent>(PrefKeys.LATEST_TRUSTED_RELAY_LIST)
|
||||||
val latestMuteList = parseEventOrNull<MuteListEvent>(PrefKeys.LATEST_MUTE_LIST)
|
val latestMuteList = parseEventOrNull<MuteListEvent>(PrefKeys.LATEST_MUTE_LIST)
|
||||||
@@ -517,7 +517,7 @@ object LocalPreferences {
|
|||||||
backupDMRelayList = latestDmRelayList,
|
backupDMRelayList = latestDmRelayList,
|
||||||
backupSearchRelayList = latestSearchRelayList,
|
backupSearchRelayList = latestSearchRelayList,
|
||||||
backupIndexRelayList = latestIndexRelayList,
|
backupIndexRelayList = latestIndexRelayList,
|
||||||
backupFavoriteRelayList = latestFavoriteRelayList,
|
backupRelayFeedsList = latestRelayFeedsList,
|
||||||
backupBlockedRelayList = latestBlockedRelayList,
|
backupBlockedRelayList = latestBlockedRelayList,
|
||||||
backupTrustedRelayList = latestTrustedRelayList,
|
backupTrustedRelayList = latestTrustedRelayList,
|
||||||
backupPrivateHomeRelayList = latestPrivateHomeRelayList,
|
backupPrivateHomeRelayList = latestPrivateHomeRelayList,
|
||||||
|
|||||||
@@ -61,8 +61,6 @@ import com.vitorpamplona.amethyst.model.nip51Lists.blockedRelays.BlockedRelayLis
|
|||||||
import com.vitorpamplona.amethyst.model.nip51Lists.blockedRelays.BlockedRelayListState
|
import com.vitorpamplona.amethyst.model.nip51Lists.blockedRelays.BlockedRelayListState
|
||||||
import com.vitorpamplona.amethyst.model.nip51Lists.broadcastRelays.BroadcastRelayListDecryptionCache
|
import com.vitorpamplona.amethyst.model.nip51Lists.broadcastRelays.BroadcastRelayListDecryptionCache
|
||||||
import com.vitorpamplona.amethyst.model.nip51Lists.broadcastRelays.BroadcastRelayListState
|
import com.vitorpamplona.amethyst.model.nip51Lists.broadcastRelays.BroadcastRelayListState
|
||||||
import com.vitorpamplona.amethyst.model.nip51Lists.favoriteRelays.FavoriteRelayListDecryptionCache
|
|
||||||
import com.vitorpamplona.amethyst.model.nip51Lists.favoriteRelays.FavoriteRelayListState
|
|
||||||
import com.vitorpamplona.amethyst.model.nip51Lists.geohashLists.GeohashListDecryptionCache
|
import com.vitorpamplona.amethyst.model.nip51Lists.geohashLists.GeohashListDecryptionCache
|
||||||
import com.vitorpamplona.amethyst.model.nip51Lists.geohashLists.GeohashListState
|
import com.vitorpamplona.amethyst.model.nip51Lists.geohashLists.GeohashListState
|
||||||
import com.vitorpamplona.amethyst.model.nip51Lists.hashtagLists.HashtagListDecryptionCache
|
import com.vitorpamplona.amethyst.model.nip51Lists.hashtagLists.HashtagListDecryptionCache
|
||||||
@@ -77,6 +75,8 @@ import com.vitorpamplona.amethyst.model.nip51Lists.peopleList.PeopleListDecrypti
|
|||||||
import com.vitorpamplona.amethyst.model.nip51Lists.peopleList.PeopleListsState
|
import com.vitorpamplona.amethyst.model.nip51Lists.peopleList.PeopleListsState
|
||||||
import com.vitorpamplona.amethyst.model.nip51Lists.proxyRelays.ProxyRelayListDecryptionCache
|
import com.vitorpamplona.amethyst.model.nip51Lists.proxyRelays.ProxyRelayListDecryptionCache
|
||||||
import com.vitorpamplona.amethyst.model.nip51Lists.proxyRelays.ProxyRelayListState
|
import com.vitorpamplona.amethyst.model.nip51Lists.proxyRelays.ProxyRelayListState
|
||||||
|
import com.vitorpamplona.amethyst.model.nip51Lists.relayFeeds.RelayFeedListState
|
||||||
|
import com.vitorpamplona.amethyst.model.nip51Lists.relayFeeds.RelayFeedsListDecryptionCache
|
||||||
import com.vitorpamplona.amethyst.model.nip51Lists.searchRelays.SearchRelayListDecryptionCache
|
import com.vitorpamplona.amethyst.model.nip51Lists.searchRelays.SearchRelayListDecryptionCache
|
||||||
import com.vitorpamplona.amethyst.model.nip51Lists.searchRelays.SearchRelayListState
|
import com.vitorpamplona.amethyst.model.nip51Lists.searchRelays.SearchRelayListState
|
||||||
import com.vitorpamplona.amethyst.model.nip51Lists.trustedRelays.TrustedRelayListDecryptionCache
|
import com.vitorpamplona.amethyst.model.nip51Lists.trustedRelays.TrustedRelayListDecryptionCache
|
||||||
@@ -278,8 +278,8 @@ class Account(
|
|||||||
val indexerRelayListDecryptionCache = IndexerRelayListDecryptionCache(signer)
|
val indexerRelayListDecryptionCache = IndexerRelayListDecryptionCache(signer)
|
||||||
val indexerRelayList = IndexerRelayListState(signer, cache, indexerRelayListDecryptionCache, scope, settings)
|
val indexerRelayList = IndexerRelayListState(signer, cache, indexerRelayListDecryptionCache, scope, settings)
|
||||||
|
|
||||||
val favoriteRelayListDecryptionCache = FavoriteRelayListDecryptionCache(signer)
|
val relayFeedsListDecryptionCache = RelayFeedsListDecryptionCache(signer)
|
||||||
val favoriteRelayList = FavoriteRelayListState(signer, cache, favoriteRelayListDecryptionCache, scope, settings)
|
val relayFeedsList = RelayFeedListState(signer, cache, relayFeedsListDecryptionCache, scope, settings)
|
||||||
|
|
||||||
val blockedRelayListDecryptionCache = BlockedRelayListDecryptionCache(signer)
|
val blockedRelayListDecryptionCache = BlockedRelayListDecryptionCache(signer)
|
||||||
val blockedRelayList = BlockedRelayListState(signer, cache, blockedRelayListDecryptionCache, scope, settings)
|
val blockedRelayList = BlockedRelayListState(signer, cache, blockedRelayListDecryptionCache, scope, settings)
|
||||||
@@ -1926,11 +1926,11 @@ class Account(
|
|||||||
|
|
||||||
suspend fun saveTrustedRelayList(trustedRelays: List<NormalizedRelayUrl>) = sendMyPublicAndPrivateOutbox(trustedRelayList.saveRelayList(trustedRelays))
|
suspend fun saveTrustedRelayList(trustedRelays: List<NormalizedRelayUrl>) = sendMyPublicAndPrivateOutbox(trustedRelayList.saveRelayList(trustedRelays))
|
||||||
|
|
||||||
suspend fun saveFavoriteRelayList(trustedRelays: List<NormalizedRelayUrl>) = sendMyPublicAndPrivateOutbox(favoriteRelayList.saveRelayList(trustedRelays))
|
suspend fun saveRelayFeedsList(trustedRelays: List<NormalizedRelayUrl>) = sendMyPublicAndPrivateOutbox(relayFeedsList.saveRelayList(trustedRelays))
|
||||||
|
|
||||||
suspend fun followFavoriteRelay(url: NormalizedRelayUrl) = sendMyPublicAndPrivateOutbox(favoriteRelayList.addRelay(url))
|
suspend fun followRelayFeed(url: NormalizedRelayUrl) = sendMyPublicAndPrivateOutbox(relayFeedsList.addRelay(url))
|
||||||
|
|
||||||
suspend fun unfollowFavoriteRelay(url: NormalizedRelayUrl) = sendMyPublicAndPrivateOutbox(favoriteRelayList.removeRelay(url))
|
suspend fun unfollowRelayFeed(url: NormalizedRelayUrl) = sendMyPublicAndPrivateOutbox(relayFeedsList.removeRelay(url))
|
||||||
|
|
||||||
suspend fun saveBlockedRelayList(blockedRelays: List<NormalizedRelayUrl>) = sendMyPublicAndPrivateOutbox(blockedRelayList.saveRelayList(blockedRelays))
|
suspend fun saveBlockedRelayList(blockedRelays: List<NormalizedRelayUrl>) = sendMyPublicAndPrivateOutbox(blockedRelayList.saveRelayList(blockedRelays))
|
||||||
|
|
||||||
|
|||||||
@@ -46,8 +46,8 @@ import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListEvent
|
|||||||
import com.vitorpamplona.quartz.nip51Lists.hashtagList.HashtagListEvent
|
import com.vitorpamplona.quartz.nip51Lists.hashtagList.HashtagListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent
|
import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent
|
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent
|
||||||
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayFeedsListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip55AndroidSigner.api.CommandType
|
import com.vitorpamplona.quartz.nip55AndroidSigner.api.CommandType
|
||||||
import com.vitorpamplona.quartz.nip55AndroidSigner.api.permission.Permission
|
import com.vitorpamplona.quartz.nip55AndroidSigner.api.permission.Permission
|
||||||
@@ -175,7 +175,7 @@ class AccountSettings(
|
|||||||
var backupNIP65RelayList: AdvertisedRelayListEvent? = null,
|
var backupNIP65RelayList: AdvertisedRelayListEvent? = null,
|
||||||
var backupSearchRelayList: SearchRelayListEvent? = null,
|
var backupSearchRelayList: SearchRelayListEvent? = null,
|
||||||
var backupIndexRelayList: IndexerRelayListEvent? = null,
|
var backupIndexRelayList: IndexerRelayListEvent? = null,
|
||||||
var backupFavoriteRelayList: FavoriteRelayListEvent? = null,
|
var backupRelayFeedsList: RelayFeedsListEvent? = null,
|
||||||
var backupBlockedRelayList: BlockedRelayListEvent? = null,
|
var backupBlockedRelayList: BlockedRelayListEvent? = null,
|
||||||
var backupTrustedRelayList: TrustedRelayListEvent? = null,
|
var backupTrustedRelayList: TrustedRelayListEvent? = null,
|
||||||
var backupMuteList: MuteListEvent? = null,
|
var backupMuteList: MuteListEvent? = null,
|
||||||
@@ -427,12 +427,12 @@ class AccountSettings(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateFavoriteRelayList(newFavoriteRelayList: FavoriteRelayListEvent?) {
|
fun updateRelayFeedList(newRelayFeedList: RelayFeedsListEvent?) {
|
||||||
if (newFavoriteRelayList == null || newFavoriteRelayList.tags.isEmpty()) return
|
if (newRelayFeedList == null || newRelayFeedList.tags.isEmpty()) return
|
||||||
|
|
||||||
// Events might be different objects, we have to compare their ids.
|
// Events might be different objects, we have to compare their ids.
|
||||||
if (backupFavoriteRelayList?.id != newFavoriteRelayList.id) {
|
if (backupRelayFeedsList?.id != newRelayFeedList.id) {
|
||||||
backupFavoriteRelayList = newFavoriteRelayList
|
backupRelayFeedsList = newRelayFeedList
|
||||||
saveAccountSettings()
|
saveAccountSettings()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,9 +148,9 @@ import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent
|
|||||||
import com.vitorpamplona.quartz.nip51Lists.peopleList.PeopleListEvent
|
import com.vitorpamplona.quartz.nip51Lists.peopleList.PeopleListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.BroadcastRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.BroadcastRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent
|
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.ProxyRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.ProxyRelayListEvent
|
||||||
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayFeedsListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relaySets.RelaySetEvent
|
import com.vitorpamplona.quartz.nip51Lists.relaySets.RelaySetEvent
|
||||||
import com.vitorpamplona.quartz.nip52Calendar.appt.day.CalendarDateSlotEvent
|
import com.vitorpamplona.quartz.nip52Calendar.appt.day.CalendarDateSlotEvent
|
||||||
@@ -1214,7 +1214,7 @@ object LocalCache : ILocalCache, ICacheProvider {
|
|||||||
) = consumeBaseReplaceable(event, relay, wasVerified)
|
) = consumeBaseReplaceable(event, relay, wasVerified)
|
||||||
|
|
||||||
private fun consume(
|
private fun consume(
|
||||||
event: FavoriteRelayListEvent,
|
event: RelayFeedsListEvent,
|
||||||
relay: NormalizedRelayUrl?,
|
relay: NormalizedRelayUrl?,
|
||||||
wasVerified: Boolean,
|
wasVerified: Boolean,
|
||||||
) = consumeBaseReplaceable(event, relay, wasVerified)
|
) = consumeBaseReplaceable(event, relay, wasVerified)
|
||||||
@@ -3096,7 +3096,7 @@ object LocalCache : ILocalCache, ICacheProvider {
|
|||||||
is GitPatchEvent -> consume(event, relay, wasVerified)
|
is GitPatchEvent -> consume(event, relay, wasVerified)
|
||||||
is GitRepositoryEvent -> consume(event, relay, wasVerified)
|
is GitRepositoryEvent -> consume(event, relay, wasVerified)
|
||||||
is ChessGameEvent -> consume(event, relay, wasVerified)
|
is ChessGameEvent -> consume(event, relay, wasVerified)
|
||||||
is FavoriteRelayListEvent -> consume(event, relay, wasVerified)
|
is RelayFeedsListEvent -> consume(event, relay, wasVerified)
|
||||||
is JesterEvent -> consume(event, relay, wasVerified)
|
is JesterEvent -> consume(event, relay, wasVerified)
|
||||||
is LiveChessGameChallengeEvent -> consume(event, relay, wasVerified)
|
is LiveChessGameChallengeEvent -> consume(event, relay, wasVerified)
|
||||||
is LiveChessGameAcceptEvent -> consume(event, relay, wasVerified)
|
is LiveChessGameAcceptEvent -> consume(event, relay, wasVerified)
|
||||||
|
|||||||
+36
-36
@@ -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.nip51Lists.favoriteRelays
|
package com.vitorpamplona.amethyst.model.nip51Lists.relayFeeds
|
||||||
|
|
||||||
import com.vitorpamplona.amethyst.model.AccountSettings
|
import com.vitorpamplona.amethyst.model.AccountSettings
|
||||||
import com.vitorpamplona.amethyst.model.LocalCache
|
import com.vitorpamplona.amethyst.model.LocalCache
|
||||||
@@ -26,7 +26,7 @@ import com.vitorpamplona.amethyst.model.Note
|
|||||||
import com.vitorpamplona.amethyst.model.NoteState
|
import com.vitorpamplona.amethyst.model.NoteState
|
||||||
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
|
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
|
||||||
import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner
|
import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayFeedsListEvent
|
||||||
import com.vitorpamplona.quartz.utils.Log
|
import com.vitorpamplona.quartz.utils.Log
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||||
@@ -40,32 +40,32 @@ import kotlinx.coroutines.flow.onStart
|
|||||||
import kotlinx.coroutines.flow.stateIn
|
import kotlinx.coroutines.flow.stateIn
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
class FavoriteRelayListState(
|
class RelayFeedListState(
|
||||||
val signer: NostrSigner,
|
val signer: NostrSigner,
|
||||||
val cache: LocalCache,
|
val cache: LocalCache,
|
||||||
val decryptionCache: FavoriteRelayListDecryptionCache,
|
val decryptionCache: RelayFeedsListDecryptionCache,
|
||||||
val scope: CoroutineScope,
|
val scope: CoroutineScope,
|
||||||
val settings: AccountSettings,
|
val settings: AccountSettings,
|
||||||
) {
|
) {
|
||||||
// Creates a long-term reference for this note so that the GC doesn't collect the note it self
|
// Creates a long-term reference for this note so that the GC doesn't collect the note it self
|
||||||
val favoriteListNote = cache.getOrCreateAddressableNote(getFavoriteRelayListAddress())
|
val relayFeedListNote = cache.getOrCreateAddressableNote(getRelayFeedsListAddress())
|
||||||
|
|
||||||
fun getFavoriteRelayListAddress() = FavoriteRelayListEvent.createAddress(signer.pubKey)
|
fun getRelayFeedsListAddress() = RelayFeedsListEvent.createAddress(signer.pubKey)
|
||||||
|
|
||||||
fun getFavoriteRelayListFlow(): StateFlow<NoteState> = favoriteListNote.flow().metadata.stateFlow
|
fun getRelayFeedsListFlow(): StateFlow<NoteState> = relayFeedListNote.flow().metadata.stateFlow
|
||||||
|
|
||||||
fun getFavoriteRelayList(): FavoriteRelayListEvent? = favoriteListNote.event as? FavoriteRelayListEvent
|
fun getRelayFeedsList(): RelayFeedsListEvent? = relayFeedListNote.event as? RelayFeedsListEvent
|
||||||
|
|
||||||
fun favoriteListEvent(note: Note) = note.event as? FavoriteRelayListEvent ?: settings.backupFavoriteRelayList
|
fun relayFeedsListEvent(note: Note) = note.event as? RelayFeedsListEvent ?: settings.backupRelayFeedsList
|
||||||
|
|
||||||
suspend fun normalizeFavoriteRelayListWithBackup(note: Note): Set<NormalizedRelayUrl> = favoriteListEvent(note)?.let { decryptionCache.relays(it) }?.ifEmpty { null } ?: emptySet()
|
suspend fun normalizeRelayFeedsListWithBackup(note: Note): Set<NormalizedRelayUrl> = relayFeedsListEvent(note)?.let { decryptionCache.relays(it) }?.ifEmpty { null } ?: emptySet()
|
||||||
|
|
||||||
suspend fun normalizeFavoriteRelayListWithBackupNoDefaults(note: Note): Set<NormalizedRelayUrl> = favoriteListEvent(note)?.let { decryptionCache.relays(it) } ?: emptySet()
|
suspend fun normalizeRelayFeedsListWithBackupNoDefaults(note: Note): Set<NormalizedRelayUrl> = relayFeedsListEvent(note)?.let { decryptionCache.relays(it) } ?: emptySet()
|
||||||
|
|
||||||
val flow =
|
val flow =
|
||||||
getFavoriteRelayListFlow()
|
getRelayFeedsListFlow()
|
||||||
.map { normalizeFavoriteRelayListWithBackup(it.note) }
|
.map { normalizeRelayFeedsListWithBackup(it.note) }
|
||||||
.onStart { emit(normalizeFavoriteRelayListWithBackup(favoriteListNote)) }
|
.onStart { emit(normalizeRelayFeedsListWithBackup(relayFeedListNote)) }
|
||||||
.flowOn(Dispatchers.IO)
|
.flowOn(Dispatchers.IO)
|
||||||
.stateIn(
|
.stateIn(
|
||||||
scope,
|
scope,
|
||||||
@@ -74,9 +74,9 @@ class FavoriteRelayListState(
|
|||||||
)
|
)
|
||||||
|
|
||||||
val flowNoDefaults =
|
val flowNoDefaults =
|
||||||
getFavoriteRelayListFlow()
|
getRelayFeedsListFlow()
|
||||||
.map { normalizeFavoriteRelayListWithBackupNoDefaults(it.note) }
|
.map { normalizeRelayFeedsListWithBackupNoDefaults(it.note) }
|
||||||
.onStart { emit(normalizeFavoriteRelayListWithBackupNoDefaults(favoriteListNote)) }
|
.onStart { emit(normalizeRelayFeedsListWithBackupNoDefaults(relayFeedListNote)) }
|
||||||
.flowOn(Dispatchers.IO)
|
.flowOn(Dispatchers.IO)
|
||||||
.stateIn(
|
.stateIn(
|
||||||
scope,
|
scope,
|
||||||
@@ -84,49 +84,49 @@ class FavoriteRelayListState(
|
|||||||
emptySet(),
|
emptySet(),
|
||||||
)
|
)
|
||||||
|
|
||||||
suspend fun addRelay(relay: NormalizedRelayUrl): FavoriteRelayListEvent {
|
suspend fun addRelay(relay: NormalizedRelayUrl): RelayFeedsListEvent {
|
||||||
val current = normalizeFavoriteRelayListWithBackupNoDefaults(favoriteListNote).toMutableList()
|
val current = normalizeRelayFeedsListWithBackupNoDefaults(relayFeedListNote).toMutableList()
|
||||||
if (relay !in current) current.add(relay)
|
if (relay !in current) current.add(relay)
|
||||||
return saveRelayList(current)
|
return saveRelayList(current)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun removeRelay(relay: NormalizedRelayUrl): FavoriteRelayListEvent? {
|
suspend fun removeRelay(relay: NormalizedRelayUrl): RelayFeedsListEvent? {
|
||||||
val current = normalizeFavoriteRelayListWithBackupNoDefaults(favoriteListNote).toMutableList()
|
val current = normalizeRelayFeedsListWithBackupNoDefaults(relayFeedListNote).toMutableList()
|
||||||
if (relay !in current) return null
|
if (relay !in current) return null
|
||||||
current.remove(relay)
|
current.remove(relay)
|
||||||
return saveRelayList(current)
|
return saveRelayList(current)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun saveRelayList(favoriteRelays: List<NormalizedRelayUrl>): FavoriteRelayListEvent {
|
suspend fun saveRelayList(relayFeeds: List<NormalizedRelayUrl>): RelayFeedsListEvent {
|
||||||
val relayListForFavorite = getFavoriteRelayList()
|
val relayFeedsList = getRelayFeedsList()
|
||||||
|
|
||||||
return if (relayListForFavorite != null && relayListForFavorite.tags.isNotEmpty()) {
|
return if (relayFeedsList != null && relayFeedsList.tags.isNotEmpty()) {
|
||||||
FavoriteRelayListEvent.updateRelayList(
|
RelayFeedsListEvent.updateRelayList(
|
||||||
earlierVersion = relayListForFavorite,
|
earlierVersion = relayFeedsList,
|
||||||
relays = favoriteRelays,
|
relays = relayFeeds,
|
||||||
signer = signer,
|
signer = signer,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
FavoriteRelayListEvent.create(
|
RelayFeedsListEvent.create(
|
||||||
relays = favoriteRelays,
|
relays = relayFeeds,
|
||||||
signer = signer,
|
signer = signer,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
settings.backupFavoriteRelayList?.let {
|
settings.backupRelayFeedsList?.let {
|
||||||
Log.d("AccountRegisterObservers", "Loading saved favorite relay list ${it.toJson()}")
|
Log.d("AccountRegisterObservers", "Loading saved relay feeds list ${it.toJson()}")
|
||||||
@OptIn(DelicateCoroutinesApi::class)
|
@OptIn(DelicateCoroutinesApi::class)
|
||||||
GlobalScope.launch(Dispatchers.IO) { LocalCache.justConsumeMyOwnEvent(it) }
|
GlobalScope.launch(Dispatchers.IO) { LocalCache.justConsumeMyOwnEvent(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.launch(Dispatchers.IO) {
|
scope.launch(Dispatchers.IO) {
|
||||||
Log.d("AccountRegisterObservers", "Favorite Relay List Collector Start")
|
Log.d("AccountRegisterObservers", "Relay feeds list Collector Start")
|
||||||
getFavoriteRelayListFlow().collect {
|
getRelayFeedsListFlow().collect {
|
||||||
Log.d("AccountRegisterObservers", "Updating Favorite Relay List for ${signer.pubKey}")
|
Log.d("AccountRegisterObservers", "Updating Relay feeds list for ${signer.pubKey}")
|
||||||
(it.note.event as? FavoriteRelayListEvent)?.let {
|
(it.note.event as? RelayFeedsListEvent)?.let {
|
||||||
settings.updateFavoriteRelayList(it)
|
settings.updateRelayFeedList(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+4
-4
@@ -18,12 +18,12 @@
|
|||||||
* 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.nip51Lists.favoriteRelays
|
package com.vitorpamplona.amethyst.model.nip51Lists.relayFeeds
|
||||||
|
|
||||||
import com.vitorpamplona.amethyst.model.nip51Lists.relayLists.GenericRelayListCache
|
import com.vitorpamplona.amethyst.model.nip51Lists.relayLists.GenericRelayListCache
|
||||||
import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner
|
import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayFeedsListEvent
|
||||||
|
|
||||||
class FavoriteRelayListDecryptionCache(
|
class RelayFeedsListDecryptionCache(
|
||||||
signer: NostrSigner,
|
signer: NostrSigner,
|
||||||
) : GenericRelayListCache<FavoriteRelayListEvent>(signer)
|
) : GenericRelayListCache<RelayFeedsListEvent>(signer)
|
||||||
+2
-2
@@ -37,9 +37,9 @@ import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListEvent
|
|||||||
import com.vitorpamplona.quartz.nip51Lists.hashtagList.HashtagListEvent
|
import com.vitorpamplona.quartz.nip51Lists.hashtagList.HashtagListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.BroadcastRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.BroadcastRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent
|
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.ProxyRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.ProxyRelayListEvent
|
||||||
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayFeedsListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent
|
import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip78AppData.AppSpecificDataEvent
|
import com.vitorpamplona.quartz.nip78AppData.AppSpecificDataEvent
|
||||||
@@ -70,7 +70,7 @@ val AccountInfoAndListsFromKeyKinds2 =
|
|||||||
GeohashListEvent.KIND,
|
GeohashListEvent.KIND,
|
||||||
TrustProviderListEvent.KIND,
|
TrustProviderListEvent.KIND,
|
||||||
PaymentTargetsEvent.KIND,
|
PaymentTargetsEvent.KIND,
|
||||||
FavoriteRelayListEvent.KIND,
|
RelayFeedsListEvent.KIND,
|
||||||
)
|
)
|
||||||
|
|
||||||
val AmethystMetadataKinds = listOf(AppSpecificDataEvent.KIND)
|
val AmethystMetadataKinds = listOf(AppSpecificDataEvent.KIND)
|
||||||
|
|||||||
+2
-2
@@ -33,9 +33,9 @@ import com.vitorpamplona.quartz.nip51Lists.geohashList.GeohashListEvent
|
|||||||
import com.vitorpamplona.quartz.nip51Lists.hashtagList.HashtagListEvent
|
import com.vitorpamplona.quartz.nip51Lists.hashtagList.HashtagListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.BroadcastRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.BroadcastRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent
|
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.ProxyRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.ProxyRelayListEvent
|
||||||
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayFeedsListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent
|
import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip96FileStorage.config.FileServersEvent
|
import com.vitorpamplona.quartz.nip96FileStorage.config.FileServersEvent
|
||||||
@@ -62,7 +62,7 @@ val BasicAccountInfoKinds2 =
|
|||||||
HashtagListEvent.KIND,
|
HashtagListEvent.KIND,
|
||||||
GeohashListEvent.KIND,
|
GeohashListEvent.KIND,
|
||||||
TrustProviderListEvent.KIND,
|
TrustProviderListEvent.KIND,
|
||||||
FavoriteRelayListEvent.KIND,
|
RelayFeedsListEvent.KIND,
|
||||||
)
|
)
|
||||||
|
|
||||||
fun filterBasicAccountInfoFromKeys(
|
fun filterBasicAccountInfoFromKeys(
|
||||||
|
|||||||
+3
-3
@@ -363,16 +363,16 @@ fun observeUserIsFollowingRelay(
|
|||||||
): State<Boolean> {
|
): State<Boolean> {
|
||||||
val flow =
|
val flow =
|
||||||
remember(accountViewModel) {
|
remember(accountViewModel) {
|
||||||
accountViewModel.account.favoriteRelayList.flowNoDefaults
|
accountViewModel.account.relayFeedsList.flowNoDefaults
|
||||||
.mapLatest { relays ->
|
.mapLatest { relays ->
|
||||||
relayUrl in relays
|
relayUrl in relays
|
||||||
}.onStart {
|
}.onStart {
|
||||||
emit(relayUrl in accountViewModel.account.favoriteRelayList.flowNoDefaults.value)
|
emit(relayUrl in accountViewModel.account.relayFeedsList.flowNoDefaults.value)
|
||||||
}.distinctUntilChanged()
|
}.distinctUntilChanged()
|
||||||
.flowOn(Dispatchers.IO)
|
.flowOn(Dispatchers.IO)
|
||||||
}
|
}
|
||||||
|
|
||||||
return flow.collectAsStateWithLifecycle(relayUrl in accountViewModel.account.favoriteRelayList.flowNoDefaults.value)
|
return flow.collectAsStateWithLifecycle(relayUrl in accountViewModel.account.relayFeedsList.flowNoDefaults.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class)
|
@OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class)
|
||||||
|
|||||||
@@ -81,12 +81,12 @@ import com.vitorpamplona.amethyst.ui.note.types.BadgeDisplay
|
|||||||
import com.vitorpamplona.amethyst.ui.note.types.DisplayBlockedRelayList
|
import com.vitorpamplona.amethyst.ui.note.types.DisplayBlockedRelayList
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.DisplayBroadcastRelayList
|
import com.vitorpamplona.amethyst.ui.note.types.DisplayBroadcastRelayList
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.DisplayDMRelayList
|
import com.vitorpamplona.amethyst.ui.note.types.DisplayDMRelayList
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.DisplayFavoriteRelayList
|
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.DisplayFollowList
|
import com.vitorpamplona.amethyst.ui.note.types.DisplayFollowList
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.DisplayIndexerRelayList
|
import com.vitorpamplona.amethyst.ui.note.types.DisplayIndexerRelayList
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.DisplayNIP65RelayList
|
import com.vitorpamplona.amethyst.ui.note.types.DisplayNIP65RelayList
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.DisplayPeopleList
|
import com.vitorpamplona.amethyst.ui.note.types.DisplayPeopleList
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.DisplayProxyRelayList
|
import com.vitorpamplona.amethyst.ui.note.types.DisplayProxyRelayList
|
||||||
|
import com.vitorpamplona.amethyst.ui.note.types.DisplayRelayFeedsList
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.DisplayRelaySet
|
import com.vitorpamplona.amethyst.ui.note.types.DisplayRelaySet
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.DisplaySearchRelayList
|
import com.vitorpamplona.amethyst.ui.note.types.DisplaySearchRelayList
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.DisplayTrustedRelayList
|
import com.vitorpamplona.amethyst.ui.note.types.DisplayTrustedRelayList
|
||||||
@@ -206,9 +206,9 @@ import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent
|
|||||||
import com.vitorpamplona.quartz.nip51Lists.peopleList.PeopleListEvent
|
import com.vitorpamplona.quartz.nip51Lists.peopleList.PeopleListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.BroadcastRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.BroadcastRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent
|
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.ProxyRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.ProxyRelayListEvent
|
||||||
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayFeedsListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relaySets.RelaySetEvent
|
import com.vitorpamplona.quartz.nip51Lists.relaySets.RelaySetEvent
|
||||||
import com.vitorpamplona.quartz.nip52Calendar.appt.day.CalendarDateSlotEvent
|
import com.vitorpamplona.quartz.nip52Calendar.appt.day.CalendarDateSlotEvent
|
||||||
@@ -842,8 +842,8 @@ private fun RenderNoteRow(
|
|||||||
DisplayTrustedRelayList(baseNote, backgroundColor, accountViewModel, nav)
|
DisplayTrustedRelayList(baseNote, backgroundColor, accountViewModel, nav)
|
||||||
}
|
}
|
||||||
|
|
||||||
is FavoriteRelayListEvent -> {
|
is RelayFeedsListEvent -> {
|
||||||
DisplayFavoriteRelayList(baseNote, backgroundColor, accountViewModel, nav)
|
DisplayRelayFeedsList(baseNote, backgroundColor, accountViewModel, nav)
|
||||||
}
|
}
|
||||||
|
|
||||||
is IndexerRelayListEvent -> {
|
is IndexerRelayListEvent -> {
|
||||||
|
|||||||
@@ -235,14 +235,14 @@ fun DisplayTrustedRelayList(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun DisplayFavoriteRelayList(
|
fun DisplayRelayFeedsList(
|
||||||
baseNote: Note,
|
baseNote: Note,
|
||||||
backgroundColor: MutableState<Color>,
|
backgroundColor: MutableState<Color>,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: INav,
|
nav: INav,
|
||||||
) {
|
) {
|
||||||
val relays by accountViewModel.account.favoriteRelayListDecryptionCache.observeDecryptedRelayList(baseNote).collectAsStateWithLifecycle(
|
val relays by accountViewModel.account.relayFeedsListDecryptionCache.observeDecryptedRelayList(baseNote).collectAsStateWithLifecycle(
|
||||||
accountViewModel.account.favoriteRelayListDecryptionCache.fastStartValueForRelayList(baseNote),
|
accountViewModel.account.relayFeedsListDecryptionCache.fastStartValueForRelayList(baseNote),
|
||||||
)
|
)
|
||||||
|
|
||||||
DisplayRelaySet(
|
DisplayRelaySet(
|
||||||
|
|||||||
+3
-2
@@ -60,8 +60,8 @@ import com.vitorpamplona.quartz.nip19Bech32.toNpub
|
|||||||
import com.vitorpamplona.quartz.nip28PublicChat.list.ChannelListEvent
|
import com.vitorpamplona.quartz.nip28PublicChat.list.ChannelListEvent
|
||||||
import com.vitorpamplona.quartz.nip49PrivKeyEnc.Nip49
|
import com.vitorpamplona.quartz.nip49PrivKeyEnc.Nip49
|
||||||
import com.vitorpamplona.quartz.nip50Search.SearchRelayListEvent
|
import com.vitorpamplona.quartz.nip50Search.SearchRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent
|
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent
|
||||||
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayFeedsListEvent
|
||||||
import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent
|
import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent
|
||||||
import com.vitorpamplona.quartz.utils.Hex
|
import com.vitorpamplona.quartz.utils.Hex
|
||||||
import com.vitorpamplona.quartz.utils.Log
|
import com.vitorpamplona.quartz.utils.Log
|
||||||
@@ -302,6 +302,7 @@ class AccountSessionManager(
|
|||||||
accountSettings.backupDMRelayList?.let { client.send(it, toPost) }
|
accountSettings.backupDMRelayList?.let { client.send(it, toPost) }
|
||||||
accountSettings.backupSearchRelayList?.let { client.send(it, toPost) }
|
accountSettings.backupSearchRelayList?.let { client.send(it, toPost) }
|
||||||
accountSettings.backupIndexRelayList?.let { client.send(it, toPost) }
|
accountSettings.backupIndexRelayList?.let { client.send(it, toPost) }
|
||||||
|
accountSettings.backupRelayFeedsList?.let { client.send(it, toPost) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -325,7 +326,7 @@ class AccountSessionManager(
|
|||||||
backupSearchRelayList = SearchRelayListEvent.create(DefaultSearchRelayList.toList(), tempSigner),
|
backupSearchRelayList = SearchRelayListEvent.create(DefaultSearchRelayList.toList(), tempSigner),
|
||||||
backupIndexRelayList = IndexerRelayListEvent.create(DefaultIndexerRelayList.toList(), tempSigner),
|
backupIndexRelayList = IndexerRelayListEvent.create(DefaultIndexerRelayList.toList(), tempSigner),
|
||||||
backupChannelList = ChannelListEvent.create(emptyList(), DefaultChannels, tempSigner),
|
backupChannelList = ChannelListEvent.create(emptyList(), DefaultChannels, tempSigner),
|
||||||
backupFavoriteRelayList = FavoriteRelayListEvent.create(DefaultGlobalRelays, tempSigner),
|
backupRelayFeedsList = RelayFeedsListEvent.create(DefaultGlobalRelays, tempSigner),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ class TopNavFilterState(
|
|||||||
account.hashtagList.flow,
|
account.hashtagList.flow,
|
||||||
account.geohashList.flow,
|
account.geohashList.flow,
|
||||||
account.communityList.flowNotes,
|
account.communityList.flowNotes,
|
||||||
account.favoriteRelayList.flow,
|
account.relayFeedsList.flow,
|
||||||
::mergeInterests,
|
::mergeInterests,
|
||||||
).onStart {
|
).onStart {
|
||||||
emit(
|
emit(
|
||||||
@@ -194,7 +194,7 @@ class TopNavFilterState(
|
|||||||
account.hashtagList.flow.value,
|
account.hashtagList.flow.value,
|
||||||
account.geohashList.flow.value,
|
account.geohashList.flow.value,
|
||||||
account.communityList.flowNotes.value,
|
account.communityList.flowNotes.value,
|
||||||
account.favoriteRelayList.flow.value,
|
account.relayFeedsList.flow.value,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -926,9 +926,9 @@ class AccountViewModel(
|
|||||||
|
|
||||||
fun unfollowHashtag(tag: String) = launchSigner { account.unfollowHashtag(tag) }
|
fun unfollowHashtag(tag: String) = launchSigner { account.unfollowHashtag(tag) }
|
||||||
|
|
||||||
fun followFavoriteRelay(url: NormalizedRelayUrl) = launchSigner { account.followFavoriteRelay(url) }
|
fun followRelayFeed(url: NormalizedRelayUrl) = launchSigner { account.followRelayFeed(url) }
|
||||||
|
|
||||||
fun unfollowFavoriteRelay(url: NormalizedRelayUrl) = launchSigner { account.unfollowFavoriteRelay(url) }
|
fun unfollowRelayFeed(url: NormalizedRelayUrl) = launchSigner { account.unfollowRelayFeed(url) }
|
||||||
|
|
||||||
fun showWord(word: String) = launchSigner { account.showWord(word) }
|
fun showWord(word: String) = launchSigner { account.showWord(word) }
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -131,7 +131,7 @@ fun RelayFeedActionOptions(
|
|||||||
R.string.login_with_a_private_key_to_be_able_to_unfollow,
|
R.string.login_with_a_private_key_to_be_able_to_unfollow,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
accountViewModel.unfollowFavoriteRelay(relayUrl)
|
accountViewModel.unfollowRelayFeed(relayUrl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -142,7 +142,7 @@ fun RelayFeedActionOptions(
|
|||||||
R.string.login_with_a_private_key_to_be_able_to_follow,
|
R.string.login_with_a_private_key_to_be_able_to_follow,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
accountViewModel.followFavoriteRelay(relayUrl)
|
accountViewModel.followRelayFeed(relayUrl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-11
@@ -55,8 +55,8 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.connected.ConnectedR
|
|||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.connected.renderConnectedItems
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.connected.renderConnectedItems
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.dm.DMRelayListViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.dm.DMRelayListViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.dm.renderDMItems
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.dm.renderDMItems
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.favorites.FavoriteRelayListViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.feeds.RelayFeedsListViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.favorites.renderFavoriteItems
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.feeds.renderRelayFeedsItems
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.indexer.IndexerRelayListViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.indexer.IndexerRelayListViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.indexer.renderIndexerItems
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.indexer.renderIndexerItems
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.local.LocalRelayListViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.local.LocalRelayListViewModel
|
||||||
@@ -95,7 +95,7 @@ fun AllRelayListScreen(
|
|||||||
val broadcastViewModel: BroadcastRelayListViewModel = viewModel()
|
val broadcastViewModel: BroadcastRelayListViewModel = viewModel()
|
||||||
val indexerViewModel: IndexerRelayListViewModel = viewModel()
|
val indexerViewModel: IndexerRelayListViewModel = viewModel()
|
||||||
val proxyViewModel: ProxyRelayListViewModel = viewModel()
|
val proxyViewModel: ProxyRelayListViewModel = viewModel()
|
||||||
val favoriteViewModel: FavoriteRelayListViewModel = viewModel()
|
val relayFeedsViewModel: RelayFeedsListViewModel = viewModel()
|
||||||
|
|
||||||
dmViewModel.init(accountViewModel)
|
dmViewModel.init(accountViewModel)
|
||||||
nip65ViewModel.init(accountViewModel)
|
nip65ViewModel.init(accountViewModel)
|
||||||
@@ -108,7 +108,7 @@ fun AllRelayListScreen(
|
|||||||
broadcastViewModel.init(accountViewModel)
|
broadcastViewModel.init(accountViewModel)
|
||||||
indexerViewModel.init(accountViewModel)
|
indexerViewModel.init(accountViewModel)
|
||||||
proxyViewModel.init(accountViewModel)
|
proxyViewModel.init(accountViewModel)
|
||||||
favoriteViewModel.init(accountViewModel)
|
relayFeedsViewModel.init(accountViewModel)
|
||||||
|
|
||||||
LaunchedEffect(accountViewModel) {
|
LaunchedEffect(accountViewModel) {
|
||||||
dmViewModel.load()
|
dmViewModel.load()
|
||||||
@@ -122,7 +122,7 @@ fun AllRelayListScreen(
|
|||||||
broadcastViewModel.load()
|
broadcastViewModel.load()
|
||||||
indexerViewModel.load()
|
indexerViewModel.load()
|
||||||
proxyViewModel.load()
|
proxyViewModel.load()
|
||||||
favoriteViewModel.load()
|
relayFeedsViewModel.load()
|
||||||
}
|
}
|
||||||
|
|
||||||
MappedAllRelayListView(
|
MappedAllRelayListView(
|
||||||
@@ -137,7 +137,7 @@ fun AllRelayListScreen(
|
|||||||
broadcastViewModel,
|
broadcastViewModel,
|
||||||
indexerViewModel,
|
indexerViewModel,
|
||||||
proxyViewModel,
|
proxyViewModel,
|
||||||
favoriteViewModel,
|
relayFeedsViewModel,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
nav,
|
nav,
|
||||||
)
|
)
|
||||||
@@ -157,7 +157,7 @@ fun MappedAllRelayListView(
|
|||||||
broadcastViewModel: BroadcastRelayListViewModel,
|
broadcastViewModel: BroadcastRelayListViewModel,
|
||||||
indexerViewModel: IndexerRelayListViewModel,
|
indexerViewModel: IndexerRelayListViewModel,
|
||||||
proxyViewModel: ProxyRelayListViewModel,
|
proxyViewModel: ProxyRelayListViewModel,
|
||||||
favoriteViewModel: FavoriteRelayListViewModel,
|
relayFeedsViewModel: RelayFeedsListViewModel,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
newNav: INav,
|
newNav: INav,
|
||||||
) {
|
) {
|
||||||
@@ -173,7 +173,7 @@ fun MappedAllRelayListView(
|
|||||||
val broadcastRelays by broadcastViewModel.relays.collectAsStateWithLifecycle()
|
val broadcastRelays by broadcastViewModel.relays.collectAsStateWithLifecycle()
|
||||||
val indexerRelays by indexerViewModel.relays.collectAsStateWithLifecycle()
|
val indexerRelays by indexerViewModel.relays.collectAsStateWithLifecycle()
|
||||||
val proxyRelays by proxyViewModel.relays.collectAsStateWithLifecycle()
|
val proxyRelays by proxyViewModel.relays.collectAsStateWithLifecycle()
|
||||||
val favoriteFeedState by favoriteViewModel.relays.collectAsStateWithLifecycle()
|
val relayFeedsFeedState by relayFeedsViewModel.relays.collectAsStateWithLifecycle()
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
topBar = {
|
topBar = {
|
||||||
@@ -190,7 +190,7 @@ fun MappedAllRelayListView(
|
|||||||
broadcastViewModel.clear()
|
broadcastViewModel.clear()
|
||||||
indexerViewModel.clear()
|
indexerViewModel.clear()
|
||||||
proxyViewModel.clear()
|
proxyViewModel.clear()
|
||||||
favoriteViewModel.clear()
|
relayFeedsViewModel.clear()
|
||||||
newNav.popBack()
|
newNav.popBack()
|
||||||
},
|
},
|
||||||
onPost = {
|
onPost = {
|
||||||
@@ -204,7 +204,7 @@ fun MappedAllRelayListView(
|
|||||||
broadcastViewModel.create()
|
broadcastViewModel.create()
|
||||||
indexerViewModel.create()
|
indexerViewModel.create()
|
||||||
proxyViewModel.create()
|
proxyViewModel.create()
|
||||||
favoriteViewModel.create()
|
relayFeedsViewModel.create()
|
||||||
newNav.popBack()
|
newNav.popBack()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -327,7 +327,7 @@ fun MappedAllRelayListView(
|
|||||||
SettingsCategorySpacingModifier,
|
SettingsCategorySpacingModifier,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
renderFavoriteItems(favoriteFeedState, favoriteViewModel, accountViewModel, newNav)
|
renderRelayFeedsItems(relayFeedsFeedState, relayFeedsViewModel, accountViewModel, newNav)
|
||||||
|
|
||||||
item {
|
item {
|
||||||
SettingsCategory(
|
SettingsCategory(
|
||||||
|
|||||||
+2
-2
@@ -204,9 +204,9 @@ import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent
|
|||||||
import com.vitorpamplona.quartz.nip51Lists.peopleList.PeopleListEvent
|
import com.vitorpamplona.quartz.nip51Lists.peopleList.PeopleListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.BroadcastRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.BroadcastRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent
|
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.ProxyRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.ProxyRelayListEvent
|
||||||
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayFeedsListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relaySets.RelaySetEvent
|
import com.vitorpamplona.quartz.nip51Lists.relaySets.RelaySetEvent
|
||||||
import com.vitorpamplona.quartz.nip52Calendar.appt.day.CalendarDateSlotEvent
|
import com.vitorpamplona.quartz.nip52Calendar.appt.day.CalendarDateSlotEvent
|
||||||
@@ -543,7 +543,7 @@ private fun kindDisplayName(kind: Int): Int =
|
|||||||
CalendarRSVPEvent.KIND -> R.string.kind_appt_rsvp
|
CalendarRSVPEvent.KIND -> R.string.kind_appt_rsvp
|
||||||
ChessGameEvent.KIND -> R.string.kind_chess_games
|
ChessGameEvent.KIND -> R.string.kind_chess_games
|
||||||
JesterEvent.KIND -> R.string.kind_chess_auth
|
JesterEvent.KIND -> R.string.kind_chess_auth
|
||||||
FavoriteRelayListEvent.KIND -> R.string.kind_favorite_relays
|
RelayFeedsListEvent.KIND -> R.string.kind_favorite_relays
|
||||||
LiveChessGameChallengeEvent.KIND -> R.string.kind_chess_challenges
|
LiveChessGameChallengeEvent.KIND -> R.string.kind_chess_challenges
|
||||||
LiveChessGameAcceptEvent.KIND -> R.string.kind_chess_game_accept
|
LiveChessGameAcceptEvent.KIND -> R.string.kind_chess_game_accept
|
||||||
LiveChessMoveEvent.KIND -> R.string.kind_chess_move
|
LiveChessMoveEvent.KIND -> R.string.kind_chess_move
|
||||||
|
|||||||
+7
-7
@@ -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.ui.screen.loggedIn.relays.favorites
|
package com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.feeds
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
@@ -41,8 +41,8 @@ import com.vitorpamplona.amethyst.ui.theme.FeedPadding
|
|||||||
import com.vitorpamplona.amethyst.ui.theme.StdVertSpacer
|
import com.vitorpamplona.amethyst.ui.theme.StdVertSpacer
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun FavoriteRelayList(
|
fun RelayFeedsList(
|
||||||
postViewModel: FavoriteRelayListViewModel,
|
postViewModel: RelayFeedsListViewModel,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
onClose: () -> Unit,
|
onClose: () -> Unit,
|
||||||
nav: INav,
|
nav: INav,
|
||||||
@@ -55,18 +55,18 @@ fun FavoriteRelayList(
|
|||||||
LazyColumn(
|
LazyColumn(
|
||||||
contentPadding = FeedPadding,
|
contentPadding = FeedPadding,
|
||||||
) {
|
) {
|
||||||
renderFavoriteItems(feedState, postViewModel, accountViewModel, newNav)
|
renderRelayFeedsItems(feedState, postViewModel, accountViewModel, newNav)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun LazyListScope.renderFavoriteItems(
|
fun LazyListScope.renderRelayFeedsItems(
|
||||||
feedState: List<BasicRelaySetupInfo>,
|
feedState: List<BasicRelaySetupInfo>,
|
||||||
postViewModel: FavoriteRelayListViewModel,
|
postViewModel: RelayFeedsListViewModel,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: INav,
|
nav: INav,
|
||||||
) {
|
) {
|
||||||
itemsIndexed(feedState, key = { _, item -> "Favorite" + item.relay.url }) { index, item ->
|
itemsIndexed(feedState, key = { _, item -> "RelayFeeds" + item.relay.url }) { index, item ->
|
||||||
BasicRelaySetupInfoDialog(
|
BasicRelaySetupInfoDialog(
|
||||||
item,
|
item,
|
||||||
onDelete = { postViewModel.deleteRelay(item) },
|
onDelete = { postViewModel.deleteRelay(item) },
|
||||||
+4
-4
@@ -18,19 +18,19 @@
|
|||||||
* 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.ui.screen.loggedIn.relays.favorites
|
package com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.feeds
|
||||||
|
|
||||||
import androidx.compose.runtime.Stable
|
import androidx.compose.runtime.Stable
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.common.BasicRelaySetupInfoModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.common.BasicRelaySetupInfoModel
|
||||||
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
|
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
|
||||||
|
|
||||||
@Stable
|
@Stable
|
||||||
class FavoriteRelayListViewModel : BasicRelaySetupInfoModel() {
|
class RelayFeedsListViewModel : BasicRelaySetupInfoModel() {
|
||||||
override fun getRelayList(): List<NormalizedRelayUrl> =
|
override fun getRelayList(): List<NormalizedRelayUrl> =
|
||||||
account.favoriteRelayList.flow.value
|
account.relayFeedsList.flow.value
|
||||||
.toList()
|
.toList()
|
||||||
|
|
||||||
override suspend fun saveRelayList(urlList: List<NormalizedRelayUrl>) {
|
override suspend fun saveRelayList(urlList: List<NormalizedRelayUrl>) {
|
||||||
account.saveFavoriteRelayList(urlList)
|
account.saveRelayFeedsList(urlList)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+4
-4
@@ -124,12 +124,12 @@ import com.vitorpamplona.amethyst.ui.note.types.BadgeDisplay
|
|||||||
import com.vitorpamplona.amethyst.ui.note.types.DisplayBlockedRelayList
|
import com.vitorpamplona.amethyst.ui.note.types.DisplayBlockedRelayList
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.DisplayBroadcastRelayList
|
import com.vitorpamplona.amethyst.ui.note.types.DisplayBroadcastRelayList
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.DisplayDMRelayList
|
import com.vitorpamplona.amethyst.ui.note.types.DisplayDMRelayList
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.DisplayFavoriteRelayList
|
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.DisplayFollowList
|
import com.vitorpamplona.amethyst.ui.note.types.DisplayFollowList
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.DisplayIndexerRelayList
|
import com.vitorpamplona.amethyst.ui.note.types.DisplayIndexerRelayList
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.DisplayNIP65RelayList
|
import com.vitorpamplona.amethyst.ui.note.types.DisplayNIP65RelayList
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.DisplayPeopleList
|
import com.vitorpamplona.amethyst.ui.note.types.DisplayPeopleList
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.DisplayProxyRelayList
|
import com.vitorpamplona.amethyst.ui.note.types.DisplayProxyRelayList
|
||||||
|
import com.vitorpamplona.amethyst.ui.note.types.DisplayRelayFeedsList
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.DisplayRelaySet
|
import com.vitorpamplona.amethyst.ui.note.types.DisplayRelaySet
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.DisplaySearchRelayList
|
import com.vitorpamplona.amethyst.ui.note.types.DisplaySearchRelayList
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.DisplayTrustedRelayList
|
import com.vitorpamplona.amethyst.ui.note.types.DisplayTrustedRelayList
|
||||||
@@ -222,9 +222,9 @@ import com.vitorpamplona.quartz.nip51Lists.followList.FollowListEvent
|
|||||||
import com.vitorpamplona.quartz.nip51Lists.peopleList.PeopleListEvent
|
import com.vitorpamplona.quartz.nip51Lists.peopleList.PeopleListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.BroadcastRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.BroadcastRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent
|
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.ProxyRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.ProxyRelayListEvent
|
||||||
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayFeedsListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relaySets.RelaySetEvent
|
import com.vitorpamplona.quartz.nip51Lists.relaySets.RelaySetEvent
|
||||||
import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent
|
import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent
|
||||||
@@ -622,8 +622,8 @@ private fun FullBleedNoteCompose(
|
|||||||
DisplayProxyRelayList(baseNote, backgroundColor, accountViewModel, nav)
|
DisplayProxyRelayList(baseNote, backgroundColor, accountViewModel, nav)
|
||||||
} else if (noteEvent is TrustedRelayListEvent) {
|
} else if (noteEvent is TrustedRelayListEvent) {
|
||||||
DisplayTrustedRelayList(baseNote, backgroundColor, accountViewModel, nav)
|
DisplayTrustedRelayList(baseNote, backgroundColor, accountViewModel, nav)
|
||||||
} else if (noteEvent is FavoriteRelayListEvent) {
|
} else if (noteEvent is RelayFeedsListEvent) {
|
||||||
DisplayFavoriteRelayList(baseNote, backgroundColor, accountViewModel, nav)
|
DisplayRelayFeedsList(baseNote, backgroundColor, accountViewModel, nav)
|
||||||
} else if (noteEvent is IndexerRelayListEvent) {
|
} else if (noteEvent is IndexerRelayListEvent) {
|
||||||
DisplayIndexerRelayList(baseNote, backgroundColor, accountViewModel, nav)
|
DisplayIndexerRelayList(baseNote, backgroundColor, accountViewModel, nav)
|
||||||
} else if (noteEvent is BroadcastRelayListEvent) {
|
} else if (noteEvent is BroadcastRelayListEvent) {
|
||||||
|
|||||||
+10
-10
@@ -36,13 +36,13 @@ import com.vitorpamplona.quartz.nip51Lists.PrivateTagArrayEvent
|
|||||||
import com.vitorpamplona.quartz.nip51Lists.encryption.PrivateTagsInContent
|
import com.vitorpamplona.quartz.nip51Lists.encryption.PrivateTagsInContent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.encryption.signNip51List
|
import com.vitorpamplona.quartz.nip51Lists.encryption.signNip51List
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.tags.RelayTag
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.tags.RelayTag
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.tags.favoriteRelays
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.tags.relayFeeds
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.tags.relays
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.tags.relays
|
||||||
import com.vitorpamplona.quartz.nip51Lists.remove
|
import com.vitorpamplona.quartz.nip51Lists.remove
|
||||||
import com.vitorpamplona.quartz.utils.TimeUtils
|
import com.vitorpamplona.quartz.utils.TimeUtils
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
class FavoriteRelayListEvent(
|
class RelayFeedsListEvent(
|
||||||
id: HexKey,
|
id: HexKey,
|
||||||
pubKey: HexKey,
|
pubKey: HexKey,
|
||||||
createdAt: Long,
|
createdAt: Long,
|
||||||
@@ -58,7 +58,7 @@ class FavoriteRelayListEvent(
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val KIND = 10012
|
const val KIND = 10012
|
||||||
const val ALT = "Favorite Relays"
|
const val ALT = "Relay Feeds"
|
||||||
val TAGS = arrayOf(AltTag.assemble(ALT))
|
val TAGS = arrayOf(AltTag.assemble(ALT))
|
||||||
|
|
||||||
fun createAddress(pubKey: HexKey): Address = Address(KIND, pubKey, "")
|
fun createAddress(pubKey: HexKey): Address = Address(KIND, pubKey, "")
|
||||||
@@ -68,11 +68,11 @@ class FavoriteRelayListEvent(
|
|||||||
fun createAddressTag(pubKey: HexKey): String = Address.Companion.assemble(KIND, pubKey, "")
|
fun createAddressTag(pubKey: HexKey): String = Address.Companion.assemble(KIND, pubKey, "")
|
||||||
|
|
||||||
suspend fun updateRelayList(
|
suspend fun updateRelayList(
|
||||||
earlierVersion: FavoriteRelayListEvent,
|
earlierVersion: RelayFeedsListEvent,
|
||||||
relays: List<NormalizedRelayUrl>,
|
relays: List<NormalizedRelayUrl>,
|
||||||
signer: NostrSigner,
|
signer: NostrSigner,
|
||||||
createdAt: Long = TimeUtils.now(),
|
createdAt: Long = TimeUtils.now(),
|
||||||
): FavoriteRelayListEvent {
|
): RelayFeedsListEvent {
|
||||||
val newRelayList = relays.map { RelayTag.assemble(it) }
|
val newRelayList = relays.map { RelayTag.assemble(it) }
|
||||||
val privateTags = earlierVersion.privateTags(signer) ?: throw SignerExceptions.UnauthorizedDecryptionException()
|
val privateTags = earlierVersion.privateTags(signer) ?: throw SignerExceptions.UnauthorizedDecryptionException()
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ class FavoriteRelayListEvent(
|
|||||||
relays: List<NormalizedRelayUrl>,
|
relays: List<NormalizedRelayUrl>,
|
||||||
signer: NostrSigner,
|
signer: NostrSigner,
|
||||||
createdAt: Long = TimeUtils.now(),
|
createdAt: Long = TimeUtils.now(),
|
||||||
): FavoriteRelayListEvent {
|
): RelayFeedsListEvent {
|
||||||
val privateTagArray = relays.map { RelayTag.assemble(it) }.toTypedArray()
|
val privateTagArray = relays.map { RelayTag.assemble(it) }.toTypedArray()
|
||||||
return signer.signNip51List(createdAt, KIND, TAGS, privateTagArray)
|
return signer.signNip51List(createdAt, KIND, TAGS, privateTagArray)
|
||||||
}
|
}
|
||||||
@@ -95,7 +95,7 @@ class FavoriteRelayListEvent(
|
|||||||
relays: List<NormalizedRelayUrl>,
|
relays: List<NormalizedRelayUrl>,
|
||||||
signer: NostrSignerSync,
|
signer: NostrSignerSync,
|
||||||
createdAt: Long = TimeUtils.now(),
|
createdAt: Long = TimeUtils.now(),
|
||||||
): FavoriteRelayListEvent {
|
): RelayFeedsListEvent {
|
||||||
val privateTagArray = relays.map { RelayTag.assemble(it) }.toTypedArray()
|
val privateTagArray = relays.map { RelayTag.assemble(it) }.toTypedArray()
|
||||||
return signer.signNip51List(createdAt, KIND, TAGS, privateTagArray)
|
return signer.signNip51List(createdAt, KIND, TAGS, privateTagArray)
|
||||||
}
|
}
|
||||||
@@ -105,14 +105,14 @@ class FavoriteRelayListEvent(
|
|||||||
privateRelays: List<NormalizedRelayUrl> = emptyList(),
|
privateRelays: List<NormalizedRelayUrl> = emptyList(),
|
||||||
signer: NostrSigner,
|
signer: NostrSigner,
|
||||||
createdAt: Long = TimeUtils.now(),
|
createdAt: Long = TimeUtils.now(),
|
||||||
initializer: TagArrayBuilder<FavoriteRelayListEvent>.() -> Unit = {},
|
initializer: TagArrayBuilder<RelayFeedsListEvent>.() -> Unit = {},
|
||||||
) = eventTemplate<FavoriteRelayListEvent>(
|
) = eventTemplate<RelayFeedsListEvent>(
|
||||||
kind = KIND,
|
kind = KIND,
|
||||||
description = PrivateTagsInContent.encryptNip44(privateRelays.map { RelayTag.assemble(it) }.toTypedArray(), signer),
|
description = PrivateTagsInContent.encryptNip44(privateRelays.map { RelayTag.assemble(it) }.toTypedArray(), signer),
|
||||||
createdAt = createdAt,
|
createdAt = createdAt,
|
||||||
) {
|
) {
|
||||||
alt(ALT)
|
alt(ALT)
|
||||||
favoriteRelays(publicRelays)
|
relayFeeds(publicRelays)
|
||||||
|
|
||||||
initializer()
|
initializer()
|
||||||
}
|
}
|
||||||
+2
-2
@@ -27,9 +27,9 @@ import com.vitorpamplona.quartz.nip50Search.SearchRelayListEvent
|
|||||||
import com.vitorpamplona.quartz.nip51Lists.PrivateTagArrayEvent
|
import com.vitorpamplona.quartz.nip51Lists.PrivateTagArrayEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.BroadcastRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.BroadcastRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent
|
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.ProxyRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.ProxyRelayListEvent
|
||||||
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayFeedsListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relaySets.RelaySetEvent
|
import com.vitorpamplona.quartz.nip51Lists.relaySets.RelaySetEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.tags.NameTag
|
import com.vitorpamplona.quartz.nip51Lists.tags.NameTag
|
||||||
@@ -52,4 +52,4 @@ fun TagArrayBuilder<PrivateOutboxRelayListEvent>.privateRelays(relays: List<Norm
|
|||||||
|
|
||||||
fun TagArrayBuilder<RelaySetEvent>.relaySet(relays: List<NormalizedRelayUrl>) = addAll(relays.map { RelayTag.assemble(it) })
|
fun TagArrayBuilder<RelaySetEvent>.relaySet(relays: List<NormalizedRelayUrl>) = addAll(relays.map { RelayTag.assemble(it) })
|
||||||
|
|
||||||
fun TagArrayBuilder<FavoriteRelayListEvent>.favoriteRelays(relays: List<NormalizedRelayUrl>) = addAll(relays.map { RelayTag.assemble(it) })
|
fun TagArrayBuilder<RelayFeedsListEvent>.relayFeeds(relays: List<NormalizedRelayUrl>) = addAll(relays.map { RelayTag.assemble(it) })
|
||||||
|
|||||||
@@ -89,9 +89,9 @@ import com.vitorpamplona.quartz.nip51Lists.muteList.MuteListEvent
|
|||||||
import com.vitorpamplona.quartz.nip51Lists.peopleList.PeopleListEvent
|
import com.vitorpamplona.quartz.nip51Lists.peopleList.PeopleListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.BlockedRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.BroadcastRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.BroadcastRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.FavoriteRelayListEvent
|
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.ProxyRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.ProxyRelayListEvent
|
||||||
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayFeedsListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.TrustedRelayListEvent
|
||||||
import com.vitorpamplona.quartz.nip51Lists.relaySets.RelaySetEvent
|
import com.vitorpamplona.quartz.nip51Lists.relaySets.RelaySetEvent
|
||||||
import com.vitorpamplona.quartz.nip52Calendar.appt.day.CalendarDateSlotEvent
|
import com.vitorpamplona.quartz.nip52Calendar.appt.day.CalendarDateSlotEvent
|
||||||
@@ -199,7 +199,7 @@ class EventFactory {
|
|||||||
CalendarRSVPEvent.KIND -> CalendarRSVPEvent(id, pubKey, createdAt, tags, content, sig)
|
CalendarRSVPEvent.KIND -> CalendarRSVPEvent(id, pubKey, createdAt, tags, content, sig)
|
||||||
ChessGameEvent.KIND -> ChessGameEvent(id, pubKey, createdAt, tags, content, sig)
|
ChessGameEvent.KIND -> ChessGameEvent(id, pubKey, createdAt, tags, content, sig)
|
||||||
CodeSnippetEvent.KIND -> CodeSnippetEvent(id, pubKey, createdAt, tags, content, sig)
|
CodeSnippetEvent.KIND -> CodeSnippetEvent(id, pubKey, createdAt, tags, content, sig)
|
||||||
FavoriteRelayListEvent.KIND -> FavoriteRelayListEvent(id, pubKey, createdAt, tags, content, sig)
|
RelayFeedsListEvent.KIND -> RelayFeedsListEvent(id, pubKey, createdAt, tags, content, sig)
|
||||||
JesterEvent.KIND -> JesterEvent(id, pubKey, createdAt, tags, content, sig)
|
JesterEvent.KIND -> JesterEvent(id, pubKey, createdAt, tags, content, sig)
|
||||||
LiveChessGameChallengeEvent.KIND -> LiveChessGameChallengeEvent(id, pubKey, createdAt, tags, content, sig)
|
LiveChessGameChallengeEvent.KIND -> LiveChessGameChallengeEvent(id, pubKey, createdAt, tags, content, sig)
|
||||||
LiveChessGameAcceptEvent.KIND -> LiveChessGameAcceptEvent(id, pubKey, createdAt, tags, content, sig)
|
LiveChessGameAcceptEvent.KIND -> LiveChessGameAcceptEvent(id, pubKey, createdAt, tags, content, sig)
|
||||||
|
|||||||
Reference in New Issue
Block a user