From 546d238db3bfd750a55cdea9935f5ace81335ccc Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Wed, 2 Jul 2025 10:51:13 -0400 Subject: [PATCH] Reformats due to new lint --- .../vitorpamplona/amethyst/model/Account.kt | 81 +++++++++++++++---- .../amethyst/model/AccountSettings.kt | 5 +- .../amethyst/model/AccountSyncedSettings.kt | 4 +- .../model/emphChat/EphemeralChatListState.kt | 10 +-- .../model/localRelays/LocalRelayListState.kt | 4 +- .../FollowListOutboxRelays.kt | 38 +++++---- .../nip02FollowLists/FollowsPerOutboxRelay.kt | 29 +++---- .../nip28PublicChats/PublicChatListState.kt | 10 +-- .../model/nip51Lists/BlockPeopleListState.kt | 10 +-- .../model/nip51Lists/GeohashListState.kt | 10 +-- .../model/nip51Lists/HashtagListState.kt | 10 +-- .../model/nip51Lists/HiddenUsersState.kt | 5 +- .../model/nip51Lists/MuteListState.kt | 10 +-- .../nip65RelayList/OutboxRelaySetState.kt | 46 ++++++----- .../nip72Communities/CommunityListState.kt | 10 +-- .../serverList/MergedFollowListsState.kt | 27 +++---- .../MergedFollowPlusMineRelayListsState.kt | 28 +++---- .../model/serverList/MergedServerListState.kt | 3 +- .../serverList/TrustedRelayListsState.kt | 28 +++---- .../model/topNavFeeds/CommunityRelayLoader.kt | 26 ++++-- .../topNavFeeds/FeedTopNavFilterState.kt | 11 ++- .../MergedTopFeedAuthorListsState.kt | 13 ++- .../model/topNavFeeds/OutboxLoaderState.kt | 11 +-- .../model/topNavFeeds/OutboxRelayLoader.kt | 19 +++-- .../AllFollowsByOutboxTopNavFilter.kt | 9 +-- .../allFollows/AllFollowsFeedFlow.kt | 5 +- .../topNavFeeds/aroundMe/AroundMeFeedFlow.kt | 5 +- .../aroundMe/LocationTopNavFilter.kt | 9 +-- .../topNavFeeds/global/GlobalTopNavFilter.kt | 10 +-- .../hashtag/HashtagTopNavFilter.kt | 15 ++-- .../AllCommunitiesTopNavFilter.kt | 14 ++-- .../author/AuthorsByOutboxTopNavFilter.kt | 13 +-- .../community/SingleCommunityTopNavFilter.kt | 5 +- .../muted/MutedAuthorsByOutboxTopNavFilter.kt | 13 +-- .../unknown/UnknownTopNavFilter.kt | 4 +- .../model/torState/TorRelayEvaluation.kt | 5 +- .../amethyst/model/torState/TorRelayState.kt | 13 ++- .../amethyst/service/ZapPaymentHandler.kt | 9 +-- .../service/okhttp/ProxySettingsAnchor.kt | 2 +- .../relayClient/RelayProxyClientConnector.kt | 21 ++--- .../AccountGiftWrapsEoseManager.kt | 5 +- .../LiveActivityWatcherSubAssembly.kt | 5 +- .../watchers/EventWatcherSubAssembler.kt | 6 +- .../user/loaders/FilterUserMetadataForKey.kt | 5 +- .../user/watchers/FilterUserMetadataForKey.kt | 16 ++-- .../service/uploads/MediaCompressor.kt | 2 +- .../amethyst/ui/actions/EditPostView.kt | 6 +- .../amethyst/ui/actions/NewMediaView.kt | 9 ++- .../NormalizedRelayUrlSerializer.kt | 4 +- .../amethyst/ui/note/UpdateZapAmountDialog.kt | 3 +- .../amethyst/ui/note/UserProfilePicture.kt | 3 +- .../creators/uploads/ImageVideoDescription.kt | 3 +- .../ui/note/elements/DisplayHashtags.kt | 3 +- .../nip22Comments/CommentPostViewModel.kt | 24 +++--- .../amethyst/ui/note/types/CommunityHeader.kt | 3 +- .../ui/screen/loggedIn/AccountViewModel.kt | 44 +++++----- .../ui/screen/loggedIn/LoggedInPage.kt | 6 +- .../metadata/NewEphemeralChatMetaViewModel.kt | 3 +- .../FilterLastMessageFollowingPublicChats.kt | 53 ++++++------ .../rooms/datasource/FilterNip04DMsFromMe.kt | 5 +- .../rooms/datasource/FilterNip04DMsToMe.kt | 5 +- .../chats/utils/ChatFileUploadDialog.kt | 3 +- .../datasource/FilterCommunityPosts.kt | 5 +- .../nip23LongForm/SubAssemblyHelper.kt | 5 +- .../FilterLongFormByAllCommunities.kt | 15 ++-- .../subassemblies/FilterLongFormByAuthors.kt | 46 ++++++----- .../FilterLongFormByCommunity.kt | 17 ++-- .../subassemblies/FilterLongFormByGeohash.kt | 23 +++--- .../subassemblies/FilterLongFormByHashtag.kt | 23 +++--- .../discover/nip28Chats/SubAssemblyHelper.kt | 5 +- .../FilterPublicChatsByAllCommunities.kt | 15 ++-- .../FilterPublicChatsByAuthors.kt | 46 ++++++----- .../FilterPublicChatsByCommunity.kt | 17 ++-- .../FilterPublicChatsByGeohash.kt | 23 +++--- .../FilterPublicChatsByHashtag.kt | 23 +++--- .../nip51FollowSets/SubAssemblyHelper.kt | 5 +- .../FilterFollowSetsByAllCommunities.kt | 15 ++-- .../FilterFollowSetsByAuthors.kt | 46 ++++++----- .../FilterFollowSetsByCommunity.kt | 17 ++-- .../FilterFollowSetsByGeohash.kt | 23 +++--- .../FilterFollowSetsByHashtag.kt | 23 +++--- .../nip53LiveActivities/SubAssemblyHelper.kt | 5 +- .../FilterLiveActivitiesByAllCommunities.kt | 15 ++-- .../FilterLiveActivitiesByAuthors.kt | 46 ++++++----- .../FilterLiveActivitiesByCommunity.kt | 17 ++-- .../FilterLiveActivitiesByGeohash.kt | 23 +++--- .../FilterLiveActivitiesByHashtag.kt | 23 +++--- .../nip72Communities/SubAssemblyHelper.kt | 5 +- .../FilterCommunitiesByAllCommunities.kt | 15 ++-- .../FilterCommunitiesByAuthors.kt | 46 ++++++----- .../FilterCommunitiesByCommunity.kt | 17 ++-- .../FilterCommunitiesByGeohash.kt | 23 +++--- .../FilterCommunitiesByHashtag.kt | 23 +++--- .../discover/nip90DVMs/SubAssemblyHelper.kt | 5 +- .../FilterContentDVMsByAllCommunities.kt | 15 ++-- .../FilterContentDVMsByAuthors.kt | 46 ++++++----- .../FilterContentDVMsByCommunity.kt | 17 ++-- .../FilterContentDVMsByGeohash.kt | 23 +++--- .../FilterContentDVMsByHashtag.kt | 23 +++--- .../nip99Classifieds/NewProductViewModel.kt | 4 +- .../nip99Classifieds/SubAssemblyHelper.kt | 5 +- .../FilterClassifiedsByAllCommunities.kt | 15 ++-- .../FilterClassifiedsByAuthors.kt | 46 ++++++----- .../FilterClassifiedsByCommunity.kt | 17 ++-- .../FilterClassifiedsByGeohash.kt | 23 +++--- .../FilterClassifiedsByHashtag.kt | 23 +++--- .../loggedIn/geohash/dal/GeoHashFeedFilter.kt | 3 +- .../ui/screen/loggedIn/home/HomeScreen.kt | 7 +- .../loggedIn/home/ShortNotePostViewModel.kt | 4 +- .../loggedIn/home/dal/HomeLiveFilter.kt | 7 +- .../nip01Core/FilterHomePostsByGeohashes.kt | 29 +++---- .../nip01Core/FilterHomePostsByHashtags.kt | 31 +++---- .../nip65Follows/FilterHomePostsByAuthors.kt | 46 ++++++----- .../FilterHomePostsByAllCommunities.kt | 15 ++-- .../FilterHomePostsFromCommunities.kt | 17 ++-- .../datasource/FilterUserProfileFollowers.kt | 5 +- .../datasource/FilterUserProfileLists.kt | 5 +- .../datasource/FilterUserProfileMedia.kt | 5 +- .../datasource/FilterUserProfilePosts.kt | 53 ++++++------ .../FilterUserProfileZapReceived.kt | 5 +- .../relays/common/BasicRelaySetupInfo.kt | 5 +- .../relays/local/LocalRelayListViewModel.kt | 4 +- .../settings/SecurityFiltersScreen.kt | 6 +- .../settings/dal/SpammerAccountsFeedFilter.kt | 4 +- .../ui/screen/loggedIn/video/VideoScreen.kt | 4 +- .../FilterPictureAndVideoByGeohash.kt | 23 +++--- .../FilterPictureAndVideoByHashtag.kt | 23 +++--- .../FilterPictureAndVideoByAuthors.kt | 46 ++++++----- .../FilterPictureAndVideoByAllCommunities.kt | 15 ++-- .../FilterPictureAndVideoByCommunity.kt | 17 ++-- .../ammolite/relays/filters/MutableTime.kt | 4 +- .../relay/client/pool/RelayBasedFilter.kt | 5 +- .../client/single/simple/OutboxProtector.kt | 4 +- .../relay/normalizer/NormalizedRelayUrl.kt | 4 +- .../relay/normalizer/RelayUrlNormalizer.kt | 9 ++- .../quartz/nip10Notes/tags/MarkedETag.kt | 5 +- .../settings/ChatMessageRelayListEvent.kt | 6 +- .../admin/ChannelCreateEvent.kt | 9 +-- .../admin/ChannelMetadataEvent.kt | 9 +-- .../quartz/nip51Lists/MuteListEvent.kt | 5 +- .../quartz/nip51Lists/PeopleListEvent.kt | 5 +- .../RelayListRecommendationProcessor.kt | 10 +-- .../tags/AdvertisedRelayInfoTag.kt | 5 +- .../nip73ExternalIds/topics/HashtagId.kt | 10 +-- .../quartz/utils/MapOfSetBuilder.kt | 5 +- .../quartz/nip01Core/hints/HintIndexerTest.kt | 3 +- 146 files changed, 1151 insertions(+), 1054 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt index d4820c0a7..c430d92ac 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt @@ -463,7 +463,18 @@ class Account( if (!isWriteable()) return userMetadata.sendNewUserMetadata( - name, picture, banner, website, pronouns, about, nip05, lnAddress, lnURL, twitter, mastodon, github, + name, + picture, + banner, + website, + pronouns, + about, + nip05, + lnAddress, + lnURL, + twitter, + mastodon, + github, ::sendMyPublicAndPrivateOutbox, ) } @@ -582,11 +593,13 @@ class Account( relay = nip47.relayUri, ) - Amethyst.instance.sources.nwc.subscribe(filter) + Amethyst.instance.sources.nwc + .subscribe(filter) GlobalScope.launch(Dispatchers.IO) { delay(60000) // waits 1 minute to complete payment. - Amethyst.instance.sources.nwc.unsubscribe(filter) + Amethyst.instance.sources.nwc + .unsubscribe(filter) } cache.consume(event, zappedNote, true, nip47.relayUri) { @@ -723,7 +736,11 @@ class Account( if (pubkey == userProfile().pubkeyHex) { notificationRelays.flow.value } else { - LocalCache.getUserIfExists(pubkey)?.inboxRelays()?.ifEmpty { null }?.toSet() + LocalCache + .getUserIfExists(pubkey) + ?.inboxRelays() + ?.ifEmpty { null } + ?.toSet() ?: cache.relayHints.hintsForKey(pubkey).toSet() } } @@ -749,7 +766,10 @@ class Account( outboxRelays.flow.value } else { replyToAuthor.outboxRelays().ifEmpty { null }?.toSet() - ?: cache.relayHints.hintsForKey(replyToAuthor.pubkeyHex).ifEmpty { null }?.toSet() + ?: cache.relayHints + .hintsForKey(replyToAuthor.pubkeyHex) + .ifEmpty { null } + ?.toSet() ?: emptySet() } } else { @@ -776,11 +796,17 @@ class Account( outboxRelays.flow.value } else { author.outboxRelays().ifEmpty { null }?.toSet() - ?: cache.relayHints.hintsForKey(author.pubkeyHex).ifEmpty { null }?.toSet() + ?: cache.relayHints + .hintsForKey(author.pubkeyHex) + .ifEmpty { null } + ?.toSet() ?: emptySet() } } else { - cache.relayHints.hintsForKey(event.pubKey).ifEmpty { null }?.toSet() + cache.relayHints + .hintsForKey(event.pubKey) + .ifEmpty { null } + ?.toSet() emptySet() } @@ -789,7 +815,11 @@ class Account( if (pubkey == userProfile().pubkeyHex) { notificationRelays.flow.value } else { - LocalCache.getUserIfExists(pubkey)?.inboxRelays()?.ifEmpty { null }?.toSet() + LocalCache + .getUserIfExists(pubkey) + ?.inboxRelays() + ?.ifEmpty { null } + ?.toSet() ?: cache.relayHints.hintsForKey(pubkey).toSet() } } @@ -832,7 +862,10 @@ class Account( outboxRelays.flow.value } else { replyToAuthor.outboxRelays().ifEmpty { null }?.toSet() - ?: cache.relayHints.hintsForKey(replyToAuthor.pubkeyHex).ifEmpty { null }?.toSet() + ?: cache.relayHints + .hintsForKey(replyToAuthor.pubkeyHex) + .ifEmpty { null } + ?.toSet() ?: emptySet() } } else { @@ -854,7 +887,10 @@ class Account( outboxRelays.flow.value } else { author.outboxRelays().ifEmpty { null }?.toSet() - ?: cache.relayHints.hintsForKey(author.pubkeyHex).ifEmpty { null }?.toSet() + ?: cache.relayHints + .hintsForKey(author.pubkeyHex) + .ifEmpty { null } + ?.toSet() ?: emptySet() } } else { @@ -866,7 +902,11 @@ class Account( if (pubkey == userProfile().pubkeyHex) { notificationRelays.flow.value } else { - LocalCache.getUserIfExists(pubkey)?.inboxRelays()?.ifEmpty { null }?.toSet() + LocalCache + .getUserIfExists(pubkey) + ?.inboxRelays() + ?.ifEmpty { null } + ?.toSet() ?: cache.relayHints.hintsForKey(pubkey).toSet() } } ?: emptySet() @@ -892,7 +932,10 @@ class Account( outboxRelays.flow.value } else { replyToAuthor.outboxRelays().ifEmpty { null }?.toSet() - ?: cache.relayHints.hintsForKey(replyToAuthor.pubkeyHex).ifEmpty { null }?.toSet() + ?: cache.relayHints + .hintsForKey(replyToAuthor.pubkeyHex) + .ifEmpty { null } + ?.toSet() ?: emptySet() } } else { @@ -1675,7 +1718,11 @@ class Account( if (pubkey == userProfile().pubkeyHex) { notificationRelays.flow.value } else { - LocalCache.getUserIfExists(pubkey)?.inboxRelays()?.ifEmpty { null }?.toSet() + LocalCache + .getUserIfExists(pubkey) + ?.inboxRelays() + ?.ifEmpty { null } + ?.toSet() ?: cache.relayHints.hintsForKey(pubkey).toSet() } } @@ -1888,9 +1935,11 @@ class Account( val relays = nip65RelayList.inboxFlow.value.toSet() NIP90ContentDiscoveryRequestEvent.create(dvmPublicKey.pubkeyHex, signer.pubKey, relays, signer) { val relayList = - dvmPublicKey.inboxRelays().ifEmpty { - LocalCache.relayHints.hintsForKey(dvmPublicKey.pubkeyHex) - }.toSet() + dvmPublicKey + .inboxRelays() + .ifEmpty { + LocalCache.relayHints.hintsForKey(dvmPublicKey.pubkeyHex) + }.toSet() client.send(it, relayList) cache.justConsumeMyOwnEvent(it) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountSettings.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountSettings.kt index 2933b790f..4f19f92c0 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountSettings.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountSettings.kt @@ -250,14 +250,13 @@ class AccountSettings( // --- // proxy settings // --- - fun setTorSettings(newTorSettings: TorSettings): Boolean { - return if (torSettings.update(newTorSettings)) { + fun setTorSettings(newTorSettings: TorSettings): Boolean = + if (torSettings.update(newTorSettings)) { saveAccountSettings() true } else { false } - } // --- // language services diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountSyncedSettings.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountSyncedSettings.kt index 8ee4e293f..5029f6044 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountSyncedSettings.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/AccountSyncedSettings.kt @@ -114,9 +114,7 @@ class AccountSyncedSettings( } } - fun dontTranslateFromFilteredBySpokenLanguages(): Set { - return languages.dontTranslateFrom - getLanguagesSpokenByUser() - } + fun dontTranslateFromFilteredBySpokenLanguages(): Set = languages.dontTranslateFrom - getLanguagesSpokenByUser() } @Stable diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/emphChat/EphemeralChatListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/emphChat/EphemeralChatListState.kt index 52f9422d3..1117e70fd 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/emphChat/EphemeralChatListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/emphChat/EphemeralChatListState.kt @@ -59,19 +59,17 @@ class EphemeralChatListState( fun getEphemeralChatList(): EphemeralChatListEvent? = getEphemeralChatListNote().event as? EphemeralChatListEvent - suspend fun ephemeralChatListWithBackup(note: Note): Set { - return ephemeralChatList( + suspend fun ephemeralChatListWithBackup(note: Note): Set = + ephemeralChatList( note.event as? EphemeralChatListEvent ?: settings.backupEphemeralChatList, ) - } - suspend fun ephemeralChatList(event: EphemeralChatListEvent?): Set { - return tryAndWait { continuation -> + suspend fun ephemeralChatList(event: EphemeralChatListEvent?): Set = + tryAndWait { continuation -> event?.publicAndPrivateRoomIds(signer) { continuation.resume(it) } } ?: emptySet() - } @OptIn(ExperimentalCoroutinesApi::class) val liveEphemeralChatList: StateFlow> by lazy { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/localRelays/LocalRelayListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/localRelays/LocalRelayListState.kt index 88a49482e..dcdaa2b36 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/localRelays/LocalRelayListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/localRelays/LocalRelayListState.kt @@ -38,9 +38,7 @@ class LocalRelayListState( val scope: CoroutineScope, val settings: AccountSettings, ) { - fun normalizeLocalRelayListWithBackup(relayList: Set): Set { - return relayList.mapNotNull { RelayUrlNormalizer.normalizeOrNull(it) }.toSet() - } + fun normalizeLocalRelayListWithBackup(relayList: Set): Set = relayList.mapNotNull { RelayUrlNormalizer.normalizeOrNull(it) }.toSet() val flow = settings.localRelayServers diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip02FollowLists/FollowListOutboxRelays.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip02FollowLists/FollowListOutboxRelays.kt index ad63c5daf..32bab4160 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip02FollowLists/FollowListOutboxRelays.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip02FollowLists/FollowListOutboxRelays.kt @@ -68,15 +68,18 @@ class FollowListOutboxRelays( @OptIn(ExperimentalCoroutinesApi::class) val flow: StateFlow> = - kind3Follows.flow.transformLatest { followList -> - val flows: List> = allRelayListFlows(followList.authors) - val relayListFlows = combineAllFlows(flows) - emitAll(relayListFlows) - }.onStart { - kind3Follows.flow.value.authors.mapNotNull { - getNIP65RelayList(it)?.writeRelaysNorm() - }.flatten().toSet() - }.flowOn(Dispatchers.Default) + kind3Follows.flow + .transformLatest { followList -> + val flows: List> = allRelayListFlows(followList.authors) + val relayListFlows = combineAllFlows(flows) + emitAll(relayListFlows) + }.onStart { + kind3Follows.flow.value.authors + .mapNotNull { + getNIP65RelayList(it)?.writeRelaysNorm() + }.flatten() + .toSet() + }.flowOn(Dispatchers.Default) .stateIn( scope, SharingStarted.Eagerly, @@ -85,13 +88,16 @@ class FollowListOutboxRelays( @OptIn(ExperimentalCoroutinesApi::class) val flowSet: StateFlow> = - flow.map { relayList -> - relayList.map { it.url }.toSet() - }.onStart { - kind3Follows.flow.value.authors.mapNotNull { - getNIP65RelayList(it)?.writeRelaysNorm()?.map { it.url }?.toSet() - }.flatten().toSet() - }.flowOn(Dispatchers.Default) + flow + .map { relayList -> + relayList.map { it.url }.toSet() + }.onStart { + kind3Follows.flow.value.authors + .mapNotNull { + getNIP65RelayList(it)?.writeRelaysNorm()?.map { it.url }?.toSet() + }.flatten() + .toSet() + }.flowOn(Dispatchers.Default) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip02FollowLists/FollowsPerOutboxRelay.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip02FollowLists/FollowsPerOutboxRelay.kt index 89207b4ff..dfd57f996 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip02FollowLists/FollowsPerOutboxRelay.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip02FollowLists/FollowsPerOutboxRelay.kt @@ -71,21 +71,22 @@ class FollowsPerOutboxRelay( @OptIn(ExperimentalCoroutinesApi::class) val flow: StateFlow>> = - kind3Follows.flow.transformLatest { followList -> - val flows: List> = allRelayListFlows(followList.authors) - val relayListFlows = combineAllFlows(flows) - emitAll(relayListFlows) - }.onStart { - emit( - mapOfSet { - kind3Follows.flow.value.authors.map { authorHex -> - getNIP65RelayList(authorHex)?.writeRelaysNorm()?.forEach { relay -> - add(relay, authorHex) + kind3Follows.flow + .transformLatest { followList -> + val flows: List> = allRelayListFlows(followList.authors) + val relayListFlows = combineAllFlows(flows) + emitAll(relayListFlows) + }.onStart { + emit( + mapOfSet { + kind3Follows.flow.value.authors.map { authorHex -> + getNIP65RelayList(authorHex)?.writeRelaysNorm()?.forEach { relay -> + add(relay, authorHex) + } } - } - }, - ) - }.flowOn(Dispatchers.Default) + }, + ) + }.flowOn(Dispatchers.Default) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip28PublicChats/PublicChatListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip28PublicChats/PublicChatListState.kt index 5dd1f9cd9..96e6693f2 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip28PublicChats/PublicChatListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip28PublicChats/PublicChatListState.kt @@ -61,19 +61,17 @@ class PublicChatListState( fun getChannelList(): ChannelListEvent? = getChannelListNote().event as? ChannelListEvent - suspend fun publicChatListWithBackup(note: Note): Set { - return publicChatList( + suspend fun publicChatListWithBackup(note: Note): Set = + publicChatList( note.event as? ChannelListEvent ?: settings.backupChannelList, ) - } - suspend fun publicChatList(event: ChannelListEvent?): Set { - return tryAndWait { continuation -> + suspend fun publicChatList(event: ChannelListEvent?): Set = + tryAndWait { continuation -> event?.publicAndPrivateChannels(signer) { continuation.resume(it) } } ?: emptySet() - } @OptIn(ExperimentalCoroutinesApi::class) val flow: StateFlow> by lazy { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/BlockPeopleListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/BlockPeopleListState.kt index 148cec26b..e40ef0a77 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/BlockPeopleListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/BlockPeopleListState.kt @@ -49,19 +49,17 @@ class BlockPeopleListState( fun getBlockList(): PeopleListEvent? = getBlockListNote().event as? PeopleListEvent - suspend fun blockListWithBackup(note: Note): PeopleListEvent.UsersAndWords { - return blockList( + suspend fun blockListWithBackup(note: Note): PeopleListEvent.UsersAndWords = + blockList( note.event as? PeopleListEvent, ) - } - suspend fun blockList(event: PeopleListEvent?): PeopleListEvent.UsersAndWords { - return tryAndWait { continuation -> + suspend fun blockList(event: PeopleListEvent?): PeopleListEvent.UsersAndWords = + tryAndWait { continuation -> event?.publicAndPrivateUsersAndWords(signer) { continuation.resume(it) } } ?: PeopleListEvent.UsersAndWords() - } val flow = getBlockListFlow() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/GeohashListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/GeohashListState.kt index 3464486e4..3d2e4e6ec 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/GeohashListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/GeohashListState.kt @@ -57,19 +57,17 @@ class GeohashListState( fun getGeohashList(): GeohashListEvent? = getGeohashListNote().event as? GeohashListEvent - suspend fun geohashListWithBackup(note: Note): Set { - return geohashList( + suspend fun geohashListWithBackup(note: Note): Set = + geohashList( note.event as? GeohashListEvent ?: settings.backupGeohashList, ) - } - suspend fun geohashList(event: GeohashListEvent?): Set { - return tryAndWait { continuation -> + suspend fun geohashList(event: GeohashListEvent?): Set = + tryAndWait { continuation -> event?.publicAndPrivateGeohash(signer) { continuation.resume(it) } } ?: emptySet() - } @OptIn(ExperimentalCoroutinesApi::class) val flow: StateFlow> by lazy { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/HashtagListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/HashtagListState.kt index 65d18040e..6b3e09b29 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/HashtagListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/HashtagListState.kt @@ -57,19 +57,17 @@ class HashtagListState( fun getHashtagList(): HashtagListEvent? = getHashtagListNote().event as? HashtagListEvent - suspend fun hashtagListWithBackup(note: Note): Set { - return hashtagList( + suspend fun hashtagListWithBackup(note: Note): Set = + hashtagList( note.event as? HashtagListEvent ?: settings.backupHashtagList, ) - } - suspend fun hashtagList(event: HashtagListEvent?): Set { - return tryAndWait { continuation -> + suspend fun hashtagList(event: HashtagListEvent?): Set = + tryAndWait { continuation -> event?.publicAndPrivateHashtag(signer) { continuation.resume(it) } } ?: emptySet() - } @OptIn(ExperimentalCoroutinesApi::class) val flow: StateFlow> by lazy { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/HiddenUsersState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/HiddenUsersState.kt index 8a953176f..9888ba5e0 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/HiddenUsersState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/HiddenUsersState.kt @@ -65,14 +65,13 @@ class HiddenUsersState( muteList: PeopleListEvent.UsersAndWords, transientHiddenUsers: Set, showSensitiveContent: Boolean?, - ): LiveHiddenUsers { - return LiveHiddenUsers( + ): LiveHiddenUsers = + LiveHiddenUsers( hiddenUsers = blockList.users + muteList.users, hiddenWords = blockList.words + muteList.words, spammers = transientHiddenUsers, showSensitiveContent = showSensitiveContent, ) - } val flow: StateFlow by lazy { combineTransform( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/MuteListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/MuteListState.kt index 42e68cda7..c79549def 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/MuteListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip51Lists/MuteListState.kt @@ -56,19 +56,17 @@ class MuteListState( fun getMuteList(): MuteListEvent? = getMuteListNote().event as? MuteListEvent - suspend fun muteListWithBackup(note: Note): PeopleListEvent.UsersAndWords { - return muteList( + suspend fun muteListWithBackup(note: Note): PeopleListEvent.UsersAndWords = + muteList( note.event as? MuteListEvent ?: settings.backupMuteList, ) - } - suspend fun muteList(event: MuteListEvent?): PeopleListEvent.UsersAndWords { - return tryAndWait { continuation -> + suspend fun muteList(event: MuteListEvent?): PeopleListEvent.UsersAndWords = + tryAndWait { continuation -> event?.publicAndPrivateUsersAndWords(signer) { continuation.resume(it) } } ?: PeopleListEvent.UsersAndWords() - } val flow = getMuteListFlow() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip65RelayList/OutboxRelaySetState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip65RelayList/OutboxRelaySetState.kt index 6467b4c7b..8f37e8cf3 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip65RelayList/OutboxRelaySetState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip65RelayList/OutboxRelaySetState.kt @@ -67,17 +67,20 @@ class OutboxRelaySetState( @OptIn(ExperimentalCoroutinesApi::class) val flow: StateFlow> = - usersToLoad.transformLatest { followList -> - val flows: List> = allRelayListFlows(followList) - val relayListFlows = combineAllFlows(flows) - emitAll(relayListFlows) - }.onStart { - emit( - usersToLoad.value.mapNotNull { - getNIP65RelayList(it)?.writeRelaysNorm() - }.flatten().toSet(), - ) - }.flowOn(Dispatchers.Default) + usersToLoad + .transformLatest { followList -> + val flows: List> = allRelayListFlows(followList) + val relayListFlows = combineAllFlows(flows) + emitAll(relayListFlows) + }.onStart { + emit( + usersToLoad.value + .mapNotNull { + getNIP65RelayList(it)?.writeRelaysNorm() + }.flatten() + .toSet(), + ) + }.flowOn(Dispatchers.Default) .stateIn( scope, SharingStarted.Companion.Eagerly, @@ -86,15 +89,18 @@ class OutboxRelaySetState( @OptIn(ExperimentalCoroutinesApi::class) val flowSet: StateFlow> = - flow.map { relayList -> - relayList.map { it.url }.toSet() - }.onStart { - emit( - usersToLoad.value.mapNotNull { - getNIP65RelayList(it)?.writeRelaysNorm()?.map { it.url }?.toSet() - }.flatten().toSet(), - ) - }.flowOn(Dispatchers.Default) + flow + .map { relayList -> + relayList.map { it.url }.toSet() + }.onStart { + emit( + usersToLoad.value + .mapNotNull { + getNIP65RelayList(it)?.writeRelaysNorm()?.map { it.url }?.toSet() + }.flatten() + .toSet(), + ) + }.flowOn(Dispatchers.Default) .stateIn( scope, SharingStarted.Companion.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip72Communities/CommunityListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip72Communities/CommunityListState.kt index 375c88034..84f127155 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip72Communities/CommunityListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/nip72Communities/CommunityListState.kt @@ -60,19 +60,17 @@ class CommunityListState( fun getCommunityList(): CommunityListEvent? = getCommunityListNote().event as? CommunityListEvent - suspend fun communityListWithBackup(note: Note): Set { - return communityList( + suspend fun communityListWithBackup(note: Note): Set = + communityList( note.event as? CommunityListEvent ?: settings.backupCommunityList, ) - } - suspend fun communityList(event: CommunityListEvent?): Set { - return tryAndWait { continuation -> + suspend fun communityList(event: CommunityListEvent?): Set = + tryAndWait { continuation -> event?.publicAndPrivateCommunities(signer) { continuation.resume(it) } } ?: emptySet() - } @OptIn(ExperimentalCoroutinesApi::class) val flow: StateFlow> by lazy { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedFollowListsState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedFollowListsState.kt index 663b8adac..ccee0916e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedFollowListsState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedFollowListsState.kt @@ -46,15 +46,14 @@ class MergedFollowListsState( hashtages: Set, geohashes: Set, community: Set, - ): FollowListState.Kind3Follows { - return FollowListState.Kind3Follows( + ): FollowListState.Kind3Follows = + FollowListState.Kind3Follows( kind3.authors, kind3.authorsPlusMe, kind3.hashtags + hashtages, kind3.geotags + geohashes, kind3.communities + community.map { it.addressId }, ) - } val flow: StateFlow = combine( @@ -64,18 +63,16 @@ class MergedFollowListsState( communityList.flow, ) { kind3, hashtag, geohash, community -> mergeLists(kind3, hashtag, geohash, community) - } - .onStart { - emit( - mergeLists( - kind3List.flow.value, - hashtagList.flow.value, - geohashList.flow.value, - communityList.flow.value, - ), - ) - } - .flowOn(Dispatchers.Default) + }.onStart { + emit( + mergeLists( + kind3List.flow.value, + hashtagList.flow.value, + geohashList.flow.value, + communityList.flow.value, + ), + ) + }.flowOn(Dispatchers.Default) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedFollowPlusMineRelayListsState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedFollowPlusMineRelayListsState.kt index 714c7d23a..1fdb93266 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedFollowPlusMineRelayListsState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedFollowPlusMineRelayListsState.kt @@ -47,9 +47,7 @@ class MergedFollowPlusMineRelayListsState( inbox: Set, private: Set, local: Set, - ): Set { - return kind3 + outbox + inbox + private + local - } + ): Set = kind3 + outbox + inbox + private + local val flow: StateFlow> = combine( @@ -59,19 +57,17 @@ class MergedFollowPlusMineRelayListsState( privateOutboxRelayList.flow, localRelayList.flow, ::mergeLists, - ) - .onStart { - emit( - mergeLists( - followsOutboxRelayList.flow.value, - nip65RelayList.outboxFlow.value, - nip65RelayList.inboxFlow.value, - privateOutboxRelayList.flow.value, - localRelayList.flow.value, - ), - ) - } - .flowOn(Dispatchers.Default) + ).onStart { + emit( + mergeLists( + followsOutboxRelayList.flow.value, + nip65RelayList.outboxFlow.value, + nip65RelayList.inboxFlow.value, + privateOutboxRelayList.flow.value, + localRelayList.flow.value, + ), + ) + }.flowOn(Dispatchers.Default) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedServerListState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedServerListState.kt index 995ca9a61..599487b36 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedServerListState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/MergedServerListState.kt @@ -62,8 +62,7 @@ class MergedServerListState( val liveServerList: StateFlow> by lazy { combine(fileServers, blossomServers) { nip96s, blossoms -> mergeServerList(nip96s, blossoms) - } - .onStart { emit(mergeServerList(fileServers.value, blossomServers.value)) } + }.onStart { emit(mergeServerList(fileServers.value, blossomServers.value)) } .flowOn(Dispatchers.Default) .stateIn( scope, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/TrustedRelayListsState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/TrustedRelayListsState.kt index 95afd5395..ba3a5984c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/TrustedRelayListsState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/serverList/TrustedRelayListsState.kt @@ -49,9 +49,7 @@ class TrustedRelayListsState( local: Set, dm: Set, search: Set, - ): Set { - return nip65 + private + local + dm + search - } + ): Set = nip65 + private + local + dm + search val flow: StateFlow> = combine( @@ -61,19 +59,17 @@ class TrustedRelayListsState( dmRelayList.flow, searchRelayListState.flow, ::mergeLists, - ) - .onStart { - emit( - mergeLists( - nip65RelayList.allFlow.value, - privateOutboxRelayList.flow.value, - localRelayList.flow.value, - dmRelayList.flow.value, - searchRelayListState.flow.value, - ), - ) - } - .flowOn(Dispatchers.Default) + ).onStart { + emit( + mergeLists( + nip65RelayList.allFlow.value, + privateOutboxRelayList.flow.value, + localRelayList.flow.value, + dmRelayList.flow.value, + searchRelayListState.flow.value, + ), + ) + }.flowOn(Dispatchers.Default) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/CommunityRelayLoader.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/CommunityRelayLoader.kt index 1d11b9680..a49b4db54 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/CommunityRelayLoader.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/CommunityRelayLoader.kt @@ -36,11 +36,12 @@ class CommunityRelayLoader { fun communitiesPerRelay( communityNotes: Array, cache: LocalCache, - ): Map> { - return mapOfSet { + ): Map> = + mapOfSet { communityNotes.forEach { communityNote -> val relays = - (communityNote.note.event as? CommunityDefinitionEvent)?.relayUrls() + (communityNote.note.event as? CommunityDefinitionEvent) + ?.relayUrls() ?.ifEmpty { null } ?: cache.relayHints.hintsForAddress(communityNote.note.idHex) @@ -49,7 +50,6 @@ class CommunityRelayLoader { } } } - } fun communitiesPerRelaySnapshot( communities: Set, @@ -57,9 +57,15 @@ class CommunityRelayLoader { transformation: (Map>) -> T, ): T { val noteMetadata = - communities.mapNotNull { addressId -> - cache.checkGetOrCreateAddressableNote(addressId)?.flow()?.metadata?.stateFlow?.value - }.toTypedArray() + communities + .mapNotNull { addressId -> + cache + .checkGetOrCreateAddressableNote(addressId) + ?.flow() + ?.metadata + ?.stateFlow + ?.value + }.toTypedArray() return transformation(communitiesPerRelay(noteMetadata, cache)) } @@ -70,7 +76,11 @@ class CommunityRelayLoader { ): Flow { val noteMetadataFlows = communities.mapNotNull { addressId -> - cache.checkGetOrCreateAddressableNote(addressId)?.flow()?.metadata?.stateFlow + cache + .checkGetOrCreateAddressableNote(addressId) + ?.flow() + ?.metadata + ?.stateFlow } return combine(noteMetadataFlows) { communityNotes -> diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/FeedTopNavFilterState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/FeedTopNavFilterState.kt index 4f7fa4750..b4dea3cf8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/FeedTopNavFilterState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/FeedTopNavFilterState.kt @@ -71,13 +71,12 @@ class FeedTopNavFilterState( @OptIn(ExperimentalCoroutinesApi::class) val flow: StateFlow = - feedFilterListName.transformLatest { listName -> - emitAll(loadFlowsFor(listName).flow()) - } - .onStart { + feedFilterListName + .transformLatest { listName -> + emitAll(loadFlowsFor(listName).flow()) + }.onStart { loadFlowsFor(feedFilterListName.value).startValue(this) - } - .flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.Default) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/MergedTopFeedAuthorListsState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/MergedTopFeedAuthorListsState.kt index 8d125d98a..06565733b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/MergedTopFeedAuthorListsState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/MergedTopFeedAuthorListsState.kt @@ -47,8 +47,8 @@ class MergedTopFeedAuthorListsState( val notificationNavFilter: StateFlow, val scope: CoroutineScope, ) { - fun authorList(navFilter: IFeedTopNavPerRelayFilterSet): Map?> { - return when (navFilter) { + fun authorList(navFilter: IFeedTopNavPerRelayFilterSet): Map?> = + when (navFilter) { is AllCommunitiesTopNavPerRelayFilterSet -> emptyMap() is AllFollowsByOutboxTopNavPerRelayFilterSet -> navFilter.set.mapValues { it.value.authors } is AuthorsByOutboxTopNavPerRelayFilterSet -> navFilter.set.mapValues { it.value.authors } @@ -59,15 +59,14 @@ class MergedTopFeedAuthorListsState( is SingleCommunityTopNavPerRelayFilterSet -> navFilter.set.mapValues { it.value.authors } else -> emptyMap() } - } fun mergeLists( homeNavFilter: IFeedTopNavPerRelayFilterSet, videoNavFilter: IFeedTopNavPerRelayFilterSet, discoveryNavFilter: IFeedTopNavPerRelayFilterSet, notificationNavFilter: IFeedTopNavPerRelayFilterSet, - ): Map> { - return mapOfSet { + ): Map> = + mapOfSet { authorList(homeNavFilter).forEach { (relay, authors) -> authors?.let { add(relay, authors) } } @@ -84,7 +83,6 @@ class MergedTopFeedAuthorListsState( authors?.let { add(relay, authors) } } } - } val flow: StateFlow>> = combine( @@ -102,8 +100,7 @@ class MergedTopFeedAuthorListsState( notificationNavFilter.value, ), ) - } - .flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.Default) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/OutboxLoaderState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/OutboxLoaderState.kt index 9a68e1e63..257fdccf0 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/OutboxLoaderState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/OutboxLoaderState.kt @@ -40,11 +40,12 @@ class OutboxLoaderState( ) { @OptIn(ExperimentalCoroutinesApi::class) val flow: StateFlow = - topNavFilter.transformLatest { filterSettings -> - emitAll(filterSettings.toPerRelayFlow(cache)) - }.onStart { - emit(topNavFilter.value.startValue(cache)) - }.flowOn(Dispatchers.Default) + topNavFilter + .transformLatest { filterSettings -> + emitAll(filterSettings.toPerRelayFlow(cache)) + }.onStart { + emit(topNavFilter.value.startValue(cache)) + }.flowOn(Dispatchers.Default) .stateIn( scope, SharingStarted.Companion.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/OutboxRelayLoader.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/OutboxRelayLoader.kt index 11e520899..faa7fff9e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/OutboxRelayLoader.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/OutboxRelayLoader.kt @@ -35,19 +35,20 @@ class OutboxRelayLoader { private fun authorsPerRelay( outboxRelayNotes: Array, cache: LocalCache, - ): Map> { - return mapOfSet { + ): Map> = + mapOfSet { outboxRelayNotes.forEach { outboxNote -> val relays = (outboxNote.note.event as? AdvertisedRelayListEvent)?.writeRelaysNorm()?.ifEmpty { null } - ?: outboxNote.note.author?.pubkeyHex ?.let { cache.relayHints.hintsForKey(it) } + ?: outboxNote.note.author + ?.pubkeyHex + ?.let { cache.relayHints.hintsForKey(it) } relays?.forEach { add(it, outboxNote.note.idHex) } } } - } fun authorsPerRelaySnapshot( authors: Set, @@ -55,9 +56,13 @@ class OutboxRelayLoader { transformation: (Map>) -> T, ): T { val noteMetadata = - authors.map { pubkeyHex -> - cache.getOrCreateAddressableNote(AdvertisedRelayListEvent.createAddress(pubkeyHex)).flow().metadata.stateFlow.value - }.toTypedArray() + authors + .map { pubkeyHex -> + cache + .getOrCreateAddressableNote(AdvertisedRelayListEvent.createAddress(pubkeyHex)) + .flow() + .metadata.stateFlow.value + }.toTypedArray() return transformation(authorsPerRelay(noteMetadata, cache)) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/allFollows/AllFollowsByOutboxTopNavFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/allFollows/AllFollowsByOutboxTopNavFilter.kt index 2d6515f07..b840ce75d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/allFollows/AllFollowsByOutboxTopNavFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/allFollows/AllFollowsByOutboxTopNavFilter.kt @@ -54,12 +54,10 @@ class AllFollowsByOutboxTopNavFilter( val geotagScopes: Set? = geotags?.mapTo(mutableSetOf()) { GeohashId.Companion.toScope(it) } val hashtagScopes: Set? = hashtags?.mapTo(mutableSetOf()) { HashtagId.Companion.toScope(it) } - override fun matchAuthor(pubkey: HexKey): Boolean { - return authors == null || pubkey in authors - } + override fun matchAuthor(pubkey: HexKey): Boolean = authors == null || pubkey in authors - override fun match(noteEvent: Event): Boolean { - return if (noteEvent is LiveActivitiesEvent) { + override fun match(noteEvent: Event): Boolean = + if (noteEvent is LiveActivitiesEvent) { (authors != null && noteEvent.participantsIntersect(authors)) || (hashtags != null && noteEvent.isTaggedHashes(hashtags)) || (geotags != null && noteEvent.isTaggedGeoHashes(geotags)) || @@ -78,7 +76,6 @@ class AllFollowsByOutboxTopNavFilter( (geotags != null && noteEvent.isTaggedGeoHashes(geotags)) || (communities != null && noteEvent.isTaggedAddressableNotes(communities)) } - } override fun toPerRelayFlow(cache: LocalCache): Flow { val authorsPerRelay = diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/allFollows/AllFollowsFeedFlow.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/allFollows/AllFollowsFeedFlow.kt index ed162f657..8052cb276 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/allFollows/AllFollowsFeedFlow.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/allFollows/AllFollowsFeedFlow.kt @@ -32,8 +32,8 @@ class AllFollowsFeedFlow( val allFollows: StateFlow, val followsRelays: StateFlow>, ) : IFeedFlowsType { - fun convert(kind3: FollowListState.Kind3Follows?): AllFollowsByOutboxTopNavFilter { - return if (kind3 != null) { + fun convert(kind3: FollowListState.Kind3Follows?): AllFollowsByOutboxTopNavFilter = + if (kind3 != null) { AllFollowsByOutboxTopNavFilter( authors = kind3.authors, hashtags = kind3.hashtags, @@ -47,7 +47,6 @@ class AllFollowsFeedFlow( defaultRelays = followsRelays, ) } - } override fun flow() = allFollows.map(::convert) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/aroundMe/AroundMeFeedFlow.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/aroundMe/AroundMeFeedFlow.kt index 51207c028..28db5545f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/aroundMe/AroundMeFeedFlow.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/aroundMe/AroundMeFeedFlow.kt @@ -32,8 +32,8 @@ class AroundMeFeedFlow( val location: StateFlow, val allFollowRelays: StateFlow>, ) : IFeedFlowsType { - fun convert(result: LocationState.LocationResult): LocationTopNavFilter { - return if (result is LocationState.LocationResult.Success) { + fun convert(result: LocationState.LocationResult): LocationTopNavFilter = + if (result is LocationState.LocationResult.Success) { // 2 neighbors deep = 25x25km LocationTopNavFilter( geotags = compute50kmRange(result.geoHash).toSet(), @@ -46,7 +46,6 @@ class AroundMeFeedFlow( relays = allFollowRelays, ) } - } override fun flow() = location.map(::convert) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/aroundMe/LocationTopNavFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/aroundMe/LocationTopNavFilter.kt index 3016de162..641f3a521 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/aroundMe/LocationTopNavFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/aroundMe/LocationTopNavFilter.kt @@ -53,13 +53,10 @@ class LocationTopNavFilter( } } - override fun toPerRelayFlow(cache: LocalCache): Flow { - return relays.map { + override fun toPerRelayFlow(cache: LocalCache): Flow = + relays.map { LocationTopNavPerRelayFilterSet(it.associateWith { LocationTopNavPerRelayFilter(geotags) }) } - } - override fun startValue(cache: LocalCache): LocationTopNavPerRelayFilterSet { - return LocationTopNavPerRelayFilterSet(relays.value.associateWith { LocationTopNavPerRelayFilter(geotags) }) - } + override fun startValue(cache: LocalCache): LocationTopNavPerRelayFilterSet = LocationTopNavPerRelayFilterSet(relays.value.associateWith { LocationTopNavPerRelayFilter(geotags) }) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/global/GlobalTopNavFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/global/GlobalTopNavFilter.kt index a8ab72b43..64a53643c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/global/GlobalTopNavFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/global/GlobalTopNavFilter.kt @@ -38,15 +38,13 @@ class GlobalTopNavFilter( override fun match(noteEvent: Event) = true - override fun toPerRelayFlow(cache: LocalCache): Flow { - return relays.map { + override fun toPerRelayFlow(cache: LocalCache): Flow = + relays.map { GlobalTopNavPerRelayFilterSet(it.associateWith { GlobalTopNavPerRelayFilter }) } - } - override fun startValue(cache: LocalCache): GlobalTopNavPerRelayFilterSet { - return GlobalTopNavPerRelayFilterSet( + override fun startValue(cache: LocalCache): GlobalTopNavPerRelayFilterSet = + GlobalTopNavPerRelayFilterSet( relays.value.associateWith { GlobalTopNavPerRelayFilter }, ) - } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/hashtag/HashtagTopNavFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/hashtag/HashtagTopNavFilter.kt index c261a3458..d13b66bed 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/hashtag/HashtagTopNavFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/hashtag/HashtagTopNavFilter.kt @@ -42,27 +42,24 @@ class HashtagTopNavFilter( override fun matchAuthor(pubkey: HexKey): Boolean = true - override fun match(noteEvent: Event): Boolean { - return if (noteEvent is CommentEvent) { + override fun match(noteEvent: Event): Boolean = + if (noteEvent is CommentEvent) { noteEvent.isTaggedHashes(hashtags) || noteEvent.isTaggedScopes(hashtagScopes) } else { noteEvent.isTaggedHashes(hashtags) } - } - override fun toPerRelayFlow(cache: LocalCache): Flow { - return relays.map { + override fun toPerRelayFlow(cache: LocalCache): Flow = + relays.map { HashtagTopNavPerRelayFilterSet( it.associateWith { HashtagTopNavPerRelayFilter(hashtags) }, ) } - } - override fun startValue(cache: LocalCache): HashtagTopNavPerRelayFilterSet { - return HashtagTopNavPerRelayFilterSet( + override fun startValue(cache: LocalCache): HashtagTopNavPerRelayFilterSet = + HashtagTopNavPerRelayFilterSet( relays.value.associateWith { HashtagTopNavPerRelayFilter(hashtags) }, ) - } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/noteBased/allcommunities/AllCommunitiesTopNavFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/noteBased/allcommunities/AllCommunitiesTopNavFilter.kt index 0dca95f15..741ef9068 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/noteBased/allcommunities/AllCommunitiesTopNavFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/noteBased/allcommunities/AllCommunitiesTopNavFilter.kt @@ -36,24 +36,20 @@ class AllCommunitiesTopNavFilter( ) : IFeedTopNavFilter { override fun matchAuthor(pubkey: HexKey): Boolean = true - override fun match(noteEvent: Event): Boolean { - return noteEvent.isTaggedAddressableNotes(communities) - } + override fun match(noteEvent: Event): Boolean = noteEvent.isTaggedAddressableNotes(communities) fun convert(map: Map>) = AllCommunitiesTopNavPerRelayFilterSet( map.mapValues { AllCommunitiesTopNavPerRelayFilter(it.value) }, ) - override fun toPerRelayFlow(cache: LocalCache): Flow { - return CommunityRelayLoader.toCommunitiesPerRelayFlow(communities, cache) { + override fun toPerRelayFlow(cache: LocalCache): Flow = + CommunityRelayLoader.toCommunitiesPerRelayFlow(communities, cache) { convert(it) } - } - override fun startValue(cache: LocalCache): AllCommunitiesTopNavPerRelayFilterSet { - return CommunityRelayLoader.communitiesPerRelaySnapshot(communities, cache) { + override fun startValue(cache: LocalCache): AllCommunitiesTopNavPerRelayFilterSet = + CommunityRelayLoader.communitiesPerRelaySnapshot(communities, cache) { convert(it) } - } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/noteBased/author/AuthorsByOutboxTopNavFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/noteBased/author/AuthorsByOutboxTopNavFilter.kt index 14697499b..e6b2e5c1c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/noteBased/author/AuthorsByOutboxTopNavFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/noteBased/author/AuthorsByOutboxTopNavFilter.kt @@ -36,24 +36,19 @@ class AuthorsByOutboxTopNavFilter( ) : IFeedTopNavFilter { override fun matchAuthor(pubkey: HexKey) = pubkey in authors - override fun match(noteEvent: Event): Boolean { - return if (noteEvent is LiveActivitiesEvent) { + override fun match(noteEvent: Event): Boolean = + if (noteEvent is LiveActivitiesEvent) { noteEvent.participantsIntersect(authors) } else { noteEvent.pubKey in authors } - } fun convert(map: Map>) = AuthorsByOutboxTopNavPerRelayFilterSet( map.mapValues { AuthorsByOutboxTopNavPerRelayFilter(it.value) }, ) - override fun toPerRelayFlow(cache: LocalCache): Flow { - return OutboxRelayLoader.toAuthorsPerRelayFlow(authors, cache, ::convert) - } + override fun toPerRelayFlow(cache: LocalCache): Flow = OutboxRelayLoader.toAuthorsPerRelayFlow(authors, cache, ::convert) - override fun startValue(cache: LocalCache): AuthorsByOutboxTopNavPerRelayFilterSet { - return OutboxRelayLoader.authorsPerRelaySnapshot(authors, cache, ::convert) - } + override fun startValue(cache: LocalCache): AuthorsByOutboxTopNavPerRelayFilterSet = OutboxRelayLoader.authorsPerRelaySnapshot(authors, cache, ::convert) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/noteBased/community/SingleCommunityTopNavFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/noteBased/community/SingleCommunityTopNavFilter.kt index 3d7016192..273d373b8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/noteBased/community/SingleCommunityTopNavFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/noteBased/community/SingleCommunityTopNavFilter.kt @@ -41,15 +41,14 @@ class SingleCommunityTopNavFilter( ) : IFeedTopNavFilter { override fun matchAuthor(pubkey: HexKey) = authors == null || pubkey in authors - override fun match(noteEvent: Event): Boolean { - return if (noteEvent is LiveActivitiesEvent) { + override fun match(noteEvent: Event): Boolean = + if (noteEvent is LiveActivitiesEvent) { (authors != null && noteEvent.participantsIntersect(authors)) || noteEvent.isTaggedAddressableNote(community) } else if (noteEvent is CommentEvent) { (authors != null && noteEvent.pubKey in authors) || noteEvent.isTaggedAddressableNote(community) } else { (authors != null && noteEvent.pubKey in authors) || noteEvent.isTaggedAddressableNote(community) } - } override fun toPerRelayFlow(cache: LocalCache): Flow { // relay field takes priority diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/noteBased/muted/MutedAuthorsByOutboxTopNavFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/noteBased/muted/MutedAuthorsByOutboxTopNavFilter.kt index d98676d6d..d90db485d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/noteBased/muted/MutedAuthorsByOutboxTopNavFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/noteBased/muted/MutedAuthorsByOutboxTopNavFilter.kt @@ -36,24 +36,19 @@ class MutedAuthorsByOutboxTopNavFilter( ) : IFeedTopNavFilter { override fun matchAuthor(pubkey: HexKey) = pubkey in authors - override fun match(noteEvent: Event): Boolean { - return if (noteEvent is LiveActivitiesEvent) { + override fun match(noteEvent: Event): Boolean = + if (noteEvent is LiveActivitiesEvent) { noteEvent.participantsIntersect(authors) } else { noteEvent.pubKey in authors } - } fun convert(map: Map>) = MutedAuthorsByOutboxTopNavPerRelayFilterSet( map.mapValues { MutedAuthorsByOutboxTopNavPerRelayFilter(it.value) }, ) - override fun toPerRelayFlow(cache: LocalCache): Flow { - return OutboxRelayLoader.toAuthorsPerRelayFlow(authors, cache, ::convert) - } + override fun toPerRelayFlow(cache: LocalCache): Flow = OutboxRelayLoader.toAuthorsPerRelayFlow(authors, cache, ::convert) - override fun startValue(cache: LocalCache): MutedAuthorsByOutboxTopNavPerRelayFilterSet { - return OutboxRelayLoader.authorsPerRelaySnapshot(authors, cache, ::convert) - } + override fun startValue(cache: LocalCache): MutedAuthorsByOutboxTopNavPerRelayFilterSet = OutboxRelayLoader.authorsPerRelaySnapshot(authors, cache, ::convert) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/unknown/UnknownTopNavFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/unknown/UnknownTopNavFilter.kt index 0699da58b..c20e5793f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/unknown/UnknownTopNavFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/topNavFeeds/unknown/UnknownTopNavFilter.kt @@ -36,9 +36,7 @@ class UnknownTopNavFilter( override fun match(noteEvent: Event) = false - override fun toPerRelayFlow(cache: LocalCache): Flow { - return MutableStateFlow(UnknownTopNavPerRelayFilterSet) - } + override fun toPerRelayFlow(cache: LocalCache): Flow = MutableStateFlow(UnknownTopNavPerRelayFilterSet) override fun startValue(cache: LocalCache) = UnknownTopNavPerRelayFilterSet } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/torState/TorRelayEvaluation.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/torState/TorRelayEvaluation.kt index db2277eb8..1041e69cc 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/torState/TorRelayEvaluation.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/torState/TorRelayEvaluation.kt @@ -30,8 +30,8 @@ class TorRelayEvaluation( val trustedRelayList: Set, val dmRelayList: Set, ) { - fun useTor(relay: NormalizedRelayUrl): Boolean { - return if (torSettings.torType == TorType.OFF) { + fun useTor(relay: NormalizedRelayUrl): Boolean = + if (torSettings.torType == TorType.OFF) { false } else { if (relay.isLocalHost()) { @@ -46,5 +46,4 @@ class TorRelayEvaluation( torSettings.newRelaysViaTor } } - } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/torState/TorRelayState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/torState/TorRelayState.kt index daa838448..3358e4699 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/torState/TorRelayState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/torState/TorRelayState.kt @@ -48,11 +48,11 @@ class TorRelayState( settings.torSettings.trustedRelaysViaTor, settings.torSettings.newRelaysViaTor, ) { - torType: TorType, - onionRelaysViaTor: Boolean, - dmRelaysViaTor: Boolean, - trustedRelaysViaTor: Boolean, - newRelaysViaTor: Boolean, + torType: TorType, + onionRelaysViaTor: Boolean, + dmRelaysViaTor: Boolean, + trustedRelaysViaTor: Boolean, + newRelaysViaTor: Boolean, -> TorRelaySettings(torType, onionRelaysViaTor, dmRelaysViaTor, trustedRelaysViaTor, newRelaysViaTor) }.onStart { @@ -65,8 +65,7 @@ class TorRelayState( settings.torSettings.newRelaysViaTor.value, ), ) - } - .flowOn(Dispatchers.Default) + }.flowOn(Dispatchers.Default) .stateIn( scope, SharingStarted.Eagerly, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/ZapPaymentHandler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/ZapPaymentHandler.kt index 844a5e6e1..505fb75f9 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/ZapPaymentHandler.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/ZapPaymentHandler.kt @@ -175,15 +175,14 @@ class ZapPaymentHandler( val user: User? = null, ) - fun receivingRelaySet(userHex: HexKey): Set? { - return ( + fun receivingRelaySet(userHex: HexKey): Set? = + ( LocalCache .getAddressableNoteIfExists( AdvertisedRelayListEvent.createAddressTag(userHex), )?.event as? AdvertisedRelayListEvent - ) - ?.readRelaysNorm()?.toSet() - } + )?.readRelaysNorm() + ?.toSet() suspend fun signAllZapRequests( note: Note, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/okhttp/ProxySettingsAnchor.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/okhttp/ProxySettingsAnchor.kt index 61133f089..37af51d96 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/okhttp/ProxySettingsAnchor.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/okhttp/ProxySettingsAnchor.kt @@ -26,7 +26,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow -class ProxySettingsAnchor() { +class ProxySettingsAnchor { val flow: MutableStateFlow> = MutableStateFlow( MutableStateFlow( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/RelayProxyClientConnector.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/RelayProxyClientConnector.kt index 4881062a9..fdc54672d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/RelayProxyClientConnector.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/RelayProxyClientConnector.kt @@ -53,16 +53,17 @@ class RelayProxyClientConnector( connManager.status, ) { torSettings, torConnection, clearConnection, connectivity -> torSettings.hashCode() + torConnection.hashCode() + clearConnection.hashCode() + connectivity.hashCode() - }.debounce(100).onEach { - Log.d("ManageRelayServices", "Relay Services have changed") - client.reconnect(true) - }.onStart { - Log.d("ManageRelayServices", "Resuming Relay Services") - client.connect() - }.onCompletion { - Log.d("ManageRelayServices", "Pausing Relay Services") - client.disconnect() - }.flowOn(Dispatchers.IO) + }.debounce(100) + .onEach { + Log.d("ManageRelayServices", "Relay Services have changed") + client.reconnect(true) + }.onStart { + Log.d("ManageRelayServices", "Resuming Relay Services") + client.connect() + }.onCompletion { + Log.d("ManageRelayServices", "Pausing Relay Services") + client.disconnect() + }.flowOn(Dispatchers.IO) .stateIn( scope, SharingStarted.WhileSubscribed(30000), diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/nip59GiftWraps/AccountGiftWrapsEoseManager.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/nip59GiftWraps/AccountGiftWrapsEoseManager.kt index 3bcc0e039..0622fac81 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/nip59GiftWraps/AccountGiftWrapsEoseManager.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/nip59GiftWraps/AccountGiftWrapsEoseManager.kt @@ -43,15 +43,14 @@ class AccountGiftWrapsEoseManager( override fun updateFilter( key: AccountQueryState, since: SincePerRelayMap?, - ): List { - return key.account.dmRelays.flow.value.flatMap { relay -> + ): List = + key.account.dmRelays.flow.value.flatMap { relay -> filterGiftWrapsToPubkey( relay = relay, pubkey = user(key).pubkeyHex, since = since?.get(relay)?.time, ) } - } val userJobMap = mutableMapOf>() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/channel/nip53LiveActivities/LiveActivityWatcherSubAssembly.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/channel/nip53LiveActivities/LiveActivityWatcherSubAssembly.kt index 6aa98492b..3a5bd44ab 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/channel/nip53LiveActivities/LiveActivityWatcherSubAssembly.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/channel/nip53LiveActivities/LiveActivityWatcherSubAssembly.kt @@ -38,15 +38,14 @@ class LiveActivityWatcherSubAssembly( override fun updateFilter( key: ChannelFinderQueryState, since: SincePerRelayMap?, - ): List { - return if (key.channel is LiveActivitiesChannel) { + ): List = + if (key.channel is LiveActivitiesChannel) { key.channel.relays().flatMap { filterLiveStreamUpdatesByAddress(it, listOf(key.channel), since?.get(it)?.time) } } else { emptyList() } - } /** * Only one key per channel. diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/event/watchers/EventWatcherSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/event/watchers/EventWatcherSubAssembler.kt index 483ff830b..36cff0b09 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/event/watchers/EventWatcherSubAssembler.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/event/watchers/EventWatcherSubAssembler.kt @@ -80,8 +80,10 @@ class EventWatcherSubAssembler( notes: Iterable, eoseCache: EOSEAccountFast, ): Collection> = - notes.groupBy { eoseCache.since(it)?.keys?.hashCode() } - .values.map { + notes + .groupBy { eoseCache.since(it)?.keys?.hashCode() } + .values + .map { // important to keep in order otherwise the Relay thinks the filter has changed and we REQ again it.sortedBy { it.idHex } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/user/loaders/FilterUserMetadataForKey.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/user/loaders/FilterUserMetadataForKey.kt index f43380b2f..7ce042af7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/user/loaders/FilterUserMetadataForKey.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/user/loaders/FilterUserMetadataForKey.kt @@ -36,11 +36,10 @@ val MetadataAndRelayListKinds = AdvertisedRelayListEvent.KIND, ) -fun filterFindUserMetadataForKey(author: HexKey): List { - return LocalCache.checkGetOrCreateUser(author)?.let { +fun filterFindUserMetadataForKey(author: HexKey): List = + LocalCache.checkGetOrCreateUser(author)?.let { filterFindUserMetadataForKey(setOf(it)) } ?: emptyList() -} fun filterFindUserMetadataForKey(authors: Set): List { val perRelayKeys = diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/user/watchers/FilterUserMetadataForKey.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/user/watchers/FilterUserMetadataForKey.kt index 049e3f9cf..ebcd0f627 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/user/watchers/FilterUserMetadataForKey.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/user/watchers/FilterUserMetadataForKey.kt @@ -45,14 +45,16 @@ fun filterUserMetadataForKey( since: SincePerRelayMap?, ): List { val relays = - authors.map { - val authorHomeRelayEventAddress = AdvertisedRelayListEvent.createAddressTag(it) - val authorHomeRelayEvent = (LocalCache.getAddressableNoteIfExists(authorHomeRelayEventAddress)?.event as? AdvertisedRelayListEvent) + authors + .map { + val authorHomeRelayEventAddress = AdvertisedRelayListEvent.createAddressTag(it) + val authorHomeRelayEvent = (LocalCache.getAddressableNoteIfExists(authorHomeRelayEventAddress)?.event as? AdvertisedRelayListEvent) - authorHomeRelayEvent?.writeRelaysNorm()?.ifEmpty { null } - ?: LocalCache.relayHints.hintsForKey(it).ifEmpty { null } - ?: listOfNotNull(LocalCache.getUserIfExists(it)?.latestMetadataRelay) - }.flatten().toSet() + authorHomeRelayEvent?.writeRelaysNorm()?.ifEmpty { null } + ?: LocalCache.relayHints.hintsForKey(it).ifEmpty { null } + ?: listOfNotNull(LocalCache.getUserIfExists(it)?.latestMetadataRelay) + }.flatten() + .toSet() return relays.map { RelayBasedFilter( diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/uploads/MediaCompressor.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/uploads/MediaCompressor.kt index 15b82ce30..4288337a2 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/uploads/MediaCompressor.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/uploads/MediaCompressor.kt @@ -108,7 +108,7 @@ class MediaCompressor { // videoName = "compressed_video" // => required name // ), // OR AND NOT BOTH - appSpecificStorageConfiguration = AppSpecificStorageConfiguration(), + storageConfiguration = AppSpecificStorageConfiguration(), configureWith = Configuration( quality = videoQuality, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/EditPostView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/EditPostView.kt index 65d19f6d8..199e2d236 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/EditPostView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/EditPostView.kt @@ -129,7 +129,11 @@ fun EditPostView( val scrollState = rememberScrollState() val scope = rememberCoroutineScope() var showRelaysDialog by remember { mutableStateOf(false) } - var relayList = remember { accountViewModel.account.outboxRelays.flow.value.toImmutableList() } + var relayList = + remember { + accountViewModel.account.outboxRelays.flow.value + .toImmutableList() + } LaunchedEffect(Unit) { postViewModel.load(edit, versionLookingAt, accountViewModel) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewMediaView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewMediaView.kt index b0e2824c3..fb81e5082 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewMediaView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewMediaView.kt @@ -101,7 +101,11 @@ fun NewMediaView( } var showRelaysDialog by remember { mutableStateOf(false) } - var relayList = remember { accountViewModel.account.outboxRelays.flow.value.toImmutableList() } + var relayList = + remember { + accountViewModel.account.outboxRelays.flow.value + .toImmutableList() + } Dialog( onDismissRequest = { onClose() }, @@ -202,7 +206,8 @@ fun ImageVideoPost( accountViewModel: AccountViewModel, ) { val nip95description = stringRes(id = R.string.upload_server_relays_nip95) - val fileServers by accountViewModel.account.serverLists.liveServerList.collectAsState() + val fileServers by accountViewModel.account.serverLists.liveServerList + .collectAsState() val fileServerOptions = remember(fileServers) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/NormalizedRelayUrlSerializer.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/NormalizedRelayUrlSerializer.kt index 1db3eaffe..10a0446c6 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/NormalizedRelayUrlSerializer.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/NormalizedRelayUrlSerializer.kt @@ -30,9 +30,7 @@ import kotlinx.serialization.encoding.Encoder object NormalizedRelayUrlSerializer : KSerializer { override val descriptor = PrimitiveSerialDescriptor("NormalizedRelayUrl", PrimitiveKind.STRING) - override fun deserialize(decoder: Decoder): NormalizedRelayUrl { - return NormalizedRelayUrl(decoder.decodeString()) - } + override fun deserialize(decoder: Decoder): NormalizedRelayUrl = NormalizedRelayUrl(decoder.decodeString()) override fun serialize( encoder: Encoder, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateZapAmountDialog.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateZapAmountDialog.kt index 2db170fbe..8f3b353c5 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateZapAmountDialog.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UpdateZapAmountDialog.kt @@ -139,7 +139,8 @@ class UpdateZapAmountViewModel : ViewModel() { ?.let { TextFieldValue(it) } ?: TextFieldValue("") this.walletConnectRelay = myAccount.settings.zapPaymentRequest - ?.relayUri?.url + ?.relayUri + ?.url ?.let { TextFieldValue(it) } ?: TextFieldValue("") this.walletConnectSecret = myAccount.settings.zapPaymentRequest diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UserProfilePicture.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UserProfilePicture.kt index c2c9eeb77..cf3dae4e1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UserProfilePicture.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/UserProfilePicture.kt @@ -373,7 +373,8 @@ fun WatchUserFollows( if (accountViewModel.isLoggedUser(userHex)) { onFollowChanges(true) } else { - val state by accountViewModel.account.kind3FollowList.flow.collectAsStateWithLifecycle() + val state by accountViewModel.account.kind3FollowList.flow + .collectAsStateWithLifecycle() onFollowChanges(state.authors.contains(userHex)) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/uploads/ImageVideoDescription.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/uploads/ImageVideoDescription.kt index baf2356ea..a119bc8a9 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/uploads/ImageVideoDescription.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/uploads/ImageVideoDescription.kt @@ -98,7 +98,8 @@ fun ImageVideoDescription( ) { val nip95description = stringRes(id = R.string.upload_server_relays_nip95) - val fileServers by accountViewModel.account.serverLists.liveServerList.collectAsState() + val fileServers by accountViewModel.account.serverLists.liveServerList + .collectAsState() val fileServerOptions = remember(fileServers, includeNIP95) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/DisplayHashtags.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/DisplayHashtags.kt index 752ac98df..04bb1a78c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/DisplayHashtags.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/elements/DisplayHashtags.kt @@ -50,7 +50,8 @@ fun DisplayFollowingHashtagsInPost( accountViewModel: AccountViewModel, nav: INav, ) { - val userFollowState by accountViewModel.account.allFollows.flow.collectAsStateWithLifecycle() + val userFollowState by accountViewModel.account.allFollows.flow + .collectAsStateWithLifecycle() var firstTag by remember(baseNote) { mutableStateOf(null) } LaunchedEffect(key1 = userFollowState) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/CommentPostViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/CommentPostViewModel.kt index 6cebce613..1b049286b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/CommentPostViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/CommentPostViewModel.kt @@ -498,13 +498,14 @@ open class CommentPostViewModel : multiOrchestrator = null } else { val errorMessages = - results.errors.map { - stringRes( - context, - it.errorResource, - *it.params, - ) - }.distinct() + results.errors + .map { + stringRes( + context, + it.errorResource, + *it.params, + ) + }.distinct() onError(stringRes(context, R.string.failed_to_upload_media_no_details), errorMessages.joinToString(".\n")) } @@ -555,7 +556,9 @@ open class CommentPostViewModel : fun reloadRelaySet() { val account = accountViewModel?.account ?: return - relayList = account.outboxRelays.flow.value.toImmutableList() + relayList = + account.outboxRelays.flow.value + .toImmutableList() } fun deleteMediaToUpload(selected: SelectedMediaProcessing) { @@ -626,7 +629,10 @@ open class CommentPostViewModel : viewModelScope.launch(Dispatchers.IO) { iMetaAttachments.downloadAndPrepare( item.link.url, - { Amethyst.Companion.instance.okHttpClients.getHttpClient(accountViewModel?.account?.shouldUseTorForImageDownload(item.link.url) ?: false) }, + { + Amethyst.Companion.instance.okHttpClients + .getHttpClient(accountViewModel?.account?.shouldUseTorForImageDownload(item.link.url) ?: false) + }, ) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/CommunityHeader.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/CommunityHeader.kt index 55f6cb25a..299d4cc0a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/CommunityHeader.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/CommunityHeader.kt @@ -361,7 +361,8 @@ fun WatchAddressableNoteFollows( accountViewModel: AccountViewModel, onFollowChanges: @Composable (Boolean) -> Unit, ) { - val state by accountViewModel.account.kind3FollowList.flow.collectAsStateWithLifecycle() + val state by accountViewModel.account.kind3FollowList.flow + .collectAsStateWithLifecycle() onFollowChanges(state.communities.contains(note.idHex)) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt index 0810a02ea..6056e32b1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt @@ -167,7 +167,9 @@ class AccountViewModel( .flow() .relays.stateFlow .map { contactListState -> - contactListState.user.latestContactList?.relays()?.keys ?: emptySet() + contactListState.user.latestContactList + ?.relays() + ?.keys ?: emptySet() }.flowOn(Dispatchers.Default) .stateIn( viewModelScope, @@ -1664,27 +1666,29 @@ class AccountViewModel( fun relayStatusFlow() = app.client.relayStatusFlow() - fun convertAccounts(loggedInAccounts: List?): Set { - return loggedInAccounts?.mapNotNull { - try { - it.npub.bechToBytes().toHexKey() - } catch (e: Exception) { - if (e is CancellationException) throw e - null - } - }?.toSet() ?: emptySet() - } + fun convertAccounts(loggedInAccounts: List?): Set = + loggedInAccounts + ?.mapNotNull { + try { + it.npub.bechToBytes().toHexKey() + } catch (e: Exception) { + if (e is CancellationException) throw e + null + } + }?.toSet() ?: emptySet() val trustedAccounts: StateFlow> = - LocalPreferences.accountsFlow().map { loggedInAccounts -> - convertAccounts(loggedInAccounts) - }.onStart { - emit(convertAccounts(LocalPreferences.allSavedAccounts())) - }.stateIn( - viewModelScope, - SharingStarted.WhileSubscribed(5000), - emptySet(), - ) + LocalPreferences + .accountsFlow() + .map { loggedInAccounts -> + convertAccounts(loggedInAccounts) + }.onStart { + emit(convertAccounts(LocalPreferences.allSavedAccounts())) + }.stateIn( + viewModelScope, + SharingStarted.WhileSubscribed(5000), + emptySet(), + ) val draftNoteCache = CachedDraftNotes(this) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/LoggedInPage.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/LoggedInPage.kt index 2c6389ec2..65df1f06f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/LoggedInPage.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/LoggedInPage.kt @@ -130,7 +130,8 @@ fun ObserveAntiSpamFilterSettings(accountViewModel: AccountViewModel) { @Composable fun SetProxyDeterminator(accountViewModel: AccountViewModel) { LaunchedEffect(accountViewModel) { - Amethyst.instance.torProxySettingsAnchor.flow.tryEmit(accountViewModel.account.torRelayState.flow) + Amethyst.instance.torProxySettingsAnchor.flow + .tryEmit(accountViewModel.account.torRelayState.flow) } } @@ -143,7 +144,8 @@ fun ObserveImageLoadingTor(accountViewModel: AccountViewModel) { @Composable fun ManageRelayServices(accountViewModel: AccountViewModel) { - val relayServices by Amethyst.instance.relayProxyClientConnector.relayServices.collectAsStateWithLifecycle() + val relayServices by Amethyst.instance.relayProxyClientConnector.relayServices + .collectAsStateWithLifecycle() Log.d("ManageRelayServices", "Relay Services changed $relayServices") } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/ephemChat/metadata/NewEphemeralChatMetaViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/ephemChat/metadata/NewEphemeralChatMetaViewModel.kt index 82fb3225e..9a5525d29 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/ephemChat/metadata/NewEphemeralChatMetaViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/ephemChat/metadata/NewEphemeralChatMetaViewModel.kt @@ -44,7 +44,8 @@ class NewEphemeralChatMetaViewModel : ViewModel() { } fun buildRoom() = - RelayUrlNormalizer.normalizeOrNull(relayUrl.value.text) + RelayUrlNormalizer + .normalizeOrNull(relayUrl.value.text) ?.let { RoomId(channelName.value.text, it) } /* diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/FilterLastMessageFollowingPublicChats.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/FilterLastMessageFollowingPublicChats.kt index 59b1288c7..a7723ac35 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/FilterLastMessageFollowingPublicChats.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/FilterLastMessageFollowingPublicChats.kt @@ -50,30 +50,31 @@ fun filterLastMessageFollowingPublicChats( } } - return relayRoomDTags.map { - listOf( - RelayBasedFilter( - // Metadata comes from any relay - relay = it.key, - filter = - Filter( - kinds = listOf(ChannelMetadataEvent.KIND), - tags = mapOf("e" to it.value.sorted()), - since = since?.get(it.key)?.time, - limit = 1, - ), - ), - RelayBasedFilter( - relay = it.key, - filter = - Filter( - kinds = listOf(ChannelMessageEvent.KIND), - tags = mapOf("e" to it.value.sorted()), - since = since?.get(it.key)?.time, - // Remember to consider spam that is being removed from the UI - limit = 100, - ), - ), - ) - }.flatten() + return relayRoomDTags + .map { + listOf( + RelayBasedFilter( + // Metadata comes from any relay + relay = it.key, + filter = + Filter( + kinds = listOf(ChannelMetadataEvent.KIND), + tags = mapOf("e" to it.value.sorted()), + since = since?.get(it.key)?.time, + limit = 1, + ), + ), + RelayBasedFilter( + relay = it.key, + filter = + Filter( + kinds = listOf(ChannelMessageEvent.KIND), + tags = mapOf("e" to it.value.sorted()), + since = since?.get(it.key)?.time, + // Remember to consider spam that is being removed from the UI + limit = 100, + ), + ), + ) + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/FilterNip04DMsFromMe.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/FilterNip04DMsFromMe.kt index afadd3b35..e32888b58 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/FilterNip04DMsFromMe.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/FilterNip04DMsFromMe.kt @@ -30,8 +30,8 @@ fun filterNip04DMsFromMe( user: User, relay: NormalizedRelayUrl, since: Long?, -): RelayBasedFilter { - return RelayBasedFilter( +): RelayBasedFilter = + RelayBasedFilter( relay = relay, filter = Filter( @@ -40,4 +40,3 @@ fun filterNip04DMsFromMe( since = since, ), ) -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/FilterNip04DMsToMe.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/FilterNip04DMsToMe.kt index b86aa6280..2488bed77 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/FilterNip04DMsToMe.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/rooms/datasource/FilterNip04DMsToMe.kt @@ -30,8 +30,8 @@ fun filterNip04DMsToMe( user: User, relay: NormalizedRelayUrl, since: Long?, -): RelayBasedFilter { - return RelayBasedFilter( +): RelayBasedFilter = + RelayBasedFilter( relay = relay, filter = Filter( @@ -40,4 +40,3 @@ fun filterNip04DMsToMe( since = since, ), ) -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/utils/ChatFileUploadDialog.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/utils/ChatFileUploadDialog.kt index b7065770a..87ac292f1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/utils/ChatFileUploadDialog.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/utils/ChatFileUploadDialog.kt @@ -148,7 +148,8 @@ private fun ImageVideoPostChat( fileUploadState: ChatFileUploadState, accountViewModel: AccountViewModel, ) { - val fileServers by accountViewModel.account.serverLists.liveServerList.collectAsState() + val fileServers by accountViewModel.account.serverLists.liveServerList + .collectAsState() val fileServerOptions = remember(fileServers) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/datasource/FilterCommunityPosts.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/datasource/FilterCommunityPosts.kt index e0447aae2..c728a9526 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/datasource/FilterCommunityPosts.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/communities/datasource/FilterCommunityPosts.kt @@ -30,8 +30,8 @@ fun filterCommunityPosts( relay: NormalizedRelayUrl, community: CommunityDefinitionEvent, since: Long?, -): RelayBasedFilter { - return RelayBasedFilter( +): RelayBasedFilter = + RelayBasedFilter( relay = relay, filter = Filter( @@ -42,4 +42,3 @@ fun filterCommunityPosts( since = since, ), ) -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/SubAssemblyHelper.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/SubAssemblyHelper.kt index 9083c8e90..aea7bdacf 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/SubAssemblyHelper.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/SubAssemblyHelper.kt @@ -42,8 +42,8 @@ import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter fun makeLongFormFilter( feedSettings: IFeedTopNavPerRelayFilterSet, since: SincePerRelayMap?, -): List { - return when (feedSettings) { +): List = + when (feedSettings) { is AllCommunitiesTopNavPerRelayFilterSet -> filterLongFormByAllCommunities(feedSettings, since) is AllFollowsByOutboxTopNavPerRelayFilterSet -> filterLongFormByFollows(feedSettings, since) is AuthorsByOutboxTopNavPerRelayFilterSet -> filterLongFormByAuthors(feedSettings, since) @@ -54,4 +54,3 @@ fun makeLongFormFilter( is SingleCommunityTopNavPerRelayFilterSet -> filterLongFormByCommunity(feedSettings, since) else -> emptyList() } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByAllCommunities.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByAllCommunities.kt index f08543c74..1d6233937 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByAllCommunities.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByAllCommunities.kt @@ -75,11 +75,12 @@ fun filterLongFormByAllCommunities( val defaultSince = TimeUtils.oneWeekAgo() - return communitySet.set.mapNotNull { - filterLongFormAllCommunities( - relay = it.key, - communities = it.value.communities, - since = since?.get(it.key)?.time ?: defaultSince, - ) - }.flatten() + return communitySet.set + .mapNotNull { + filterLongFormAllCommunities( + relay = it.key, + communities = it.value.communities, + since = since?.get(it.key)?.time ?: defaultSince, + ) + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByAuthors.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByAuthors.kt index 838d31e00..40f3f914d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByAuthors.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByAuthors.kt @@ -60,17 +60,18 @@ fun filterLongFormByAuthors( val defaultSince = TimeUtils.oneWeekAgo() - return authorSet.set.mapNotNull { - if (it.value.authors.isEmpty()) { - null - } else { - filterLongFormAuthors( - relay = it.key, - authors = it.value.authors, - since = since?.get(it.key)?.time ?: defaultSince, - ) - } - }.flatten() + return authorSet.set + .mapNotNull { + if (it.value.authors.isEmpty()) { + null + } else { + filterLongFormAuthors( + relay = it.key, + authors = it.value.authors, + since = since?.get(it.key)?.time ?: defaultSince, + ) + } + }.flatten() } fun filterLongFormByAuthors( @@ -81,15 +82,16 @@ fun filterLongFormByAuthors( val defaultSince = TimeUtils.oneWeekAgo() - return authorSet.set.mapNotNull { - if (it.value.authors.isEmpty()) { - null - } else { - filterLongFormAuthors( - relay = it.key, - authors = it.value.authors, - since = since?.get(it.key)?.time ?: defaultSince, - ) - } - }.flatten() + return authorSet.set + .mapNotNull { + if (it.value.authors.isEmpty()) { + null + } else { + filterLongFormAuthors( + relay = it.key, + authors = it.value.authors, + since = since?.get(it.key)?.time ?: defaultSince, + ) + } + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByCommunity.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByCommunity.kt index 81570692b..7cb866ad0 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByCommunity.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByCommunity.kt @@ -77,12 +77,13 @@ fun filterLongFormByCommunity( val defaultSince = TimeUtils.oneWeekAgo() - return communitySet.set.mapNotNull { - filterLongFormByCommunity( - relay = it.key, - community = it.value.community, - authors = it.value.authors, - since = since?.get(it.key)?.time ?: defaultSince, - ) - }.flatten() + return communitySet.set + .mapNotNull { + filterLongFormByCommunity( + relay = it.key, + community = it.value.community, + authors = it.value.authors, + since = since?.get(it.key)?.time ?: defaultSince, + ) + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByGeohash.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByGeohash.kt index 51f81e137..138a4fca2 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByGeohash.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByGeohash.kt @@ -61,15 +61,16 @@ fun filterLongFormByGeohash( val defaultSince = TimeUtils.oneWeekAgo() - return geoSet.set.mapNotNull { - if (it.value.geotags.isEmpty()) { - null - } else { - filterLiveActivitiesByGeohash( - relay = it.key, - geotags = it.value.geotags, - since = since?.get(it.key)?.time ?: defaultSince, - ) - } - }.flatten() + return geoSet.set + .mapNotNull { + if (it.value.geotags.isEmpty()) { + null + } else { + filterLiveActivitiesByGeohash( + relay = it.key, + geotags = it.value.geotags, + since = since?.get(it.key)?.time ?: defaultSince, + ) + } + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByHashtag.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByHashtag.kt index 71afa309c..07c36e21b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByHashtag.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip23LongForm/subassemblies/FilterLongFormByHashtag.kt @@ -61,15 +61,16 @@ fun filterLongFormByHashtag( val defaultSince = TimeUtils.oneWeekAgo() - return hashSet.set.mapNotNull { relayHashSet -> - if (relayHashSet.value.hashtags.isEmpty()) { - null - } else { - filterLongFormByHashtag( - relay = relayHashSet.key, - hashtags = relayHashSet.value.hashtags, - since = since?.get(relayHashSet.key)?.time ?: defaultSince, - ) - } - }.flatten() + return hashSet.set + .mapNotNull { relayHashSet -> + if (relayHashSet.value.hashtags.isEmpty()) { + null + } else { + filterLongFormByHashtag( + relay = relayHashSet.key, + hashtags = relayHashSet.value.hashtags, + since = since?.get(relayHashSet.key)?.time ?: defaultSince, + ) + } + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/SubAssemblyHelper.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/SubAssemblyHelper.kt index d3db8579c..4b79b94a2 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/SubAssemblyHelper.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/SubAssemblyHelper.kt @@ -42,8 +42,8 @@ import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter fun makePublicChatsFilter( feedSettings: IFeedTopNavPerRelayFilterSet, since: SincePerRelayMap?, -): List { - return when (feedSettings) { +): List = + when (feedSettings) { is AllCommunitiesTopNavPerRelayFilterSet -> filterPublicChatsByAllCommunities(feedSettings, since) is AllFollowsByOutboxTopNavPerRelayFilterSet -> filterPublicChatsByFollows(feedSettings, since) is AuthorsByOutboxTopNavPerRelayFilterSet -> filterPublicChatsByAuthors(feedSettings, since) @@ -54,4 +54,3 @@ fun makePublicChatsFilter( is SingleCommunityTopNavPerRelayFilterSet -> filterPublicChatsByCommunity(feedSettings, since) else -> emptyList() } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByAllCommunities.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByAllCommunities.kt index 130409fa6..656e396f3 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByAllCommunities.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByAllCommunities.kt @@ -82,11 +82,12 @@ fun filterPublicChatsByAllCommunities( val defaultSince = TimeUtils.oneWeekAgo() - return communitySet.set.mapNotNull { - filterPublicChatsAllCommunities( - relay = it.key, - communities = it.value.communities, - since = since?.get(it.key)?.time ?: defaultSince, - ) - }.flatten() + return communitySet.set + .mapNotNull { + filterPublicChatsAllCommunities( + relay = it.key, + communities = it.value.communities, + since = since?.get(it.key)?.time ?: defaultSince, + ) + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByAuthors.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByAuthors.kt index 3aedb1875..aa3a7a7f8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByAuthors.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByAuthors.kt @@ -67,17 +67,18 @@ fun filterPublicChatsByAuthors( val defaultSince = TimeUtils.oneWeekAgo() - return authorSet.set.mapNotNull { - if (it.value.authors.isEmpty()) { - null - } else { - filterPublicChatsAuthors( - relay = it.key, - authors = it.value.authors, - since = since?.get(it.key)?.time ?: defaultSince, - ) - } - }.flatten() + return authorSet.set + .mapNotNull { + if (it.value.authors.isEmpty()) { + null + } else { + filterPublicChatsAuthors( + relay = it.key, + authors = it.value.authors, + since = since?.get(it.key)?.time ?: defaultSince, + ) + } + }.flatten() } fun filterPublicChatsByAuthors( @@ -88,15 +89,16 @@ fun filterPublicChatsByAuthors( val defaultSince = TimeUtils.oneWeekAgo() - return authorSet.set.mapNotNull { - if (it.value.authors.isEmpty()) { - null - } else { - filterPublicChatsAuthors( - relay = it.key, - authors = it.value.authors, - since = since?.get(it.key)?.time ?: defaultSince, - ) - } - }.flatten() + return authorSet.set + .mapNotNull { + if (it.value.authors.isEmpty()) { + null + } else { + filterPublicChatsAuthors( + relay = it.key, + authors = it.value.authors, + since = since?.get(it.key)?.time ?: defaultSince, + ) + } + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByCommunity.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByCommunity.kt index ce0975292..98d183db4 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByCommunity.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByCommunity.kt @@ -84,12 +84,13 @@ fun filterPublicChatsByCommunity( val defaultSince = TimeUtils.oneWeekAgo() - return communitySet.set.mapNotNull { - filterPublicChatsByCommunity( - relay = it.key, - community = it.value.community, - authors = it.value.authors, - since = since?.get(it.key)?.time ?: defaultSince, - ) - }.flatten() + return communitySet.set + .mapNotNull { + filterPublicChatsByCommunity( + relay = it.key, + community = it.value.community, + authors = it.value.authors, + since = since?.get(it.key)?.time ?: defaultSince, + ) + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByGeohash.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByGeohash.kt index fafc069a5..2e03857e5 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByGeohash.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByGeohash.kt @@ -67,15 +67,16 @@ fun filterPublicChatsByGeohash( val defaultSince = TimeUtils.oneWeekAgo() - return geoSet.set.mapNotNull { - if (it.value.geotags.isEmpty()) { - null - } else { - filterPublicChatsByGeohash( - relay = it.key, - geotags = it.value.geotags, - since = since?.get(it.key)?.time ?: defaultSince, - ) - } - }.flatten() + return geoSet.set + .mapNotNull { + if (it.value.geotags.isEmpty()) { + null + } else { + filterPublicChatsByGeohash( + relay = it.key, + geotags = it.value.geotags, + since = since?.get(it.key)?.time ?: defaultSince, + ) + } + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByHashtag.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByHashtag.kt index d7a69d40b..1f70a7a73 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByHashtag.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip28Chats/subassemblies/FilterPublicChatsByHashtag.kt @@ -68,15 +68,16 @@ fun filterPublicChatsByHashtag( val defaultSince = TimeUtils.oneWeekAgo() - return hashSet.set.mapNotNull { relayHashSet -> - if (relayHashSet.value.hashtags.isEmpty()) { - null - } else { - filterPublicChatsByHashtag( - relay = relayHashSet.key, - hashtags = relayHashSet.value.hashtags, - since = since?.get(relayHashSet.key)?.time ?: defaultSince, - ) - } - }.flatten() + return hashSet.set + .mapNotNull { relayHashSet -> + if (relayHashSet.value.hashtags.isEmpty()) { + null + } else { + filterPublicChatsByHashtag( + relay = relayHashSet.key, + hashtags = relayHashSet.value.hashtags, + since = since?.get(relayHashSet.key)?.time ?: defaultSince, + ) + } + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/SubAssemblyHelper.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/SubAssemblyHelper.kt index bb5a3f60a..8c3797df9 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/SubAssemblyHelper.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/SubAssemblyHelper.kt @@ -42,8 +42,8 @@ import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter fun makeFollowSetsFilter( feedSettings: IFeedTopNavPerRelayFilterSet, since: SincePerRelayMap?, -): List { - return when (feedSettings) { +): List = + when (feedSettings) { is AllCommunitiesTopNavPerRelayFilterSet -> filterFollowSetsByAllCommunities(feedSettings, since) is AllFollowsByOutboxTopNavPerRelayFilterSet -> filterFollowSetsByFollows(feedSettings, since) is AuthorsByOutboxTopNavPerRelayFilterSet -> filterFollowSetsByAuthors(feedSettings, since) @@ -54,4 +54,3 @@ fun makeFollowSetsFilter( is SingleCommunityTopNavPerRelayFilterSet -> filterFollowSetsByCommunity(feedSettings, since) else -> emptyList() } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByAllCommunities.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByAllCommunities.kt index 21ec68b6c..93ca8f70e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByAllCommunities.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByAllCommunities.kt @@ -76,11 +76,12 @@ fun filterFollowSetsByAllCommunities( val defaultSince = TimeUtils.oneWeekAgo() - return communitySet.set.mapNotNull { - filterContentDVMsAllCommunities( - relay = it.key, - communities = it.value.communities, - since = since?.get(it.key)?.time ?: defaultSince, - ) - }.flatten() + return communitySet.set + .mapNotNull { + filterContentDVMsAllCommunities( + relay = it.key, + communities = it.value.communities, + since = since?.get(it.key)?.time ?: defaultSince, + ) + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByAuthors.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByAuthors.kt index d37e3e392..3d08502c2 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByAuthors.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByAuthors.kt @@ -60,17 +60,18 @@ fun filterFollowSetsByAuthors( val defaultSince = TimeUtils.oneWeekAgo() - return authorSet.set.mapNotNull { - if (it.value.authors.isEmpty()) { - null - } else { - filterFollowSetsAuthors( - relay = it.key, - authors = it.value.authors, - since = since?.get(it.key)?.time ?: defaultSince, - ) - } - }.flatten() + return authorSet.set + .mapNotNull { + if (it.value.authors.isEmpty()) { + null + } else { + filterFollowSetsAuthors( + relay = it.key, + authors = it.value.authors, + since = since?.get(it.key)?.time ?: defaultSince, + ) + } + }.flatten() } fun filterFollowSetsByAuthors( @@ -81,15 +82,16 @@ fun filterFollowSetsByAuthors( val defaultSince = TimeUtils.oneWeekAgo() - return authorSet.set.mapNotNull { - if (it.value.authors.isEmpty()) { - null - } else { - filterFollowSetsAuthors( - relay = it.key, - authors = it.value.authors, - since = since?.get(it.key)?.time ?: defaultSince, - ) - } - }.flatten() + return authorSet.set + .mapNotNull { + if (it.value.authors.isEmpty()) { + null + } else { + filterFollowSetsAuthors( + relay = it.key, + authors = it.value.authors, + since = since?.get(it.key)?.time ?: defaultSince, + ) + } + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByCommunity.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByCommunity.kt index 7a0fb3f66..09a9be898 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByCommunity.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByCommunity.kt @@ -77,12 +77,13 @@ fun filterFollowSetsByCommunity( val defaultSince = TimeUtils.oneWeekAgo() - return communitySet.set.mapNotNull { - filterFollowSetsByCommunity( - relay = it.key, - community = it.value.community, - authors = it.value.authors, - since = since?.get(it.key)?.time ?: defaultSince, - ) - }.flatten() + return communitySet.set + .mapNotNull { + filterFollowSetsByCommunity( + relay = it.key, + community = it.value.community, + authors = it.value.authors, + since = since?.get(it.key)?.time ?: defaultSince, + ) + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByGeohash.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByGeohash.kt index 1ab2287ab..21195dd0e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByGeohash.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByGeohash.kt @@ -60,15 +60,16 @@ fun filterFollowSetsByGeohash( val defaultSince = TimeUtils.oneWeekAgo() - return geoSet.set.mapNotNull { - if (it.value.geotags.isEmpty()) { - null - } else { - filterFollowSetsByGeohash( - relay = it.key, - geotags = it.value.geotags, - since = since?.get(it.key)?.time ?: defaultSince, - ) - } - }.flatten() + return geoSet.set + .mapNotNull { + if (it.value.geotags.isEmpty()) { + null + } else { + filterFollowSetsByGeohash( + relay = it.key, + geotags = it.value.geotags, + since = since?.get(it.key)?.time ?: defaultSince, + ) + } + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByHashtag.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByHashtag.kt index 530015ce0..f5e8e4caf 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByHashtag.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip51FollowSets/subassemblies/FilterFollowSetsByHashtag.kt @@ -61,15 +61,16 @@ fun filterFollowSetsByHashtag( val defaultSince = TimeUtils.oneWeekAgo() - return hashSet.set.mapNotNull { relayHashSet -> - if (relayHashSet.value.hashtags.isEmpty()) { - null - } else { - filterFollowSetsByHashtag( - relay = relayHashSet.key, - hashtags = relayHashSet.value.hashtags, - since = since?.get(relayHashSet.key)?.time ?: defaultSince, - ) - } - }.flatten() + return hashSet.set + .mapNotNull { relayHashSet -> + if (relayHashSet.value.hashtags.isEmpty()) { + null + } else { + filterFollowSetsByHashtag( + relay = relayHashSet.key, + hashtags = relayHashSet.value.hashtags, + since = since?.get(relayHashSet.key)?.time ?: defaultSince, + ) + } + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/SubAssemblyHelper.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/SubAssemblyHelper.kt index 13acbd03e..0cca444f9 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/SubAssemblyHelper.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/SubAssemblyHelper.kt @@ -42,8 +42,8 @@ import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter fun makeLiveActivitiesFilter( feedSettings: IFeedTopNavPerRelayFilterSet, since: SincePerRelayMap?, -): List { - return when (feedSettings) { +): List = + when (feedSettings) { is AllCommunitiesTopNavPerRelayFilterSet -> filterLiveActivitiesByAllCommunities(feedSettings, since) is AllFollowsByOutboxTopNavPerRelayFilterSet -> filterLiveActivitiesByFollows(feedSettings, since) is AuthorsByOutboxTopNavPerRelayFilterSet -> filterLiveActivitiesByAuthors(feedSettings, since) @@ -54,4 +54,3 @@ fun makeLiveActivitiesFilter( is SingleCommunityTopNavPerRelayFilterSet -> filterLiveActivitiesByCommunity(feedSettings, since) else -> emptyList() } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByAllCommunities.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByAllCommunities.kt index c139cea3d..6354b18c6 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByAllCommunities.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByAllCommunities.kt @@ -77,11 +77,12 @@ fun filterLiveActivitiesByAllCommunities( val defaultSince = TimeUtils.oneWeekAgo() - return communitySet.set.mapNotNull { - filterContentDVMsAllCommunities( - relay = it.key, - communities = it.value.communities, - since = since?.get(it.key)?.time ?: defaultSince, - ) - }.flatten() + return communitySet.set + .mapNotNull { + filterContentDVMsAllCommunities( + relay = it.key, + communities = it.value.communities, + since = since?.get(it.key)?.time ?: defaultSince, + ) + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByAuthors.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByAuthors.kt index 84225a667..8d3211226 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByAuthors.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByAuthors.kt @@ -72,17 +72,18 @@ fun filterLiveActivitiesByAuthors( val defaultSince = TimeUtils.oneWeekAgo() - return authorSet.set.mapNotNull { - if (it.value.authors.isEmpty()) { - null - } else { - filterLiveActivitiesAuthors( - relay = it.key, - authors = it.value.authors, - since = since?.get(it.key)?.time ?: defaultSince, - ) - } - }.flatten() + return authorSet.set + .mapNotNull { + if (it.value.authors.isEmpty()) { + null + } else { + filterLiveActivitiesAuthors( + relay = it.key, + authors = it.value.authors, + since = since?.get(it.key)?.time ?: defaultSince, + ) + } + }.flatten() } fun filterLiveActivitiesByAuthors( @@ -93,15 +94,16 @@ fun filterLiveActivitiesByAuthors( val defaultSince = TimeUtils.oneWeekAgo() - return authorSet.set.mapNotNull { - if (it.value.authors.isEmpty()) { - null - } else { - filterLiveActivitiesAuthors( - relay = it.key, - authors = it.value.authors, - since = since?.get(it.key)?.time ?: defaultSince, - ) - } - }.flatten() + return authorSet.set + .mapNotNull { + if (it.value.authors.isEmpty()) { + null + } else { + filterLiveActivitiesAuthors( + relay = it.key, + authors = it.value.authors, + since = since?.get(it.key)?.time ?: defaultSince, + ) + } + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByCommunity.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByCommunity.kt index 382c0d633..0141bb8b7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByCommunity.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByCommunity.kt @@ -78,12 +78,13 @@ fun filterLiveActivitiesByCommunity( val defaultSince = TimeUtils.oneWeekAgo() - return communitySet.set.mapNotNull { - filterLiveActivitiesByCommunity( - relay = it.key, - community = it.value.community, - authors = it.value.authors, - since = since?.get(it.key)?.time ?: defaultSince, - ) - }.flatten() + return communitySet.set + .mapNotNull { + filterLiveActivitiesByCommunity( + relay = it.key, + community = it.value.community, + authors = it.value.authors, + since = since?.get(it.key)?.time ?: defaultSince, + ) + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByGeohash.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByGeohash.kt index 8a9470a0c..875bf036b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByGeohash.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByGeohash.kt @@ -61,15 +61,16 @@ fun filterLiveActivitiesByGeohash( val defaultSince = TimeUtils.oneWeekAgo() - return geoSet.set.mapNotNull { - if (it.value.geotags.isEmpty()) { - null - } else { - filterLiveActivitiesByGeohash( - relay = it.key, - geotags = it.value.geotags, - since = since?.get(it.key)?.time ?: defaultSince, - ) - } - }.flatten() + return geoSet.set + .mapNotNull { + if (it.value.geotags.isEmpty()) { + null + } else { + filterLiveActivitiesByGeohash( + relay = it.key, + geotags = it.value.geotags, + since = since?.get(it.key)?.time ?: defaultSince, + ) + } + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByHashtag.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByHashtag.kt index 32bd409ca..5e7e7b4bd 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByHashtag.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip53LiveActivities/subassemblies/FilterLiveActivitiesByHashtag.kt @@ -62,15 +62,16 @@ fun filterLiveActivitiesByHashtag( val defaultSince = TimeUtils.oneWeekAgo() - return hashSet.set.mapNotNull { relayHashSet -> - if (relayHashSet.value.hashtags.isEmpty()) { - null - } else { - filterLiveActivitiesByHashtag( - relay = relayHashSet.key, - hashtags = relayHashSet.value.hashtags, - since = since?.get(relayHashSet.key)?.time ?: defaultSince, - ) - } - }.flatten() + return hashSet.set + .mapNotNull { relayHashSet -> + if (relayHashSet.value.hashtags.isEmpty()) { + null + } else { + filterLiveActivitiesByHashtag( + relay = relayHashSet.key, + hashtags = relayHashSet.value.hashtags, + since = since?.get(relayHashSet.key)?.time ?: defaultSince, + ) + } + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/SubAssemblyHelper.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/SubAssemblyHelper.kt index 97576f15e..4b275fae7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/SubAssemblyHelper.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/SubAssemblyHelper.kt @@ -42,8 +42,8 @@ import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter fun makeCommunitiesFilter( feedSettings: IFeedTopNavPerRelayFilterSet, since: SincePerRelayMap?, -): List { - return when (feedSettings) { +): List = + when (feedSettings) { is AllCommunitiesTopNavPerRelayFilterSet -> filterCommunitiesByAllCommunities(feedSettings, since) is AllFollowsByOutboxTopNavPerRelayFilterSet -> filterCommunitiesByFollows(feedSettings, since) is AuthorsByOutboxTopNavPerRelayFilterSet -> filterCommunitiesByAuthors(feedSettings, since) @@ -54,4 +54,3 @@ fun makeCommunitiesFilter( is SingleCommunityTopNavPerRelayFilterSet -> filterCommunitiesByCommunity(feedSettings, since) else -> emptyList() } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByAllCommunities.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByAllCommunities.kt index 3dff4e38c..07f1637a0 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByAllCommunities.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByAllCommunities.kt @@ -71,11 +71,12 @@ fun filterCommunitiesByAllCommunities( val defaultSince = TimeUtils.oneWeekAgo() - return communitySet.set.mapNotNull { - filterCommunitiesAllCommunities( - relay = it.key, - communities = it.value.communities, - since = since?.get(it.key)?.time ?: defaultSince, - ) - }.flatten() + return communitySet.set + .mapNotNull { + filterCommunitiesAllCommunities( + relay = it.key, + communities = it.value.communities, + since = since?.get(it.key)?.time ?: defaultSince, + ) + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByAuthors.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByAuthors.kt index b1dab2df3..7557077b8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByAuthors.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByAuthors.kt @@ -61,17 +61,18 @@ fun filterCommunitiesByAuthors( val defaultSince = TimeUtils.oneWeekAgo() - return authorSet.set.mapNotNull { - if (it.value.authors.isEmpty()) { - null - } else { - filterCommunitiesAuthors( - relay = it.key, - authors = it.value.authors, - since = since?.get(it.key)?.time ?: defaultSince, - ) - } - }.flatten() + return authorSet.set + .mapNotNull { + if (it.value.authors.isEmpty()) { + null + } else { + filterCommunitiesAuthors( + relay = it.key, + authors = it.value.authors, + since = since?.get(it.key)?.time ?: defaultSince, + ) + } + }.flatten() } fun filterCommunitiesByAuthors( @@ -82,15 +83,16 @@ fun filterCommunitiesByAuthors( val defaultSince = TimeUtils.oneWeekAgo() - return authorSet.set.mapNotNull { - if (it.value.authors.isEmpty()) { - null - } else { - filterCommunitiesAuthors( - relay = it.key, - authors = it.value.authors, - since = since?.get(it.key)?.time ?: defaultSince, - ) - } - }.flatten() + return authorSet.set + .mapNotNull { + if (it.value.authors.isEmpty()) { + null + } else { + filterCommunitiesAuthors( + relay = it.key, + authors = it.value.authors, + since = since?.get(it.key)?.time ?: defaultSince, + ) + } + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByCommunity.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByCommunity.kt index 4a1bc7b7e..6697fd72c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByCommunity.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByCommunity.kt @@ -60,12 +60,13 @@ fun filterCommunitiesByCommunity( val defaultSince = TimeUtils.oneWeekAgo() - return communitySet.set.mapNotNull { - filterClassifiedsByCommunity( - relay = it.key, - community = it.value.community, - authors = it.value.authors, - since = since?.get(it.key)?.time ?: defaultSince, - ) - }.flatten() + return communitySet.set + .mapNotNull { + filterClassifiedsByCommunity( + relay = it.key, + community = it.value.community, + authors = it.value.authors, + since = since?.get(it.key)?.time ?: defaultSince, + ) + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByGeohash.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByGeohash.kt index 338fb283f..a3f87648d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByGeohash.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByGeohash.kt @@ -61,15 +61,16 @@ fun filterCommunitiesByGeohash( val defaultSince = TimeUtils.oneWeekAgo() - return geoSet.set.mapNotNull { - if (it.value.geotags.isEmpty()) { - null - } else { - filterCommunitiesByGeohash( - relay = it.key, - geotags = it.value.geotags, - since = since?.get(it.key)?.time ?: defaultSince, - ) - } - }.flatten() + return geoSet.set + .mapNotNull { + if (it.value.geotags.isEmpty()) { + null + } else { + filterCommunitiesByGeohash( + relay = it.key, + geotags = it.value.geotags, + since = since?.get(it.key)?.time ?: defaultSince, + ) + } + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByHashtag.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByHashtag.kt index 0a6aa4afd..59dc98a02 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByHashtag.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip72Communities/subassemblies/FilterCommunitiesByHashtag.kt @@ -62,15 +62,16 @@ fun filterCommunitiesByHashtag( val defaultSince = TimeUtils.oneWeekAgo() - return hashSet.set.mapNotNull { relayHashSet -> - if (relayHashSet.value.hashtags.isEmpty()) { - null - } else { - filterCommunitiesByHashtag( - relay = relayHashSet.key, - hashtags = relayHashSet.value.hashtags, - since = since?.get(relayHashSet.key)?.time ?: defaultSince, - ) - } - }.flatten() + return hashSet.set + .mapNotNull { relayHashSet -> + if (relayHashSet.value.hashtags.isEmpty()) { + null + } else { + filterCommunitiesByHashtag( + relay = relayHashSet.key, + hashtags = relayHashSet.value.hashtags, + since = since?.get(relayHashSet.key)?.time ?: defaultSince, + ) + } + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/SubAssemblyHelper.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/SubAssemblyHelper.kt index 3438e6ef2..1a03971c5 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/SubAssemblyHelper.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/SubAssemblyHelper.kt @@ -42,8 +42,8 @@ import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter fun makeContentDVMsFilter( feedSettings: IFeedTopNavPerRelayFilterSet, since: SincePerRelayMap?, -): List { - return when (feedSettings) { +): List = + when (feedSettings) { is AllCommunitiesTopNavPerRelayFilterSet -> filterContentDVMsByAllCommunities(feedSettings, since) is AllFollowsByOutboxTopNavPerRelayFilterSet -> filterContentDVMsByFollows(feedSettings, since) is AuthorsByOutboxTopNavPerRelayFilterSet -> filterContentDVMsByAuthors(feedSettings, since) @@ -54,4 +54,3 @@ fun makeContentDVMsFilter( is SingleCommunityTopNavPerRelayFilterSet -> filterContentDVMsByCommunity(feedSettings, since) else -> emptyList() } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByAllCommunities.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByAllCommunities.kt index 04b096309..0af546957 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByAllCommunities.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByAllCommunities.kt @@ -75,11 +75,12 @@ fun filterContentDVMsByAllCommunities( val defaultSince = TimeUtils.oneWeekAgo() - return communitySet.set.mapNotNull { - filterContentDVMsAllCommunities( - relay = it.key, - communities = it.value.communities, - since = since?.get(it.key)?.time ?: defaultSince, - ) - }.flatten() + return communitySet.set + .mapNotNull { + filterContentDVMsAllCommunities( + relay = it.key, + communities = it.value.communities, + since = since?.get(it.key)?.time ?: defaultSince, + ) + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByAuthors.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByAuthors.kt index 2c7cfa0ae..cd5769e97 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByAuthors.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByAuthors.kt @@ -61,17 +61,18 @@ fun filterContentDVMsByAuthors( val defaultSince = TimeUtils.oneWeekAgo() - return authorSet.set.mapNotNull { - if (it.value.authors.isEmpty()) { - null - } else { - filterContentDVMsAuthors( - relay = it.key, - authors = it.value.authors, - since = since?.get(it.key)?.time ?: defaultSince, - ) - } - }.flatten() + return authorSet.set + .mapNotNull { + if (it.value.authors.isEmpty()) { + null + } else { + filterContentDVMsAuthors( + relay = it.key, + authors = it.value.authors, + since = since?.get(it.key)?.time ?: defaultSince, + ) + } + }.flatten() } fun filterContentDVMsByAuthors( @@ -82,15 +83,16 @@ fun filterContentDVMsByAuthors( val defaultSince = TimeUtils.oneWeekAgo() - return authorSet.set.mapNotNull { - if (it.value.authors.isEmpty()) { - null - } else { - filterContentDVMsAuthors( - relay = it.key, - authors = it.value.authors, - since = since?.get(it.key)?.time ?: defaultSince, - ) - } - }.flatten() + return authorSet.set + .mapNotNull { + if (it.value.authors.isEmpty()) { + null + } else { + filterContentDVMsAuthors( + relay = it.key, + authors = it.value.authors, + since = since?.get(it.key)?.time ?: defaultSince, + ) + } + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByCommunity.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByCommunity.kt index 8c0e586d1..1cdb07be4 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByCommunity.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByCommunity.kt @@ -77,12 +77,13 @@ fun filterContentDVMsByCommunity( val defaultSince = TimeUtils.oneWeekAgo() - return communitySet.set.mapNotNull { - filterContentDVMsByCommunity( - relay = it.key, - community = it.value.community, - authors = it.value.authors, - since = since?.get(it.key)?.time ?: defaultSince, - ) - }.flatten() + return communitySet.set + .mapNotNull { + filterContentDVMsByCommunity( + relay = it.key, + community = it.value.community, + authors = it.value.authors, + since = since?.get(it.key)?.time ?: defaultSince, + ) + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByGeohash.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByGeohash.kt index 0f8a6e7de..23f3342b3 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByGeohash.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByGeohash.kt @@ -60,15 +60,16 @@ fun filterContentDVMsByGeohash( val defaultSince = TimeUtils.oneWeekAgo() - return geoSet.set.mapNotNull { - if (it.value.geotags.isEmpty()) { - null - } else { - filterContentDVMsByGeohash( - relay = it.key, - geotags = it.value.geotags, - since = since?.get(it.key)?.time ?: defaultSince, - ) - } - }.flatten() + return geoSet.set + .mapNotNull { + if (it.value.geotags.isEmpty()) { + null + } else { + filterContentDVMsByGeohash( + relay = it.key, + geotags = it.value.geotags, + since = since?.get(it.key)?.time ?: defaultSince, + ) + } + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByHashtag.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByHashtag.kt index 1a486d011..615c01438 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByHashtag.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip90DVMs/subassemblies/FilterContentDVMsByHashtag.kt @@ -61,15 +61,16 @@ fun filterContentDVMsByHashtag( val defaultSince = TimeUtils.oneWeekAgo() - return hashSet.set.mapNotNull { relayHashSet -> - if (relayHashSet.value.hashtags.isEmpty()) { - null - } else { - filterContentDVMsByHashtag( - relay = relayHashSet.key, - hashtags = relayHashSet.value.hashtags, - since = since?.get(relayHashSet.key)?.time ?: defaultSince, - ) - } - }.flatten() + return hashSet.set + .mapNotNull { relayHashSet -> + if (relayHashSet.value.hashtags.isEmpty()) { + null + } else { + filterContentDVMsByHashtag( + relay = relayHashSet.key, + hashtags = relayHashSet.value.hashtags, + since = since?.get(relayHashSet.key)?.time ?: defaultSince, + ) + } + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/NewProductViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/NewProductViewModel.kt index 56ce892d3..3648ad00c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/NewProductViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/NewProductViewModel.kt @@ -475,7 +475,9 @@ open class NewProductViewModel : fun reloadRelaySet() { val account = accountViewModel?.account ?: return - relayList = account.outboxRelays.flow.value.toImmutableList() + relayList = + account.outboxRelays.flow.value + .toImmutableList() } fun deleteMediaToUpload(selected: SelectedMediaProcessing) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/SubAssemblyHelper.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/SubAssemblyHelper.kt index b4047919a..fca10fdc3 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/SubAssemblyHelper.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/SubAssemblyHelper.kt @@ -42,8 +42,8 @@ import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter fun makeClassifiedsFilter( feedSettings: IFeedTopNavPerRelayFilterSet, since: SincePerRelayMap?, -): List { - return when (feedSettings) { +): List = + when (feedSettings) { is AllCommunitiesTopNavPerRelayFilterSet -> filterClassifiedsByAllCommunities(feedSettings, since) is AllFollowsByOutboxTopNavPerRelayFilterSet -> filterClassifiedsByFollows(feedSettings, since) is AuthorsByOutboxTopNavPerRelayFilterSet -> filterClassifiedsByAuthors(feedSettings, since) @@ -54,4 +54,3 @@ fun makeClassifiedsFilter( is SingleCommunityTopNavPerRelayFilterSet -> filterClassifiedsByCommunity(feedSettings, since) else -> emptyList() } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByAllCommunities.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByAllCommunities.kt index d143e23bc..3ba7cd619 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByAllCommunities.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByAllCommunities.kt @@ -75,11 +75,12 @@ fun filterClassifiedsByAllCommunities( val defaultSince = TimeUtils.oneWeekAgo() - return communitySet.set.mapNotNull { - filterClassifiedsAllCommunities( - relay = it.key, - communities = it.value.communities, - since = since?.get(it.key)?.time ?: defaultSince, - ) - }.flatten() + return communitySet.set + .mapNotNull { + filterClassifiedsAllCommunities( + relay = it.key, + communities = it.value.communities, + since = since?.get(it.key)?.time ?: defaultSince, + ) + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByAuthors.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByAuthors.kt index c6168c634..838c6f04e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByAuthors.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByAuthors.kt @@ -60,17 +60,18 @@ fun filterClassifiedsByAuthors( val defaultSince = TimeUtils.oneWeekAgo() - return authorSet.set.mapNotNull { - if (it.value.authors.isEmpty()) { - null - } else { - filterClassifiedsAuthors( - relay = it.key, - authors = it.value.authors, - since = since?.get(it.key)?.time ?: defaultSince, - ) - } - }.flatten() + return authorSet.set + .mapNotNull { + if (it.value.authors.isEmpty()) { + null + } else { + filterClassifiedsAuthors( + relay = it.key, + authors = it.value.authors, + since = since?.get(it.key)?.time ?: defaultSince, + ) + } + }.flatten() } fun filterClassifiedsByAuthors( @@ -81,15 +82,16 @@ fun filterClassifiedsByAuthors( val defaultSince = TimeUtils.oneWeekAgo() - return authorSet.set.mapNotNull { - if (it.value.authors.isEmpty()) { - null - } else { - filterClassifiedsAuthors( - relay = it.key, - authors = it.value.authors, - since = since?.get(it.key)?.time ?: defaultSince, - ) - } - }.flatten() + return authorSet.set + .mapNotNull { + if (it.value.authors.isEmpty()) { + null + } else { + filterClassifiedsAuthors( + relay = it.key, + authors = it.value.authors, + since = since?.get(it.key)?.time ?: defaultSince, + ) + } + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByCommunity.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByCommunity.kt index 7b5d64e70..1ee093d0c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByCommunity.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByCommunity.kt @@ -77,12 +77,13 @@ fun filterClassifiedsByCommunity( val defaultSince = TimeUtils.oneWeekAgo() - return communitySet.set.mapNotNull { - filterClassifiedsByCommunity( - relay = it.key, - community = it.value.community, - authors = it.value.authors, - since = since?.get(it.key)?.time ?: defaultSince, - ) - }.flatten() + return communitySet.set + .mapNotNull { + filterClassifiedsByCommunity( + relay = it.key, + community = it.value.community, + authors = it.value.authors, + since = since?.get(it.key)?.time ?: defaultSince, + ) + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByGeohash.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByGeohash.kt index f43b66121..5225b0a2f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByGeohash.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByGeohash.kt @@ -60,15 +60,16 @@ fun filterClassifiedsByGeohash( val defaultSince = TimeUtils.oneWeekAgo() - return geoSet.set.mapNotNull { - if (it.value.geotags.isEmpty()) { - null - } else { - filterClassifiedsByGeohash( - relay = it.key, - geotags = it.value.geotags, - since = since?.get(it.key)?.time ?: defaultSince, - ) - } - }.flatten() + return geoSet.set + .mapNotNull { + if (it.value.geotags.isEmpty()) { + null + } else { + filterClassifiedsByGeohash( + relay = it.key, + geotags = it.value.geotags, + since = since?.get(it.key)?.time ?: defaultSince, + ) + } + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByHashtag.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByHashtag.kt index 5efa7423d..8aa332218 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByHashtag.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/subassemblies/FilterClassifiedsByHashtag.kt @@ -61,15 +61,16 @@ fun filterClassifiedsByHashtag( val defaultSince = TimeUtils.oneWeekAgo() - return hashSet.set.mapNotNull { relayHashSet -> - if (relayHashSet.value.hashtags.isEmpty()) { - null - } else { - filterClassifiedsByHashtag( - relay = relayHashSet.key, - hashtags = relayHashSet.value.hashtags, - since = since?.get(relayHashSet.key)?.time ?: defaultSince, - ) - } - }.flatten() + return hashSet.set + .mapNotNull { relayHashSet -> + if (relayHashSet.value.hashtags.isEmpty()) { + null + } else { + filterClassifiedsByHashtag( + relay = relayHashSet.key, + hashtags = relayHashSet.value.hashtags, + since = since?.get(relayHashSet.key)?.time ?: defaultSince, + ) + } + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/geohash/dal/GeoHashFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/geohash/dal/GeoHashFeedFilter.kt index 1ffdfaefd..a0f556e32 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/geohash/dal/GeoHashFeedFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/geohash/dal/GeoHashFeedFilter.kt @@ -79,7 +79,8 @@ class GeoHashFeedFilter( event is PrivateDmEvent || event is PollNoteEvent || event is AudioHeaderEvent - ) && event.isTaggedGeoHash(geohash) + ) && + event.isTaggedGeoHash(geohash) fun acceptableViaScope( event: Event?, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/HomeScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/HomeScreen.kt index 5d3deaef4..87dd27e36 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/HomeScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/HomeScreen.kt @@ -228,10 +228,13 @@ fun HomeScreenFloatingButton( accountViewModel: AccountViewModel, nav: INav, ) { - val list = accountViewModel.account.settings.defaultHomeFollowList.collectAsStateWithLifecycle() + val list = + accountViewModel.account.settings.defaultHomeFollowList + .collectAsStateWithLifecycle() if (list.value == AROUND_ME) { - val location by Amethyst.instance.locationManager.geohashStateFlow.collectAsStateWithLifecycle() + val location by Amethyst.instance.locationManager.geohashStateFlow + .collectAsStateWithLifecycle() when (val myLocation = location) { is LocationState.LocationResult.Success -> NewGeoPostButton(myLocation.geoHash.toString(), accountViewModel, nav) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostViewModel.kt index 2ef0869e0..90d5280f4 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostViewModel.kt @@ -716,7 +716,9 @@ open class ShortNotePostViewModel : fun reloadRelaySet() { val account = accountViewModel?.account ?: return - relayList = account.outboxRelays.flow.value.toImmutableList() + relayList = + account.outboxRelays.flow.value + .toImmutableList() } fun deleteMediaToUpload(selected: SelectedMediaProcessing) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/dal/HomeLiveFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/dal/HomeLiveFilter.kt index e4b15204e..7005e7016 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/dal/HomeLiveFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/dal/HomeLiveFilter.kt @@ -68,9 +68,10 @@ class HomeLiveFilter( filterParams: FilterByListParams, timeLimit: Long, ): Boolean = - channel.notes.filter { key, value -> - acceptableEvent(value, filterParams, timeLimit) - }.isNotEmpty() + channel.notes + .filter { key, value -> + acceptableEvent(value, filterParams, timeLimit) + }.isNotEmpty() override fun updateListWith( oldList: List, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip01Core/FilterHomePostsByGeohashes.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip01Core/FilterHomePostsByGeohashes.kt index 629750561..12b90b80a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip01Core/FilterHomePostsByGeohashes.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip01Core/FilterHomePostsByGeohashes.kt @@ -82,20 +82,21 @@ fun filterHomePostsByGeohashes( val defaultSince = TimeUtils.oneWeekAgo() - return geoSet.set.mapNotNull { - if (it.value.geotags.isEmpty()) { - null - } else { - filterHomePostsByGeohashes( - relay = it.key, - geotags = it.value.geotags, - since = since?.get(it.key)?.time ?: defaultSince, - ) + - filterHomePostsByScopes( + return geoSet.set + .mapNotNull { + if (it.value.geotags.isEmpty()) { + null + } else { + filterHomePostsByGeohashes( relay = it.key, - scopesToLoad = it.value.geotagScopes, + geotags = it.value.geotags, since = since?.get(it.key)?.time ?: defaultSince, - ) - } - }.flatten() + ) + + filterHomePostsByScopes( + relay = it.key, + scopesToLoad = it.value.geotagScopes, + since = since?.get(it.key)?.time ?: defaultSince, + ) + } + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip01Core/FilterHomePostsByHashtags.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip01Core/FilterHomePostsByHashtags.kt index f7bbd8a74..fb65c4851 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip01Core/FilterHomePostsByHashtags.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip01Core/FilterHomePostsByHashtags.kt @@ -86,22 +86,23 @@ fun filterHomePostsByHashtags( val defaultSince = TimeUtils.oneWeekAgo() - return hashtagSet.set.mapNotNull { - if (it.value.hashtags.isEmpty()) { - null - } else { - val since = since?.get(it.key)?.time ?: defaultSince + return hashtagSet.set + .mapNotNull { + if (it.value.hashtags.isEmpty()) { + null + } else { + val since = since?.get(it.key)?.time ?: defaultSince - return filterHomePostsByHashtags( - relay = it.key, - hashToLoad = it.value.hashtags, - since = since, - ) + - filterHomePostsByScopes( + return filterHomePostsByHashtags( relay = it.key, - scopesToLoad = it.value.hashtagScopes, + hashToLoad = it.value.hashtags, since = since, - ) - } - }.flatten() + ) + + filterHomePostsByScopes( + relay = it.key, + scopesToLoad = it.value.hashtagScopes, + since = since, + ) + } + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip65Follows/FilterHomePostsByAuthors.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip65Follows/FilterHomePostsByAuthors.kt index 386cf8afb..4fd05a4bb 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip65Follows/FilterHomePostsByAuthors.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip65Follows/FilterHomePostsByAuthors.kt @@ -107,17 +107,18 @@ fun filterHomePostsByAuthors( val defaultSince = TimeUtils.oneWeekAgo() - return authorSet.set.mapNotNull { - if (it.value.authors.isEmpty()) { - null - } else { - filterHomePostsByAuthors( - relay = it.key, - authors = it.value.authors, - since = since?.get(it.key)?.time ?: defaultSince, - ) - } - }.flatten() + return authorSet.set + .mapNotNull { + if (it.value.authors.isEmpty()) { + null + } else { + filterHomePostsByAuthors( + relay = it.key, + authors = it.value.authors, + since = since?.get(it.key)?.time ?: defaultSince, + ) + } + }.flatten() } fun filterHomePostsByAuthors( @@ -128,15 +129,16 @@ fun filterHomePostsByAuthors( val defaultSince = TimeUtils.oneWeekAgo() - return authorSet.set.mapNotNull { - if (it.value.authors.isEmpty()) { - null - } else { - filterHomePostsByAuthors( - relay = it.key, - authors = it.value.authors, - since = since?.get(it.key)?.time ?: defaultSince, - ) - } - }.flatten() + return authorSet.set + .mapNotNull { + if (it.value.authors.isEmpty()) { + null + } else { + filterHomePostsByAuthors( + relay = it.key, + authors = it.value.authors, + since = since?.get(it.key)?.time ?: defaultSince, + ) + } + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip72Communities/FilterHomePostsByAllCommunities.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip72Communities/FilterHomePostsByAllCommunities.kt index 431091725..0eaf28b7f 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip72Communities/FilterHomePostsByAllCommunities.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip72Communities/FilterHomePostsByAllCommunities.kt @@ -74,11 +74,12 @@ fun filterHomePostsByAllCommunities( val defaultSince = TimeUtils.oneWeekAgo() - return communitySet.set.mapNotNull { - filterHomePostsFromAllCommunities( - relay = it.key, - communities = it.value.communities, - since = since?.get(it.key)?.time ?: defaultSince, - ) - }.flatten() + return communitySet.set + .mapNotNull { + filterHomePostsFromAllCommunities( + relay = it.key, + communities = it.value.communities, + since = since?.get(it.key)?.time ?: defaultSince, + ) + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip72Communities/FilterHomePostsFromCommunities.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip72Communities/FilterHomePostsFromCommunities.kt index 337a1cb12..30a90c857 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip72Communities/FilterHomePostsFromCommunities.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/datasource/nip72Communities/FilterHomePostsFromCommunities.kt @@ -108,12 +108,13 @@ fun filterHomePostsByCommunity( val defaultSince = TimeUtils.oneWeekAgo() - return communitySet.set.mapNotNull { - filterHomePostsFromCommunity( - relay = it.key, - community = it.value.community, - authors = it.value.authors, - since = since?.get(it.key)?.time ?: defaultSince, - ) - }.flatten() + return communitySet.set + .mapNotNull { + filterHomePostsFromCommunity( + relay = it.key, + community = it.value.community, + authors = it.value.authors, + since = since?.get(it.key)?.time ?: defaultSince, + ) + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfileFollowers.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfileFollowers.kt index 19ad86a31..274fc334b 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfileFollowers.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfileFollowers.kt @@ -31,8 +31,8 @@ val UserProfileFollowersKinds = listOf(ContactListEvent.KIND) fun filterUserProfileFollowers( user: User, since: SincePerRelayMap?, -): List { - return user.inboxRelays().map { +): List = + user.inboxRelays().map { RelayBasedFilter( relay = it, filter = @@ -43,4 +43,3 @@ fun filterUserProfileFollowers( ), ) } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfileLists.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfileLists.kt index e1ebad1cb..51258fad5 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfileLists.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfileLists.kt @@ -40,8 +40,8 @@ val UserProfileListKinds = fun filterUserProfileLists( users: Map>, since: SincePerRelayMap?, -): List { - return users.map { +): List = + users.map { RelayBasedFilter( relay = it.key, filter = @@ -53,4 +53,3 @@ fun filterUserProfileLists( ), ) } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfileMedia.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfileMedia.kt index 80dc2ec2c..a1a97d332 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfileMedia.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfileMedia.kt @@ -40,8 +40,8 @@ val UserProfileMediaKinds = fun filterUserProfileMedia( user: User, since: SincePerRelayMap?, -): List { - return user.outboxRelays().map { relay -> +): List = + user.outboxRelays().map { relay -> RelayBasedFilter( relay = relay, filter = @@ -53,4 +53,3 @@ fun filterUserProfileMedia( ), ) } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfilePosts.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfilePosts.kt index 43bd81fe9..24e306865 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfilePosts.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfilePosts.kt @@ -60,29 +60,30 @@ val UserProfilePostKinds2 = fun filterUserProfilePosts( user: User, since: SincePerRelayMap?, -): List { - return user.outboxRelays().map { relay -> - listOf( - RelayBasedFilter( - relay = relay, - filter = - Filter( - kinds = UserProfilePostKinds1, - authors = listOf(user.pubkeyHex), - limit = 200, - since = since?.get(relay)?.time, - ), - ), - RelayBasedFilter( - relay = relay, - filter = - Filter( - kinds = UserProfilePostKinds2, - authors = listOf(user.pubkeyHex), - limit = 50, - since = since?.get(relay)?.time, - ), - ), - ) - }.flatten() -} +): List = + user + .outboxRelays() + .map { relay -> + listOf( + RelayBasedFilter( + relay = relay, + filter = + Filter( + kinds = UserProfilePostKinds1, + authors = listOf(user.pubkeyHex), + limit = 200, + since = since?.get(relay)?.time, + ), + ), + RelayBasedFilter( + relay = relay, + filter = + Filter( + kinds = UserProfilePostKinds2, + authors = listOf(user.pubkeyHex), + limit = 50, + since = since?.get(relay)?.time, + ), + ), + ) + }.flatten() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfileZapReceived.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfileZapReceived.kt index f9abf7c27..ffd963542 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfileZapReceived.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/profile/datasource/FilterUserProfileZapReceived.kt @@ -31,8 +31,8 @@ val UserProfileZapReceiverKinds = listOf(LnZapEvent.KIND) fun filterUserProfileZapsReceived( user: User, since: SincePerRelayMap?, -): List { - return user.inboxRelays().map { relay -> +): List = + user.inboxRelays().map { relay -> RelayBasedFilter( relay = relay, filter = @@ -44,4 +44,3 @@ fun filterUserProfileZapsReceived( ), ) } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/BasicRelaySetupInfo.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/BasicRelaySetupInfo.kt index 1f13e3d63..c176d9750 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/BasicRelaySetupInfo.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/BasicRelaySetupInfo.kt @@ -32,9 +32,8 @@ data class BasicRelaySetupInfo( val paidRelay: Boolean = false, ) -fun relaySetupInfoBuilder(normalized: NormalizedRelayUrl): BasicRelaySetupInfo { - return BasicRelaySetupInfo( +fun relaySetupInfoBuilder(normalized: NormalizedRelayUrl): BasicRelaySetupInfo = + BasicRelaySetupInfo( normalized, RelayStats.get(normalized), ) -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/local/LocalRelayListViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/local/LocalRelayListViewModel.kt index 615668f81..9cabbb3bd 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/local/LocalRelayListViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/local/LocalRelayListViewModel.kt @@ -24,7 +24,9 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.relays.common.BasicRelaySet import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl class LocalRelayListViewModel : BasicRelaySetupInfoModel() { - override fun getRelayList(): List = account.localRelayList.flow.value.toList() + override fun getRelayList(): List = + account.localRelayList.flow.value + .toList() override fun saveRelayList(urlList: List) { account.localRelayList.saveRelayList(urlList) {} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/SecurityFiltersScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/SecurityFiltersScreen.kt index 2981f85d9..cb49a840a 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/SecurityFiltersScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/SecurityFiltersScreen.kt @@ -335,8 +335,10 @@ fun WatchAccountAndBlockList( accountViewModel: AccountViewModel, invalidate: () -> Unit, ) { - val transientSpammers by accountViewModel.account.hiddenUsers.transientHiddenUsers.collectAsStateWithLifecycle() - val blockListState by accountViewModel.account.hiddenUsers.flow.collectAsStateWithLifecycle() + val transientSpammers by accountViewModel.account.hiddenUsers.transientHiddenUsers + .collectAsStateWithLifecycle() + val blockListState by accountViewModel.account.hiddenUsers.flow + .collectAsStateWithLifecycle() LaunchedEffect(accountViewModel, transientSpammers, blockListState) { invalidate() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/dal/SpammerAccountsFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/dal/SpammerAccountsFeedFilter.kt index 69a19a8bd..542fa1f92 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/dal/SpammerAccountsFeedFilter.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/settings/dal/SpammerAccountsFeedFilter.kt @@ -32,5 +32,7 @@ class SpammerAccountsFeedFilter( override fun showHiddenKey(): Boolean = true - override fun feed(): List = account.hiddenUsers.transientHiddenUsers.value.map { LocalCache.getOrCreateUser(it) } + override fun feed(): List = + account.hiddenUsers.transientHiddenUsers.value + .map { LocalCache.getOrCreateUser(it) } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/VideoScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/VideoScreen.kt index e8f5f14c0..e925c9be1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/VideoScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/VideoScreen.kt @@ -164,7 +164,9 @@ fun WatchAccountForVideoScreen( accountViewModel: AccountViewModel, ) { val listState by accountViewModel.account.liveStoriesFollowLists.collectAsStateWithLifecycle() - val hiddenUsers = accountViewModel.account.hiddenUsers.flow.collectAsStateWithLifecycle() + val hiddenUsers = + accountViewModel.account.hiddenUsers.flow + .collectAsStateWithLifecycle() LaunchedEffect(accountViewModel, listState, hiddenUsers) { videoFeedContentState.checkKeysInvalidateDataAndSendToTop() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip01Core/FilterPictureAndVideoByGeohash.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip01Core/FilterPictureAndVideoByGeohash.kt index 277c21e6b..5e8d242fa 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip01Core/FilterPictureAndVideoByGeohash.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip01Core/FilterPictureAndVideoByGeohash.kt @@ -72,15 +72,16 @@ fun filterPictureAndVideoByGeohash( ): List { if (geoSet.set.isEmpty()) return emptyList() - return geoSet.set.mapNotNull { - if (it.value.geotags.isEmpty()) { - null - } else { - filterPictureAndVideoGeohash( - relay = it.key, - geotags = it.value.geotags, - since = since?.get(it.key)?.time, - ) - } - }.flatten() + return geoSet.set + .mapNotNull { + if (it.value.geotags.isEmpty()) { + null + } else { + filterPictureAndVideoGeohash( + relay = it.key, + geotags = it.value.geotags, + since = since?.get(it.key)?.time, + ) + } + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip01Core/FilterPictureAndVideoByHashtag.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip01Core/FilterPictureAndVideoByHashtag.kt index 12dc9003e..7c40f4452 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip01Core/FilterPictureAndVideoByHashtag.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip01Core/FilterPictureAndVideoByHashtag.kt @@ -75,15 +75,16 @@ fun filterPictureAndVideoByHashtag( val defaultSince = TimeUtils.oneWeekAgo() - return hashSet.set.mapNotNull { relayHashSet -> - if (relayHashSet.value.hashtags.isEmpty()) { - null - } else { - filterPictureAndVideoHashtag( - relay = relayHashSet.key, - hashtags = relayHashSet.value.hashtags, - since = since?.get(relayHashSet.key)?.time ?: defaultSince, - ) - } - }.flatten() + return hashSet.set + .mapNotNull { relayHashSet -> + if (relayHashSet.value.hashtags.isEmpty()) { + null + } else { + filterPictureAndVideoHashtag( + relay = relayHashSet.key, + hashtags = relayHashSet.value.hashtags, + since = since?.get(relayHashSet.key)?.time ?: defaultSince, + ) + } + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip65Follows/FilterPictureAndVideoByAuthors.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip65Follows/FilterPictureAndVideoByAuthors.kt index 7b490dcad..25e142395 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip65Follows/FilterPictureAndVideoByAuthors.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip65Follows/FilterPictureAndVideoByAuthors.kt @@ -73,17 +73,18 @@ fun filterPictureAndVideoByAuthors( val defaultSince = TimeUtils.oneWeekAgo() - return authorSet.set.mapNotNull { - if (it.value.authors.isEmpty()) { - null - } else { - filterPictureAndVideoAuthors( - relay = it.key, - authors = it.value.authors, - since = since?.get(it.key)?.time ?: defaultSince, - ) - } - }.flatten() + return authorSet.set + .mapNotNull { + if (it.value.authors.isEmpty()) { + null + } else { + filterPictureAndVideoAuthors( + relay = it.key, + authors = it.value.authors, + since = since?.get(it.key)?.time ?: defaultSince, + ) + } + }.flatten() } fun filterPictureAndVideoByAuthors( @@ -94,15 +95,16 @@ fun filterPictureAndVideoByAuthors( val defaultSince = TimeUtils.oneWeekAgo() - return authorSet.set.mapNotNull { - if (it.value.authors.isEmpty()) { - null - } else { - filterPictureAndVideoAuthors( - relay = it.key, - authors = it.value.authors, - since = since?.get(it.key)?.time ?: defaultSince, - ) - } - }.flatten() + return authorSet.set + .mapNotNull { + if (it.value.authors.isEmpty()) { + null + } else { + filterPictureAndVideoAuthors( + relay = it.key, + authors = it.value.authors, + since = since?.get(it.key)?.time ?: defaultSince, + ) + } + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip72Communities/FilterPictureAndVideoByAllCommunities.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip72Communities/FilterPictureAndVideoByAllCommunities.kt index 08071cb90..997bdb254 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip72Communities/FilterPictureAndVideoByAllCommunities.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip72Communities/FilterPictureAndVideoByAllCommunities.kt @@ -107,11 +107,12 @@ fun filterPictureAndVideoByAllCommunities( ): List { if (communitySet.set.isEmpty()) return emptyList() - return communitySet.set.mapNotNull { - filterPictureAndVideoAllCommunities( - relay = it.key, - communities = it.value.communities, - since = since?.get(it.key)?.time, - ) - }.flatten() + return communitySet.set + .mapNotNull { + filterPictureAndVideoAllCommunities( + relay = it.key, + communities = it.value.communities, + since = since?.get(it.key)?.time, + ) + }.flatten() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip72Communities/FilterPictureAndVideoByCommunity.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip72Communities/FilterPictureAndVideoByCommunity.kt index 61aee43e2..a6c532b04 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip72Communities/FilterPictureAndVideoByCommunity.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/video/datasource/subassemblies/nip72Communities/FilterPictureAndVideoByCommunity.kt @@ -113,12 +113,13 @@ fun filterPictureAndVideoByCommunity( val defaultSince = TimeUtils.oneWeekAgo() - return communitySet.set.mapNotNull { - filterPictureAndVideoCommunity( - relay = it.key, - community = it.value.community, - authors = it.value.authors, - since = since?.get(it.key)?.time ?: defaultSince, - ) - }.flatten() + return communitySet.set + .mapNotNull { + filterPictureAndVideoCommunity( + relay = it.key, + community = it.value.community, + authors = it.value.authors, + since = since?.get(it.key)?.time ?: defaultSince, + ) + }.flatten() } diff --git a/ammolite/src/main/java/com/vitorpamplona/ammolite/relays/filters/MutableTime.kt b/ammolite/src/main/java/com/vitorpamplona/ammolite/relays/filters/MutableTime.kt index 155f628c5..67dfd8f2f 100644 --- a/ammolite/src/main/java/com/vitorpamplona/ammolite/relays/filters/MutableTime.kt +++ b/ammolite/src/main/java/com/vitorpamplona/ammolite/relays/filters/MutableTime.kt @@ -23,7 +23,9 @@ package com.vitorpamplona.ammolite.relays.filters /* * Wrapper class to allow changing in EOSE without modifying the list it is included within */ -class MutableTime(startTime: Long) { +class MutableTime( + startTime: Long, +) { var time: Long = startTime private set diff --git a/quartz/src/main/java/com/vitorpamplona/quartz/nip01Core/relay/client/pool/RelayBasedFilter.kt b/quartz/src/main/java/com/vitorpamplona/quartz/nip01Core/relay/client/pool/RelayBasedFilter.kt index d4922d889..2383936e7 100644 --- a/quartz/src/main/java/com/vitorpamplona/quartz/nip01Core/relay/client/pool/RelayBasedFilter.kt +++ b/quartz/src/main/java/com/vitorpamplona/quartz/nip01Core/relay/client/pool/RelayBasedFilter.kt @@ -33,11 +33,10 @@ class RelayBasedFilter( // This only exists because some relays confuse empty lists with null lists fun isValidFor(relay: NormalizedRelayUrl) = relay == this.relay - fun toFilter(relay: NormalizedRelayUrl): Filter? { - return if (isValidFor(relay)) { + fun toFilter(relay: NormalizedRelayUrl): Filter? = + if (isValidFor(relay)) { filter } else { null } - } } diff --git a/quartz/src/main/java/com/vitorpamplona/quartz/nip01Core/relay/client/single/simple/OutboxProtector.kt b/quartz/src/main/java/com/vitorpamplona/quartz/nip01Core/relay/client/single/simple/OutboxProtector.kt index 80d1d378e..9e1884b9a 100644 --- a/quartz/src/main/java/com/vitorpamplona/quartz/nip01Core/relay/client/single/simple/OutboxProtector.kt +++ b/quartz/src/main/java/com/vitorpamplona/quartz/nip01Core/relay/client/single/simple/OutboxProtector.kt @@ -29,7 +29,9 @@ import com.vitorpamplona.quartz.nip01Core.relay.client.single.IRelayClient import com.vitorpamplona.quartz.nip42RelayAuth.RelayAuthEvent import com.vitorpamplona.quartz.utils.LargeCache -class OutboxProtector(listener: IRelayClientListener) : RedirectRelayClientListener(listener) { +class OutboxProtector( + listener: IRelayClientListener, +) : RedirectRelayClientListener(listener) { /** * Auth procedures require us to keep track of the outgoing events * to make sure the relay waits for the auth to finish and send them. diff --git a/quartz/src/main/java/com/vitorpamplona/quartz/nip01Core/relay/normalizer/NormalizedRelayUrl.kt b/quartz/src/main/java/com/vitorpamplona/quartz/nip01Core/relay/normalizer/NormalizedRelayUrl.kt index 38abf28e7..c74f03348 100644 --- a/quartz/src/main/java/com/vitorpamplona/quartz/nip01Core/relay/normalizer/NormalizedRelayUrl.kt +++ b/quartz/src/main/java/com/vitorpamplona/quartz/nip01Core/relay/normalizer/NormalizedRelayUrl.kt @@ -20,7 +20,9 @@ */ package com.vitorpamplona.quartz.nip01Core.relay.normalizer -data class NormalizedRelayUrl(val url: String) : Comparable { +data class NormalizedRelayUrl( + val url: String, +) : Comparable { override fun compareTo(other: NormalizedRelayUrl) = url.compareTo(other.url) } diff --git a/quartz/src/main/java/com/vitorpamplona/quartz/nip01Core/relay/normalizer/RelayUrlNormalizer.kt b/quartz/src/main/java/com/vitorpamplona/quartz/nip01Core/relay/normalizer/RelayUrlNormalizer.kt index f42e8b7d8..8d3a84549 100644 --- a/quartz/src/main/java/com/vitorpamplona/quartz/nip01Core/relay/normalizer/RelayUrlNormalizer.kt +++ b/quartz/src/main/java/com/vitorpamplona/quartz/nip01Core/relay/normalizer/RelayUrlNormalizer.kt @@ -31,7 +31,14 @@ class RelayUrlNormalizer { fun isOnion(url: String) = url.endsWith(".onion") || url.endsWith(".onion/") - private fun norm(url: String) = NormalizedRelayUrl(URIReference.parse(url).normalize().toString().intern()) + private fun norm(url: String) = + NormalizedRelayUrl( + URIReference + .parse(url) + .normalize() + .toString() + .intern(), + ) fun fix(url: String): String { val trimmed = url.trim() diff --git a/quartz/src/main/java/com/vitorpamplona/quartz/nip10Notes/tags/MarkedETag.kt b/quartz/src/main/java/com/vitorpamplona/quartz/nip10Notes/tags/MarkedETag.kt index 2c04df5d1..ece41e8b2 100644 --- a/quartz/src/main/java/com/vitorpamplona/quartz/nip10Notes/tags/MarkedETag.kt +++ b/quartz/src/main/java/com/vitorpamplona/quartz/nip10Notes/tags/MarkedETag.kt @@ -59,15 +59,14 @@ data class MarkedETag( ; companion object { - fun parse(code: String): MARKER? { - return when (code) { + fun parse(code: String): MARKER? = + when (code) { ROOT.code -> ROOT REPLY.code -> REPLY MENTION.code -> MENTION FORK.code -> FORK else -> null } - } } } diff --git a/quartz/src/main/java/com/vitorpamplona/quartz/nip17Dm/settings/ChatMessageRelayListEvent.kt b/quartz/src/main/java/com/vitorpamplona/quartz/nip17Dm/settings/ChatMessageRelayListEvent.kt index ac5a6eb2b..40c933834 100644 --- a/quartz/src/main/java/com/vitorpamplona/quartz/nip17Dm/settings/ChatMessageRelayListEvent.kt +++ b/quartz/src/main/java/com/vitorpamplona/quartz/nip17Dm/settings/ChatMessageRelayListEvent.kt @@ -58,8 +58,7 @@ class ChatMessageRelayListEvent( RelayTag.assemble(it) }.plusElement( AltTag.assemble("Relay list to receive private messages"), - ) - .toTypedArray() + ).toTypedArray() fun updateRelayList( earlierVersion: ChatMessageRelayListEvent, @@ -69,7 +68,8 @@ class ChatMessageRelayListEvent( onReady: (ChatMessageRelayListEvent) -> Unit, ) { val tags = - earlierVersion.tags.filter(RelayTag::notMatch) + earlierVersion.tags + .filter(RelayTag::notMatch) .plus( relays.map { RelayTag.assemble(it) diff --git a/quartz/src/main/java/com/vitorpamplona/quartz/nip28PublicChat/admin/ChannelCreateEvent.kt b/quartz/src/main/java/com/vitorpamplona/quartz/nip28PublicChat/admin/ChannelCreateEvent.kt index d7925bd07..c7164a668 100644 --- a/quartz/src/main/java/com/vitorpamplona/quartz/nip28PublicChat/admin/ChannelCreateEvent.kt +++ b/quartz/src/main/java/com/vitorpamplona/quartz/nip28PublicChat/admin/ChannelCreateEvent.kt @@ -46,16 +46,15 @@ class ChannelCreateEvent( sig: HexKey, ) : Event(id, pubKey, createdAt, KIND, tags, content, sig), EventHintProvider { - override fun eventHints() = channelInfo().relays?.mapNotNull { EventIdHint(id, it) } ?: emptyList() + override fun eventHints() = channelInfo().relays?.map { EventIdHint(id, it) } ?: emptyList() - fun channelInfo(): ChannelDataNorm { - return try { + fun channelInfo(): ChannelDataNorm = + try { ChannelData.parse(content)?.normalize() ?: ChannelDataNorm() } catch (e: JsonParseException) { - Log.e("ChannelCreateEvent", "Failure to parse ${this.toJson()}", e) + Log.w("ChannelCreateEvent", "Failure to parse ${this.toJson()}", e) ChannelDataNorm() } - } companion object { const val KIND = 40 diff --git a/quartz/src/main/java/com/vitorpamplona/quartz/nip28PublicChat/admin/ChannelMetadataEvent.kt b/quartz/src/main/java/com/vitorpamplona/quartz/nip28PublicChat/admin/ChannelMetadataEvent.kt index 456bca8bc..d46c0ece8 100644 --- a/quartz/src/main/java/com/vitorpamplona/quartz/nip28PublicChat/admin/ChannelMetadataEvent.kt +++ b/quartz/src/main/java/com/vitorpamplona/quartz/nip28PublicChat/admin/ChannelMetadataEvent.kt @@ -48,16 +48,15 @@ class ChannelMetadataEvent( sig: HexKey, ) : BasePublicChatEvent(id, pubKey, createdAt, KIND, tags, content, sig), EventHintProvider { - override fun eventHints() = channelInfo().relays?.mapNotNull { EventIdHint(id, it) } ?: emptyList() + override fun eventHints() = channelInfo().relays?.map { EventIdHint(id, it) } ?: emptyList() - fun channelInfo(): ChannelDataNorm { - return try { + fun channelInfo(): ChannelDataNorm = + try { ChannelData.parse(content)?.normalize() ?: ChannelDataNorm() } catch (e: JsonParseException) { - Log.e("ChannelCreateEvent", "Failure to parse ${this.toJson()}", e) + Log.w("ChannelCreateEvent", "Failure to parse ${this.toJson()}", e) ChannelDataNorm() } - } companion object { const val KIND = 41 diff --git a/quartz/src/main/java/com/vitorpamplona/quartz/nip51Lists/MuteListEvent.kt b/quartz/src/main/java/com/vitorpamplona/quartz/nip51Lists/MuteListEvent.kt index 4536f28bd..16719a972 100644 --- a/quartz/src/main/java/com/vitorpamplona/quartz/nip51Lists/MuteListEvent.kt +++ b/quartz/src/main/java/com/vitorpamplona/quartz/nip51Lists/MuteListEvent.kt @@ -61,13 +61,12 @@ class MuteListEvent( } } - suspend fun publicAndPrivateUsersAndWords(signer: NostrSigner): UsersAndWords? { - return tryAndWait { continuation -> + suspend fun publicAndPrivateUsersAndWords(signer: NostrSigner): UsersAndWords? = + tryAndWait { continuation -> publicAndPrivateUsersAndWords(signer) { privateTagList -> continuation.resume(privateTagList) } } - } companion object { const val KIND = 10000 diff --git a/quartz/src/main/java/com/vitorpamplona/quartz/nip51Lists/PeopleListEvent.kt b/quartz/src/main/java/com/vitorpamplona/quartz/nip51Lists/PeopleListEvent.kt index 3e35ff9f5..08a80ad1a 100644 --- a/quartz/src/main/java/com/vitorpamplona/quartz/nip51Lists/PeopleListEvent.kt +++ b/quartz/src/main/java/com/vitorpamplona/quartz/nip51Lists/PeopleListEvent.kt @@ -64,13 +64,12 @@ class PeopleListEvent( } } - suspend fun publicAndPrivateUsersAndWords(signer: NostrSigner): UsersAndWords? { - return tryAndWait { continuation -> + suspend fun publicAndPrivateUsersAndWords(signer: NostrSigner): UsersAndWords? = + tryAndWait { continuation -> publicAndPrivateUsersAndWords(signer) { privateTagList -> continuation.resume(privateTagList) } } - } fun isTaggedWord( word: String, diff --git a/quartz/src/main/java/com/vitorpamplona/quartz/nip65RelayList/RelayListRecommendationProcessor.kt b/quartz/src/main/java/com/vitorpamplona/quartz/nip65RelayList/RelayListRecommendationProcessor.kt index fd0953e56..5856ed926 100644 --- a/quartz/src/main/java/com/vitorpamplona/quartz/nip65RelayList/RelayListRecommendationProcessor.kt +++ b/quartz/src/main/java/com/vitorpamplona/quartz/nip65RelayList/RelayListRecommendationProcessor.kt @@ -31,8 +31,8 @@ class RelayListRecommendationProcessor { fun transpose( userList: Map>, ignore: Set = setOf(), - ): Map> { - return mapOfSet { + ): Map> = + mapOfSet { userList.forEach { event -> event.value.forEach { relay -> if (relay !in ignore) { @@ -41,7 +41,6 @@ class RelayListRecommendationProcessor { } } } - } /** * filter onion and local host from write relays @@ -50,8 +49,8 @@ class RelayListRecommendationProcessor { private fun filterValidRelays( userList: List, hasOnionConnection: Boolean = false, - ): Map> { - return mapOfSet { + ): Map> = + mapOfSet { userList.forEach { event -> event.writeRelaysNorm()?.forEach { relay -> if (!relay.isLocalHost() && (hasOnionConnection || !relay.isOnion())) { @@ -60,7 +59,6 @@ class RelayListRecommendationProcessor { } } } - } fun reliableRelaySetFor( usersAndRelays: Map>, diff --git a/quartz/src/main/java/com/vitorpamplona/quartz/nip65RelayList/tags/AdvertisedRelayInfoTag.kt b/quartz/src/main/java/com/vitorpamplona/quartz/nip65RelayList/tags/AdvertisedRelayInfoTag.kt index 07d6a1319..4bb8d237b 100644 --- a/quartz/src/main/java/com/vitorpamplona/quartz/nip65RelayList/tags/AdvertisedRelayInfoTag.kt +++ b/quartz/src/main/java/com/vitorpamplona/quartz/nip65RelayList/tags/AdvertisedRelayInfoTag.kt @@ -94,13 +94,12 @@ class AdvertisedRelayInfo( fun assemble( relay: NormalizedRelayUrl, type: AdvertisedRelayType, - ): Array { - return if (type == AdvertisedRelayType.BOTH) { + ): Array = + if (type == AdvertisedRelayType.BOTH) { arrayOf(TAG_NAME, relay.url) } else { arrayOf(TAG_NAME, relay.url, type.code) } - } } } diff --git a/quartz/src/main/java/com/vitorpamplona/quartz/nip73ExternalIds/topics/HashtagId.kt b/quartz/src/main/java/com/vitorpamplona/quartz/nip73ExternalIds/topics/HashtagId.kt index 50b4be0a3..166d3a255 100644 --- a/quartz/src/main/java/com/vitorpamplona/quartz/nip73ExternalIds/topics/HashtagId.kt +++ b/quartz/src/main/java/com/vitorpamplona/quartz/nip73ExternalIds/topics/HashtagId.kt @@ -70,23 +70,21 @@ class HashtagId( return encoded.indexOf(value, 1) > 0 } - fun parse(encoded: String): String? { - return if (encoded.length > 1 && encoded[0] == KIND_CHR) { + fun parse(encoded: String): String? = + if (encoded.length > 1 && encoded[0] == KIND_CHR) { encoded.substring(1) } else { null } - } fun parse( encoded: String, hint: String?, - ): HashtagId? { - return if (encoded.length > 1 && encoded[0] == KIND_CHR) { + ): HashtagId? = + if (encoded.length > 1 && encoded[0] == KIND_CHR) { HashtagId(encoded.substring(1), hint) } else { null } - } } } diff --git a/quartz/src/main/java/com/vitorpamplona/quartz/utils/MapOfSetBuilder.kt b/quartz/src/main/java/com/vitorpamplona/quartz/utils/MapOfSetBuilder.kt index 698daf72b..95fbae954 100644 --- a/quartz/src/main/java/com/vitorpamplona/quartz/utils/MapOfSetBuilder.kt +++ b/quartz/src/main/java/com/vitorpamplona/quartz/utils/MapOfSetBuilder.kt @@ -64,10 +64,9 @@ fun mapOfSet(init: MapOfSetBuilder.() -> Unit): Map> { return data.build() } -fun merge(maps: List>>): Map> { - return mapOfSet { +fun merge(maps: List>>): Map> = + mapOfSet { maps.forEach { map -> add(map) } } -} diff --git a/quartz/src/test/java/com/vitorpamplona/quartz/nip01Core/hints/HintIndexerTest.kt b/quartz/src/test/java/com/vitorpamplona/quartz/nip01Core/hints/HintIndexerTest.kt index 4a265ad02..f58a4cf7d 100644 --- a/quartz/src/test/java/com/vitorpamplona/quartz/nip01Core/hints/HintIndexerTest.kt +++ b/quartz/src/test/java/com/vitorpamplona/quartz/nip01Core/hints/HintIndexerTest.kt @@ -63,7 +63,8 @@ class HintIndexerTest { .getResourceAsStream("relayDB.txt") ?.readAllBytes() .toString() - .split("\n").mapNotNull { RelayUrlNormalizer.normalizeOrNull(it) } + .split("\n") + .mapNotNull { RelayUrlNormalizer.normalizeOrNull(it) } val indexer by lazy { System.gc()