remove redundant modifiers

This commit is contained in:
davotoula
2026-03-06 19:17:56 +01:00
parent 8329184d99
commit bd71e9ae8f
45 changed files with 59 additions and 61 deletions
@@ -80,7 +80,7 @@ class ImageUploadTesting {
.addInterceptor(DefaultContentTypeInterceptor("Amethyst/${BuildConfig.VERSION_NAME}"))
.build()
private suspend fun getBitmap(): ByteArray {
private fun getBitmap(): ByteArray {
val bitmap = Bitmap.createBitmap(200, 300, Bitmap.Config.ARGB_8888)
for (x in 0 until bitmap.width) {
for (y in 0 until bitmap.height) {
@@ -34,9 +34,9 @@ class TorAwareOkHttpOtsResolverBuilder(
) : OtsResolverBuilder {
fun getAPI(usingTor: Boolean) =
if (usingTor) {
OkHttpBitcoinExplorer.Companion.MEMPOOL_API_URL
OkHttpBitcoinExplorer.MEMPOOL_API_URL
} else {
OkHttpBitcoinExplorer.Companion.BLOCKSTREAM_API_URL
OkHttpBitcoinExplorer.BLOCKSTREAM_API_URL
}
override fun build(): OtsResolver =
@@ -44,9 +44,9 @@ class TorAwareOkHttpOtsResolverBuilder(
explorer =
OkHttpBitcoinExplorer(
baseUrl = {
getAPI(usingTor = isTorActive(OkHttpBitcoinExplorer.Companion.MEMPOOL_API_URL))
getAPI(usingTor = isTorActive(OkHttpBitcoinExplorer.MEMPOOL_API_URL))
},
client = okHttpClient(OkHttpBitcoinExplorer.Companion.MEMPOOL_API_URL),
client = okHttpClient(OkHttpBitcoinExplorer.MEMPOOL_API_URL),
cache = cache,
),
calendar = OkHttpCalendar(okHttpClient),
@@ -62,7 +62,7 @@ class BookmarkListState(
fun getBookmarkList(): BookmarkListEvent? = bookmarkList.event as? BookmarkListEvent
suspend fun publicBookmarks(note: Note): List<BookmarkIdTag> {
fun publicBookmarks(note: Note): List<BookmarkIdTag> {
val noteEvent = note.event as? BookmarkListEvent
return noteEvent?.publicBookmarks() ?: emptyList()
}
@@ -47,7 +47,7 @@ class HiddenUsersState(
) {
var transientHiddenUsers: MutableStateFlow<Set<String>> = MutableStateFlow(setOf())
suspend fun assembleLiveHiddenUsers(
fun assembleLiveHiddenUsers(
blockList: List<MuteTag>,
muteList: List<MuteTag>,
transientHiddenUsers: Set<String>,
@@ -51,7 +51,7 @@ class SearchRelayListState(
// Creates a long-term reference for this note so that the GC doesn't collect the note it self
val searchListNote = cache.getOrCreateAddressableNote(getSearchRelayListAddress())
fun getSearchRelayListAddress() = SearchRelayListEvent.Companion.createAddress(signer.pubKey)
fun getSearchRelayListAddress() = SearchRelayListEvent.createAddress(signer.pubKey)
fun getSearchRelayListFlow(): StateFlow<NoteState> = searchListNote.flow().metadata.stateFlow
@@ -70,7 +70,7 @@ class SearchRelayListState(
.flowOn(Dispatchers.IO)
.stateIn(
scope,
SharingStarted.Companion.Eagerly,
SharingStarted.Eagerly,
emptySet(),
)
@@ -68,7 +68,7 @@ class TrustedRelayListState(
.flowOn(Dispatchers.IO)
.stateIn(
scope,
SharingStarted.Companion.Eagerly,
SharingStarted.Eagerly,
emptySet(),
)
@@ -76,13 +76,13 @@ class TrustedRelayListState(
val relayListForTrusted = getTrustedRelayList()
return if (relayListForTrusted != null && relayListForTrusted.tags.isNotEmpty()) {
TrustedRelayListEvent.Companion.updateRelayList(
TrustedRelayListEvent.updateRelayList(
earlierVersion = relayListForTrusted,
relays = trustedRelays,
signer = signer,
)
} else {
TrustedRelayListEvent.Companion.create(
TrustedRelayListEvent.create(
relays = trustedRelays,
signer = signer,
)
@@ -120,5 +120,5 @@ class BlossomServerListState(
suspend fun createBlossomDeleteAuth(
hash: HexKey,
alt: String,
): BlossomAuthorizationEvent? = BlossomAuthorizationEvent.createDeleteAuth(hash, alt, signer)
): BlossomAuthorizationEvent = BlossomAuthorizationEvent.createDeleteAuth(hash, alt, signer)
}
@@ -29,7 +29,7 @@ import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.map
import java.io.IOException
suspend fun <T> DataStore<Preferences>.getProperty(
fun <T> DataStore<Preferences>.getProperty(
key: Preferences.Key<String>,
parser: (String) -> T,
serializer: (T) -> String,
@@ -67,7 +67,7 @@ class EncryptedDataStore(
?.get(key)
?.let { decrypt(it) }
suspend fun <T> getProperty(
fun <T> getProperty(
key: Preferences.Key<String>,
parser: (String) -> T,
serializer: (T) -> String,
@@ -48,7 +48,7 @@ class OutboxLoaderState(
}.flowOn(Dispatchers.IO)
.stateIn(
scope,
SharingStarted.Companion.Eagerly,
SharingStarted.Eagerly,
UnknownTopNavPerRelayFilterSet,
)
}
@@ -52,8 +52,8 @@ class AllFollowsByOutboxTopNavFilter(
val defaultRelays: StateFlow<Set<NormalizedRelayUrl>>,
val blockedRelays: StateFlow<Set<NormalizedRelayUrl>>,
) : IFeedTopNavFilter {
val geotagScopes: Set<String>? = geotags?.mapTo(mutableSetOf<String>()) { GeohashId.Companion.toScope(it) }
val hashtagScopes: Set<String>? = hashtags?.mapTo(mutableSetOf<String>()) { HashtagId.Companion.toScope(it) }
val geotagScopes: Set<String>? = geotags?.mapTo(mutableSetOf<String>()) { GeohashId.toScope(it) }
val hashtagScopes: Set<String>? = hashtags?.mapTo(mutableSetOf<String>()) { HashtagId.toScope(it) }
override fun matchAuthor(pubkey: HexKey): Boolean = authors == null || pubkey in authors
@@ -47,8 +47,8 @@ class AllFollowsByProxyTopNavFilter(
val communities: Set<String>? = null,
val proxyRelays: Set<NormalizedRelayUrl>,
) : IFeedTopNavFilter {
val geotagScopes: Set<String>? = geotags?.mapTo(mutableSetOf<String>()) { GeohashId.Companion.toScope(it) }
val hashtagScopes: Set<String>? = hashtags?.mapTo(mutableSetOf<String>()) { HashtagId.Companion.toScope(it) }
val geotagScopes: Set<String>? = geotags?.mapTo(mutableSetOf()) { GeohashId.toScope(it) }
val hashtagScopes: Set<String>? = hashtags?.mapTo(mutableSetOf()) { HashtagId.toScope(it) }
override fun matchAuthor(pubkey: HexKey): Boolean = authors == null || pubkey in authors
@@ -62,7 +62,7 @@ class NoteFeedFlow(
): IFeedTopNavFilter =
when (noteEvent) {
is PeopleListEvent -> {
if (noteEvent.dTag() == PeopleListEvent.Companion.BLOCK_LIST_D_TAG) {
if (noteEvent.dTag() == PeopleListEvent.BLOCK_LIST_D_TAG) {
MutedAuthorsByOutboxTopNavFilter(caches.peopleListCache.cachedUserIdSet(noteEvent), blockedRelays)
} else {
AuthorsByOutboxTopNavFilter(caches.peopleListCache.cachedUserIdSet(noteEvent), blockedRelays)
@@ -109,7 +109,7 @@ class NoteFeedFlow(
) {
when (noteEvent) {
is PeopleListEvent -> {
if (noteEvent.dTag() == PeopleListEvent.Companion.BLOCK_LIST_D_TAG) {
if (noteEvent.dTag() == PeopleListEvent.BLOCK_LIST_D_TAG) {
emit(MutedAuthorsByOutboxTopNavFilter(caches.peopleListCache.userIdSet(noteEvent), blockedRelays))
} else {
emit(AuthorsByOutboxTopNavFilter(caches.peopleListCache.userIdSet(noteEvent), blockedRelays))
@@ -161,7 +161,7 @@ class NoteFeedFlow(
): IFeedTopNavFilter =
when (noteEvent) {
is PeopleListEvent -> {
if (noteEvent.dTag() == PeopleListEvent.Companion.BLOCK_LIST_D_TAG) {
if (noteEvent.dTag() == PeopleListEvent.BLOCK_LIST_D_TAG) {
MutedAuthorsByProxyTopNavFilter(caches.peopleListCache.cachedUserIdSet(noteEvent), proxyRelays)
} else {
AuthorsByProxyTopNavFilter(caches.peopleListCache.cachedUserIdSet(noteEvent), proxyRelays)
@@ -208,7 +208,7 @@ class NoteFeedFlow(
) {
when (noteEvent) {
is PeopleListEvent -> {
if (noteEvent.dTag() == PeopleListEvent.Companion.BLOCK_LIST_D_TAG) {
if (noteEvent.dTag() == PeopleListEvent.BLOCK_LIST_D_TAG) {
emit(MutedAuthorsByProxyTopNavFilter(caches.peopleListCache.userIdSet(noteEvent), proxyRelays))
} else {
emit(AuthorsByProxyTopNavFilter(caches.peopleListCache.userIdSet(noteEvent), proxyRelays))
@@ -272,7 +272,7 @@ class NoteFeedFlow(
override fun startValue(): IFeedTopNavFilter {
val noteEvent = metadataFlow.value?.note?.event
return if (noteEvent == null) {
return AuthorsByOutboxTopNavFilter(emptySet(), blockedRelays)
AuthorsByOutboxTopNavFilter(emptySet(), blockedRelays)
} else {
if (proxyRelays.value.isEmpty()) {
processByOutbox(noteEvent, outboxRelays.value)
@@ -83,7 +83,7 @@ class MeltProcessor {
)
}
suspend fun melt(
fun melt(
token: CashuToken,
lud16: String,
okHttpClient: (String) -> OkHttpClient,
@@ -32,7 +32,7 @@ class MemoryTrimmingService(
) {
var isTrimmingMemoryMutex = AtomicBoolean(false)
private suspend fun doTrim(
private fun doTrim(
account: Collection<Account>,
otherAccounts: List<AccountInfo>,
) {
@@ -30,7 +30,7 @@ import com.vitorpamplona.amethyst.service.playback.composable.mainVideo.VideoPla
import com.vitorpamplona.amethyst.service.playback.composable.mediaitem.GetMediaItem
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
public val DEFAULT_MUTED_SETTING = mutableStateOf(true)
val DEFAULT_MUTED_SETTING = mutableStateOf(true)
@Composable
fun VideoViewInner(
@@ -77,7 +77,7 @@ class IntentExtras {
data.mimeType?.let { putString("mimeType", it) }
data.aspectRatio?.let { putFloat("aspectRatio", it) }
data.proxyPort?.let { putInt("proxyPort", it) }
data.keepPlaying.let { putBoolean("keepPlaying", it) }
putBoolean("keepPlaying", data.keepPlaying)
data.waveformData?.let { putFloatArray("wavefrontData", it.wave.toFloatArray()) }
bounds?.let { putInt("boundLeft", it.left) }
@@ -49,7 +49,7 @@ class AccountNotificationsEoseFromInboxRelaysManager(
override fun updateFilter(
key: AccountQueryState,
since: SincePerRelayMap?,
): List<RelayBasedFilter>? =
): List<RelayBasedFilter> =
key.account.notificationRelays.flow.value.flatMap {
filterSummaryNotificationsToPubkey(
relay = it,
@@ -50,7 +50,7 @@ class AccountNotificationsEoseFromRandomRelaysManager(
override fun updateFilter(
key: AccountQueryState,
since: SincePerRelayMap?,
): List<RelayBasedFilter>? {
): List<RelayBasedFilter> {
// only loads this after the feed is built
val defaultSince = key.feedContentStates.notifications.lastNoteCreatedAtIfFilled() ?: TimeUtils.oneWeekAgo()
return (key.account.followsPerRelay.value.keys - key.account.notificationRelays.flow.value).flatMap {
@@ -38,7 +38,7 @@ class ChannelLoaderSubAssembler(
client: INostrClient,
allKeys: () -> Set<ChannelFinderQueryState>,
) : SingleSubNoEoseCacheEoseManager<ChannelFinderQueryState>(client, allKeys, invalidateAfterEose = true) {
override fun updateFilter(keys: List<ChannelFinderQueryState>): List<RelayBasedFilter>? = filterMissingChannelsById(keys)
override fun updateFilter(keys: List<ChannelFinderQueryState>): List<RelayBasedFilter> = filterMissingChannelsById(keys)
override fun distinct(key: ChannelFinderQueryState) = key.channel
}
@@ -71,7 +71,7 @@ fun potentialRelaysToFindAddress(note: AddressableNote): Set<NormalizedRelayUrl>
return set
}
fun filterMissingAddressables(keys: List<EventFinderQueryState>): List<RelayBasedFilter>? {
fun filterMissingAddressables(keys: List<EventFinderQueryState>): List<RelayBasedFilter> {
val addressesPerRelay =
mapOfSet {
keys.forEach { key ->
@@ -67,7 +67,7 @@ fun potentialRelaysToFindEvent(note: Note): Set<NormalizedRelayUrl> {
return set
}
fun filterMissingEvents(keys: List<EventFinderQueryState>): List<RelayBasedFilter>? {
fun filterMissingEvents(keys: List<EventFinderQueryState>): List<RelayBasedFilter> {
val eventsPerRelay =
mapOfSet {
keys.forEach { key ->
@@ -207,6 +207,4 @@ internal fun Iterable<Float>.normalize(
return values.map { scale * ((it - currentMin) / range) + min }
}
private fun Int.safeDiv(value: Int): Float {
return if (value == 0) return 0F else this / value.toFloat()
}
private fun Int.safeDiv(value: Int): Float = if (value == 0) 0F else this / value.toFloat()
@@ -64,7 +64,7 @@ class ChannelFeedContentState(
viewModelScope.launch(Dispatchers.IO) { _scrollToTop.emit(_scrollToTop.value + 1) }
}
suspend fun sentToTop() {
fun sentToTop() {
scrolltoTopPending = false
}
@@ -323,7 +323,7 @@ suspend fun routeEditDraftTo(
is ChatroomKeyable -> {
val room = draft.chatroomKey(account.userProfile().pubkeyHex)
account.chatroomList.getOrCreatePrivateChatroom(room)
return Route.Room(room, draftId = note.idHex)
Route.Room(room, draftId = note.idHex)
}
is TextNoteEvent -> {
@@ -262,7 +262,7 @@ class PollNoteViewModel : ViewModel() {
valueMinimum?.let { minimum ->
valueMaximum?.let { maximum ->
if (minimum != maximum) {
options.add(((minimum + maximum) / 2).toLong())
options.add(((minimum + maximum) / 2))
}
}
}
@@ -474,7 +474,7 @@ open class CommentPostViewModel :
myMultiOrchestrator.upload(
alt,
contentWarningReason,
MediaCompressor.Companion.intToCompressorQuality(mediaQuality),
MediaCompressor.intToCompressorQuality(mediaQuality),
server,
account,
context,
@@ -703,5 +703,5 @@ open class CommentPostViewModel :
return location!!
}
override fun locationManager(): LocationState = Amethyst.Companion.instance.locationManager
override fun locationManager(): LocationState = Amethyst.instance.locationManager
}
@@ -63,7 +63,7 @@ import com.vitorpamplona.quartz.nip30CustomEmoji.pack.EmojiPackEvent
import com.vitorpamplona.quartz.nip30CustomEmoji.taggedEmojis
@Composable
public fun RenderEmojiPack(
fun RenderEmojiPack(
baseNote: Note,
actionable: Boolean,
backgroundColor: MutableState<Color>,
@@ -86,7 +86,7 @@ public fun RenderEmojiPack(
@OptIn(ExperimentalLayoutApi::class)
@Composable
public fun RenderEmojiPack(
fun RenderEmojiPack(
noteEvent: EmojiPackEvent,
baseNote: Note,
actionable: Boolean,
@@ -118,7 +118,7 @@ class AccountSessionManager(
}
}
private suspend fun requestLoginUI() = _accountContent.update { AccountState.LoggedOff }
private fun requestLoginUI() = _accountContent.update { AccountState.LoggedOff }
suspend fun loginAndStartUI(
key: String,
@@ -29,7 +29,7 @@ import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent
fun filterMessagesToPublicChat(
channel: PublicChatChannel,
since: SincePerRelayMap?,
): List<RelayBasedFilter>? =
): List<RelayBasedFilter> =
channel.relays().toSet().map {
RelayBasedFilter(
relay = it,
@@ -31,7 +31,7 @@ fun filterMyMessagesToLiveActivities(
channel: LiveActivitiesChannel,
pubKey: HexKey,
since: SincePerRelayMap?,
): List<RelayBasedFilter>? =
): List<RelayBasedFilter> =
channel.relays().toSet().map {
RelayBasedFilter(
relay = it,
@@ -40,7 +40,7 @@ class FollowingEphemeralChatSubAssembler(
override fun updateFilter(
key: ChatroomListState,
since: SincePerRelayMap?,
): List<RelayBasedFilter>? =
): List<RelayBasedFilter> =
listOfNotNull(
filterFollowingEphemeralChats(key.account.ephemeralChatList.liveEphemeralChatList.value, since),
).flatten()
@@ -40,7 +40,7 @@ class FollowingPublicChatSubAssembler(
override fun updateFilter(
key: ChatroomListState,
since: SincePerRelayMap?,
): List<RelayBasedFilter>? =
): List<RelayBasedFilter> =
listOfNotNull(
filterLastMessageFollowingPublicChats(key.account.publicChatList.flowSet.value, since),
filterFollowingPublicChatsCreationEvent(key.account.publicChatList.flowSet.value, since),
@@ -32,7 +32,7 @@ class GeoHashFeedFilterSubAssembler(
override fun updateFilter(
key: GeohashQueryState,
since: SincePerRelayMap?,
): List<RelayBasedFilter>? = filterPostsByGeohash(key.geohash, key.relays, since)
): List<RelayBasedFilter> = filterPostsByGeohash(key.geohash, key.relays, since)
/**
* Only one key per hashtag.
@@ -32,7 +32,7 @@ class UserProfileFollowersFilterSubAssembler(
override fun updateFilter(
key: UserProfileQueryState,
since: SincePerRelayMap?,
): List<RelayBasedFilter>? = filterUserProfileFollowers(user(key), since)
): List<RelayBasedFilter> = filterUserProfileFollowers(user(key), since)
override fun user(key: UserProfileQueryState) = key.user
}
@@ -34,7 +34,7 @@ class UserProfileMetadataFilterSubAssembler(
override fun updateFilter(
keys: List<UserProfileQueryState>,
since: SincePerRelayMap?,
): List<RelayBasedFilter>? {
): List<RelayBasedFilter> {
val userPerRelay =
mapOfSet {
keys.mapTo(mutableSetOf()) { key -> key.user }.forEach { user ->
@@ -26,7 +26,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
@Stable
class BlockedRelayListViewModel : BasicRelaySetupInfoModel() {
override fun getRelayList(): List<NormalizedRelayUrl>? =
override fun getRelayList(): List<NormalizedRelayUrl> =
account.blockedRelayList.flow.value
.toList()
@@ -26,7 +26,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
@Stable
class BroadcastRelayListViewModel : BasicRelaySetupInfoModel() {
override fun getRelayList(): List<NormalizedRelayUrl>? =
override fun getRelayList(): List<NormalizedRelayUrl> =
account.broadcastRelayList.flow.value
.toList()
@@ -26,7 +26,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
@Stable
class FavoriteRelayListViewModel : BasicRelaySetupInfoModel() {
override fun getRelayList(): List<NormalizedRelayUrl>? =
override fun getRelayList(): List<NormalizedRelayUrl> =
account.favoriteRelayList.flow.value
.toList()
@@ -26,7 +26,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
@Stable
class IndexerRelayListViewModel : BasicRelaySetupInfoModel() {
override fun getRelayList(): List<NormalizedRelayUrl>? =
override fun getRelayList(): List<NormalizedRelayUrl> =
account.indexerRelayList.flowNoDefaults.value
.toList()
@@ -26,7 +26,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
@Stable
class PrivateOutboxRelayListViewModel : BasicRelaySetupInfoModel() {
override fun getRelayList(): List<NormalizedRelayUrl>? =
override fun getRelayList(): List<NormalizedRelayUrl> =
account.privateStorageRelayList.flow.value
.toList()
@@ -26,7 +26,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
@Stable
class ProxyRelayListViewModel : BasicRelaySetupInfoModel() {
override fun getRelayList(): List<NormalizedRelayUrl>? =
override fun getRelayList(): List<NormalizedRelayUrl> =
account.proxyRelayList.flow.value
.toList()
@@ -26,7 +26,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
@Stable
class SearchRelayListViewModel : BasicRelaySetupInfoModel() {
override fun getRelayList(): List<NormalizedRelayUrl>? =
override fun getRelayList(): List<NormalizedRelayUrl> =
account.searchRelayList.flowNoDefaults.value
.toList()
@@ -26,7 +26,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
@Stable
class TrustedRelayListViewModel : BasicRelaySetupInfoModel() {
override fun getRelayList(): List<NormalizedRelayUrl>? =
override fun getRelayList(): List<NormalizedRelayUrl> =
account.trustedRelayList.flow.value
.toList()
@@ -55,7 +55,7 @@ class PushNotificationReceiverService : FirebaseMessagingService() {
}
}
private suspend fun parseMessage(params: Map<String, String>): GiftWrapEvent? {
private fun parseMessage(params: Map<String, String>): GiftWrapEvent? {
params["encryptedEvent"]?.let { eventStr ->
(Event.fromJson(eventStr) as? GiftWrapEvent)?.let {
return it