Fixes unchecked cast and other opt-in tags on observers
This commit is contained in:
+3
@@ -28,6 +28,7 @@ import com.vitorpamplona.amethyst.model.Channel
|
|||||||
import com.vitorpamplona.amethyst.model.ChannelState
|
import com.vitorpamplona.amethyst.model.ChannelState
|
||||||
import com.vitorpamplona.amethyst.model.LiveActivitiesChannel
|
import com.vitorpamplona.amethyst.model.LiveActivitiesChannel
|
||||||
import com.vitorpamplona.quartz.nip53LiveActivities.streaming.LiveActivitiesEvent
|
import com.vitorpamplona.quartz.nip53LiveActivities.streaming.LiveActivitiesEvent
|
||||||
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||||
import kotlinx.coroutines.flow.mapLatest
|
import kotlinx.coroutines.flow.mapLatest
|
||||||
|
|
||||||
@@ -38,6 +39,7 @@ fun observeChannel(baseChannel: Channel): State<ChannelState?> {
|
|||||||
return baseChannel.flow.stateFlow.collectAsStateWithLifecycle()
|
return baseChannel.flow.stateFlow.collectAsStateWithLifecycle()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun observeChannelPicture(baseChannel: Channel): State<String?> {
|
fun observeChannelPicture(baseChannel: Channel): State<String?> {
|
||||||
// Subscribe in the relay for changes in the metadata of this user.
|
// Subscribe in the relay for changes in the metadata of this user.
|
||||||
@@ -55,6 +57,7 @@ fun observeChannelPicture(baseChannel: Channel): State<String?> {
|
|||||||
return flow.collectAsStateWithLifecycle(baseChannel.profilePicture())
|
return flow.collectAsStateWithLifecycle(baseChannel.profilePicture())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun observeChannelInfo(baseChannel: LiveActivitiesChannel): State<LiveActivitiesEvent?> {
|
fun observeChannelInfo(baseChannel: LiveActivitiesChannel): State<LiveActivitiesEvent?> {
|
||||||
// Subscribe in the relay for changes in the metadata of this user.
|
// Subscribe in the relay for changes in the metadata of this user.
|
||||||
|
|||||||
+12
@@ -29,6 +29,8 @@ import com.vitorpamplona.amethyst.model.NoteState
|
|||||||
import com.vitorpamplona.amethyst.model.User
|
import com.vitorpamplona.amethyst.model.User
|
||||||
import com.vitorpamplona.quartz.nip01Core.core.Event
|
import com.vitorpamplona.quartz.nip01Core.core.Event
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
|
import kotlinx.coroutines.FlowPreview
|
||||||
import kotlinx.coroutines.flow.combine
|
import kotlinx.coroutines.flow.combine
|
||||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||||
import kotlinx.coroutines.flow.flowOn
|
import kotlinx.coroutines.flow.flowOn
|
||||||
@@ -47,6 +49,8 @@ fun observeNote(note: Note): State<NoteState> {
|
|||||||
.collectAsStateWithLifecycle()
|
.collectAsStateWithLifecycle()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun <T : Event> observeNoteEvent(note: Note): State<T?> {
|
fun <T : Event> observeNoteEvent(note: Note): State<T?> {
|
||||||
// Subscribe in the relay for changes in this note.
|
// Subscribe in the relay for changes in this note.
|
||||||
@@ -64,6 +68,7 @@ fun <T : Event> observeNoteEvent(note: Note): State<T?> {
|
|||||||
return flow.collectAsStateWithLifecycle(note.event as? T?)
|
return flow.collectAsStateWithLifecycle(note.event as? T?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun <T> observeNoteAndMap(
|
fun <T> observeNoteAndMap(
|
||||||
note: Note,
|
note: Note,
|
||||||
@@ -86,6 +91,8 @@ fun <T> observeNoteAndMap(
|
|||||||
return flow.collectAsStateWithLifecycle(map(note))
|
return flow.collectAsStateWithLifecycle(map(note))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun <T, U> observeNoteEventAndMap(
|
fun <T, U> observeNoteEventAndMap(
|
||||||
note: Note,
|
note: Note,
|
||||||
@@ -109,6 +116,7 @@ fun <T, U> observeNoteEventAndMap(
|
|||||||
return flow.collectAsStateWithLifecycle((note.event as? T)?.let { map(it) })
|
return flow.collectAsStateWithLifecycle((note.event as? T)?.let { map(it) })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun observeNoteHasEvent(note: Note): State<Boolean> {
|
fun observeNoteHasEvent(note: Note): State<Boolean> {
|
||||||
// Subscribe in the relay for changes in this note.
|
// Subscribe in the relay for changes in this note.
|
||||||
@@ -139,6 +147,7 @@ fun observeNoteReplies(note: Note): State<NoteState?> {
|
|||||||
.collectAsStateWithLifecycle()
|
.collectAsStateWithLifecycle()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun observeNoteReplyCount(note: Note): State<Int> {
|
fun observeNoteReplyCount(note: Note): State<Int> {
|
||||||
// Subscribe in the relay for changes in this note.
|
// Subscribe in the relay for changes in this note.
|
||||||
@@ -170,6 +179,7 @@ fun observeNoteReactions(note: Note): State<NoteState?> {
|
|||||||
.collectAsStateWithLifecycle()
|
.collectAsStateWithLifecycle()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun observeNoteReactionCount(note: Note): State<Int> {
|
fun observeNoteReactionCount(note: Note): State<Int> {
|
||||||
// Subscribe in the relay for changes in this note.
|
// Subscribe in the relay for changes in this note.
|
||||||
@@ -215,6 +225,7 @@ fun observeNoteReposts(note: Note): State<NoteState?> {
|
|||||||
.collectAsStateWithLifecycle()
|
.collectAsStateWithLifecycle()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun observeNoteRepostsBy(
|
fun observeNoteRepostsBy(
|
||||||
note: Note,
|
note: Note,
|
||||||
@@ -237,6 +248,7 @@ fun observeNoteRepostsBy(
|
|||||||
return flow.collectAsStateWithLifecycle(note.isBoostedBy(user))
|
return flow.collectAsStateWithLifecycle(note.isBoostedBy(user))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun observeNoteRepostCount(note: Note): State<Int> {
|
fun observeNoteRepostCount(note: Note): State<Int> {
|
||||||
// Subscribe in the relay for changes in this note.
|
// Subscribe in the relay for changes in this note.
|
||||||
|
|||||||
+23
@@ -36,6 +36,8 @@ import com.vitorpamplona.quartz.nip65RelayList.RelayUrlFormatter
|
|||||||
import kotlinx.collections.immutable.ImmutableList
|
import kotlinx.collections.immutable.ImmutableList
|
||||||
import kotlinx.collections.immutable.persistentListOf
|
import kotlinx.collections.immutable.persistentListOf
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
|
import kotlinx.coroutines.FlowPreview
|
||||||
import kotlinx.coroutines.flow.combine
|
import kotlinx.coroutines.flow.combine
|
||||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||||
import kotlinx.coroutines.flow.flowOn
|
import kotlinx.coroutines.flow.flowOn
|
||||||
@@ -55,6 +57,7 @@ fun observeUser(user: User): State<UserState?> {
|
|||||||
.collectAsStateWithLifecycle()
|
.collectAsStateWithLifecycle()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun observeUserName(user: User): State<String> {
|
fun observeUserName(user: User): State<String> {
|
||||||
// Subscribe in the relay for changes in the metadata of this user.
|
// Subscribe in the relay for changes in the metadata of this user.
|
||||||
@@ -73,6 +76,7 @@ fun observeUserName(user: User): State<String> {
|
|||||||
return flow.collectAsStateWithLifecycle(user.toBestDisplayName())
|
return flow.collectAsStateWithLifecycle(user.toBestDisplayName())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun observeUserNip05(user: User): State<String?> {
|
fun observeUserNip05(user: User): State<String?> {
|
||||||
// Subscribe in the relay for changes in the metadata of this user.
|
// Subscribe in the relay for changes in the metadata of this user.
|
||||||
@@ -91,6 +95,7 @@ fun observeUserNip05(user: User): State<String?> {
|
|||||||
return flow.collectAsStateWithLifecycle(user.info?.nip05)
|
return flow.collectAsStateWithLifecycle(user.info?.nip05)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun observeUserAboutMe(user: User): State<String> {
|
fun observeUserAboutMe(user: User): State<String> {
|
||||||
// Subscribe in the relay for changes in the metadata of this user.
|
// Subscribe in the relay for changes in the metadata of this user.
|
||||||
@@ -109,6 +114,7 @@ fun observeUserAboutMe(user: User): State<String> {
|
|||||||
return flow.collectAsStateWithLifecycle(user.info?.about ?: "")
|
return flow.collectAsStateWithLifecycle(user.info?.about ?: "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun observeUserInfo(user: User): State<UserMetadata?> {
|
fun observeUserInfo(user: User): State<UserMetadata?> {
|
||||||
// Subscribe in the relay for changes in the metadata of this user.
|
// Subscribe in the relay for changes in the metadata of this user.
|
||||||
@@ -127,6 +133,7 @@ fun observeUserInfo(user: User): State<UserMetadata?> {
|
|||||||
return flow.collectAsStateWithLifecycle(user.info)
|
return flow.collectAsStateWithLifecycle(user.info)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun observeUserBanner(user: User): State<String?> {
|
fun observeUserBanner(user: User): State<String?> {
|
||||||
// Subscribe in the relay for changes in the metadata of this user.
|
// Subscribe in the relay for changes in the metadata of this user.
|
||||||
@@ -145,6 +152,7 @@ fun observeUserBanner(user: User): State<String?> {
|
|||||||
return flow.collectAsStateWithLifecycle(user.info?.banner)
|
return flow.collectAsStateWithLifecycle(user.info?.banner)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun observeUserPicture(user: User): State<String?> {
|
fun observeUserPicture(user: User): State<String?> {
|
||||||
// Subscribe in the relay for changes in the metadata of this user.
|
// Subscribe in the relay for changes in the metadata of this user.
|
||||||
@@ -163,6 +171,7 @@ fun observeUserPicture(user: User): State<String?> {
|
|||||||
return flow.collectAsStateWithLifecycle(user.info?.picture)
|
return flow.collectAsStateWithLifecycle(user.info?.picture)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun observeUserShortName(user: User): State<String> {
|
fun observeUserShortName(user: User): State<String> {
|
||||||
// Subscribe in the relay for changes in the metadata of this user.
|
// Subscribe in the relay for changes in the metadata of this user.
|
||||||
@@ -193,6 +202,7 @@ fun observeUserFollows(user: User): State<UserState?> {
|
|||||||
.collectAsStateWithLifecycle()
|
.collectAsStateWithLifecycle()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun observeUserFollowCount(user: User): State<Int> {
|
fun observeUserFollowCount(user: User): State<Int> {
|
||||||
// Subscribe in the relay for changes in the metadata of this user.
|
// Subscribe in the relay for changes in the metadata of this user.
|
||||||
@@ -214,6 +224,7 @@ fun observeUserFollowCount(user: User): State<Int> {
|
|||||||
return flow.collectAsStateWithLifecycle(0)
|
return flow.collectAsStateWithLifecycle(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun observeUserTagFollows(user: User): State<Int> {
|
fun observeUserTagFollows(user: User): State<Int> {
|
||||||
// Subscribe in the relay for changes in the metadata of this user.
|
// Subscribe in the relay for changes in the metadata of this user.
|
||||||
@@ -247,6 +258,7 @@ fun observeUserBookmarks(user: User): State<UserState?> {
|
|||||||
.collectAsStateWithLifecycle()
|
.collectAsStateWithLifecycle()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun observeUserBookmarkCount(user: User): State<Int> {
|
fun observeUserBookmarkCount(user: User): State<Int> {
|
||||||
// Subscribe in the relay for changes in the metadata of this user.
|
// Subscribe in the relay for changes in the metadata of this user.
|
||||||
@@ -280,6 +292,7 @@ fun observeUserFollowers(user: User): State<UserState?> {
|
|||||||
.collectAsStateWithLifecycle()
|
.collectAsStateWithLifecycle()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun observeUserFollowerCount(user: User): State<Int> {
|
fun observeUserFollowerCount(user: User): State<Int> {
|
||||||
// Subscribe in the relay for changes in the metadata of this user.
|
// Subscribe in the relay for changes in the metadata of this user.
|
||||||
@@ -301,6 +314,7 @@ fun observeUserFollowerCount(user: User): State<Int> {
|
|||||||
return flow.collectAsStateWithLifecycle(0)
|
return flow.collectAsStateWithLifecycle(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun observeUserIsFollowing(
|
fun observeUserIsFollowing(
|
||||||
user1: User,
|
user1: User,
|
||||||
@@ -325,6 +339,7 @@ fun observeUserIsFollowing(
|
|||||||
return flow.collectAsStateWithLifecycle(user1.isFollowing(user2))
|
return flow.collectAsStateWithLifecycle(user1.isFollowing(user2))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun observeUserIsFollowingHashtag(
|
fun observeUserIsFollowingHashtag(
|
||||||
user: User,
|
user: User,
|
||||||
@@ -349,6 +364,7 @@ fun observeUserIsFollowingHashtag(
|
|||||||
return flow.collectAsStateWithLifecycle(user.isFollowingHashtag(hashtag))
|
return flow.collectAsStateWithLifecycle(user.isFollowingHashtag(hashtag))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun observeUserIsFollowingGeohash(
|
fun observeUserIsFollowingGeohash(
|
||||||
user: User,
|
user: User,
|
||||||
@@ -373,6 +389,7 @@ fun observeUserIsFollowingGeohash(
|
|||||||
return flow.collectAsStateWithLifecycle(user.isFollowingGeohash(geohash))
|
return flow.collectAsStateWithLifecycle(user.isFollowingGeohash(geohash))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun observeUserIsFollowingChannel(
|
fun observeUserIsFollowingChannel(
|
||||||
user: User,
|
user: User,
|
||||||
@@ -409,6 +426,7 @@ fun observeUserZaps(user: User): State<UserState?> {
|
|||||||
.collectAsStateWithLifecycle()
|
.collectAsStateWithLifecycle()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun observeUserZapAmount(user: User): State<BigDecimal> {
|
fun observeUserZapAmount(user: User): State<BigDecimal> {
|
||||||
// Subscribe in the relay for changes in the metadata of this user.
|
// Subscribe in the relay for changes in the metadata of this user.
|
||||||
@@ -442,6 +460,7 @@ fun observeUserReports(user: User): State<UserState?> {
|
|||||||
.collectAsStateWithLifecycle()
|
.collectAsStateWithLifecycle()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun observeUserReportCount(user: User): State<Int> {
|
fun observeUserReportCount(user: User): State<Int> {
|
||||||
// Subscribe in the relay for changes in the metadata of this user.
|
// Subscribe in the relay for changes in the metadata of this user.
|
||||||
@@ -464,6 +483,7 @@ fun observeUserReportCount(user: User): State<Int> {
|
|||||||
return flow.collectAsStateWithLifecycle(0)
|
return flow.collectAsStateWithLifecycle(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun observeUserStatuses(user: User): State<ImmutableList<AddressableNote>> {
|
fun observeUserStatuses(user: User): State<ImmutableList<AddressableNote>> {
|
||||||
// Subscribe in the relay for changes in the metadata of this user.
|
// Subscribe in the relay for changes in the metadata of this user.
|
||||||
@@ -486,6 +506,7 @@ fun observeUserStatuses(user: User): State<ImmutableList<AddressableNote>> {
|
|||||||
return flow.collectAsStateWithLifecycle(persistentListOf())
|
return flow.collectAsStateWithLifecycle(persistentListOf())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun observeUserRelayIntoList(
|
fun observeUserRelayIntoList(
|
||||||
user: User,
|
user: User,
|
||||||
@@ -513,6 +534,7 @@ fun observeUserRelayIntoList(
|
|||||||
return flow.collectAsStateWithLifecycle(false)
|
return flow.collectAsStateWithLifecycle(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun observeUserRoomSubject(
|
fun observeUserRoomSubject(
|
||||||
user: User,
|
user: User,
|
||||||
@@ -543,6 +565,7 @@ data class RelayUsage(
|
|||||||
val userRelayList: List<String> = emptyList(),
|
val userRelayList: List<String> = emptyList(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun observeUserRelaysUsing(user: User): State<RelayUsage> {
|
fun observeUserRelaysUsing(user: User): State<RelayUsage> {
|
||||||
// Subscribe in the relay for changes in the metadata of this user.
|
// Subscribe in the relay for changes in the metadata of this user.
|
||||||
|
|||||||
Reference in New Issue
Block a user