Bugfix for home feed scrolling to the top when a new follower updates the cache.
This commit is contained in:
@@ -96,10 +96,10 @@ class User(val pubkeyHex: String) {
|
|||||||
// Update Followers of the past user list
|
// Update Followers of the past user list
|
||||||
// Update Followers of the new contact list
|
// Update Followers of the new contact list
|
||||||
(oldContactListEvent)?.unverifiedFollowKeySet()?.forEach {
|
(oldContactListEvent)?.unverifiedFollowKeySet()?.forEach {
|
||||||
LocalCache.users[it]?.liveSet?.follows?.invalidateData()
|
LocalCache.users[it]?.liveSet?.followers?.invalidateData()
|
||||||
}
|
}
|
||||||
(latestContactList)?.unverifiedFollowKeySet()?.forEach {
|
(latestContactList)?.unverifiedFollowKeySet()?.forEach {
|
||||||
LocalCache.users[it]?.liveSet?.follows?.invalidateData()
|
LocalCache.users[it]?.liveSet?.followers?.invalidateData()
|
||||||
}
|
}
|
||||||
|
|
||||||
liveSet?.relays?.invalidateData()
|
liveSet?.relays?.invalidateData()
|
||||||
@@ -340,6 +340,7 @@ class User(val pubkeyHex: String) {
|
|||||||
class UserLiveSet(u: User) {
|
class UserLiveSet(u: User) {
|
||||||
// UI Observers line up here.
|
// UI Observers line up here.
|
||||||
val follows: UserLiveData = UserLiveData(u)
|
val follows: UserLiveData = UserLiveData(u)
|
||||||
|
val followers: UserLiveData = UserLiveData(u)
|
||||||
val reports: UserLiveData = UserLiveData(u)
|
val reports: UserLiveData = UserLiveData(u)
|
||||||
val messages: UserLiveData = UserLiveData(u)
|
val messages: UserLiveData = UserLiveData(u)
|
||||||
val relays: UserLiveData = UserLiveData(u)
|
val relays: UserLiveData = UserLiveData(u)
|
||||||
@@ -351,6 +352,7 @@ class UserLiveSet(u: User) {
|
|||||||
|
|
||||||
fun isInUse(): Boolean {
|
fun isInUse(): Boolean {
|
||||||
return follows.hasObservers() ||
|
return follows.hasObservers() ||
|
||||||
|
followers.hasObservers() ||
|
||||||
reports.hasObservers() ||
|
reports.hasObservers() ||
|
||||||
messages.hasObservers() ||
|
messages.hasObservers() ||
|
||||||
relays.hasObservers() ||
|
relays.hasObservers() ||
|
||||||
|
|||||||
@@ -230,14 +230,15 @@ fun ProfileContent(
|
|||||||
@Composable
|
@Composable
|
||||||
private fun FollowingAndFollowerCounts(baseAccountUser: User) {
|
private fun FollowingAndFollowerCounts(baseAccountUser: User) {
|
||||||
val accountUserFollowsState by baseAccountUser.live().follows.observeAsState()
|
val accountUserFollowsState by baseAccountUser.live().follows.observeAsState()
|
||||||
|
val accountUserFollowersState by baseAccountUser.live().followers.observeAsState()
|
||||||
|
|
||||||
var followingCount by remember { mutableStateOf("--") }
|
var followingCount by remember { mutableStateOf("--") }
|
||||||
var followerCount by remember { mutableStateOf("--") }
|
var followerCount by remember { mutableStateOf("--") }
|
||||||
|
|
||||||
LaunchedEffect(key1 = accountUserFollowsState) {
|
LaunchedEffect(key1 = accountUserFollowsState, key2 = accountUserFollowersState) {
|
||||||
launch(Dispatchers.IO) {
|
launch(Dispatchers.IO) {
|
||||||
val newFollowing = accountUserFollowsState?.user?.cachedFollowCount()?.toString() ?: "--"
|
val newFollowing = accountUserFollowsState?.user?.cachedFollowCount()?.toString() ?: "--"
|
||||||
val newFollower = accountUserFollowsState?.user?.cachedFollowerCount()?.toString() ?: "--"
|
val newFollower = accountUserFollowersState?.user?.cachedFollowerCount()?.toString() ?: "--"
|
||||||
|
|
||||||
if (followingCount != newFollowing) {
|
if (followingCount != newFollowing) {
|
||||||
followingCount = newFollowing
|
followingCount = newFollowing
|
||||||
|
|||||||
@@ -299,7 +299,7 @@ fun ProfileScreen(
|
|||||||
0 -> TabNotesNewThreads(accountViewModel, nav)
|
0 -> TabNotesNewThreads(accountViewModel, nav)
|
||||||
1 -> TabNotesConversations(accountViewModel, nav)
|
1 -> TabNotesConversations(accountViewModel, nav)
|
||||||
2 -> TabFollows(baseUser, followsFeedViewModel, accountViewModel, nav)
|
2 -> TabFollows(baseUser, followsFeedViewModel, accountViewModel, nav)
|
||||||
3 -> TabFollows(baseUser, followersFeedViewModel, accountViewModel, nav)
|
3 -> TabFollowers(baseUser, followersFeedViewModel, accountViewModel, nav)
|
||||||
4 -> TabReceivedZaps(baseUser, zapFeedViewModel, accountViewModel, nav)
|
4 -> TabReceivedZaps(baseUser, zapFeedViewModel, accountViewModel, nav)
|
||||||
5 -> TabBookmarks(baseUser, accountViewModel, nav)
|
5 -> TabBookmarks(baseUser, accountViewModel, nav)
|
||||||
6 -> TabReports(baseUser, accountViewModel, nav)
|
6 -> TabReports(baseUser, accountViewModel, nav)
|
||||||
@@ -382,7 +382,7 @@ private fun ZapTabHeader(baseUser: User) {
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun FollowersTabHeader(baseUser: User) {
|
private fun FollowersTabHeader(baseUser: User) {
|
||||||
val userState by baseUser.live().follows.observeAsState()
|
val userState by baseUser.live().followers.observeAsState()
|
||||||
var followerCount by remember { mutableStateOf("--") }
|
var followerCount by remember { mutableStateOf("--") }
|
||||||
|
|
||||||
LaunchedEffect(key1 = userState) {
|
LaunchedEffect(key1 = userState) {
|
||||||
@@ -531,6 +531,7 @@ private fun ProfileActions(
|
|||||||
val account = remember(accountLocalUserState) { accountLocalUserState?.account } ?: return
|
val account = remember(accountLocalUserState) { accountLocalUserState?.account } ?: return
|
||||||
|
|
||||||
val accountUserState by accountViewModel.account.userProfile().live().follows.observeAsState()
|
val accountUserState by accountViewModel.account.userProfile().live().follows.observeAsState()
|
||||||
|
val baseUserState by baseUser.live().follows.observeAsState()
|
||||||
|
|
||||||
val accountUser = remember(accountUserState) { accountUserState?.user } ?: return
|
val accountUser = remember(accountUserState) { accountUserState?.user } ?: return
|
||||||
|
|
||||||
@@ -546,7 +547,7 @@ private fun ProfileActions(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val isUserFollowingLoggedIn by remember(accountUserState, accountLocalUserState) {
|
val isUserFollowingLoggedIn by remember(baseUserState, accountLocalUserState) {
|
||||||
derivedStateOf {
|
derivedStateOf {
|
||||||
baseUser.isFollowing(accountUser)
|
baseUser.isFollowing(accountUser)
|
||||||
}
|
}
|
||||||
@@ -1117,6 +1118,19 @@ fun TabFollows(baseUser: User, feedViewModel: UserFeedViewModel, accountViewMode
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun TabFollowers(baseUser: User, feedViewModel: UserFeedViewModel, accountViewModel: AccountViewModel, nav: (String) -> Unit) {
|
||||||
|
WatchFollowerChanges(baseUser, feedViewModel)
|
||||||
|
|
||||||
|
Column(Modifier.fillMaxHeight()) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.padding(vertical = 0.dp)
|
||||||
|
) {
|
||||||
|
RefreshingFeedUserFeedView(feedViewModel, accountViewModel, nav, enablePullRefresh = false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun WatchFollowChanges(
|
private fun WatchFollowChanges(
|
||||||
baseUser: User,
|
baseUser: User,
|
||||||
@@ -1129,6 +1143,18 @@ private fun WatchFollowChanges(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun WatchFollowerChanges(
|
||||||
|
baseUser: User,
|
||||||
|
feedViewModel: UserFeedViewModel
|
||||||
|
) {
|
||||||
|
val userState by baseUser.live().followers.observeAsState()
|
||||||
|
|
||||||
|
LaunchedEffect(userState) {
|
||||||
|
feedViewModel.invalidateData()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun TabReceivedZaps(baseUser: User, zapFeedViewModel: NostrUserProfileZapsFeedViewModel, accountViewModel: AccountViewModel, nav: (String) -> Unit) {
|
fun TabReceivedZaps(baseUser: User, zapFeedViewModel: NostrUserProfileZapsFeedViewModel, accountViewModel: AccountViewModel, nav: (String) -> Unit) {
|
||||||
WatchZapsAndUpdateFeed(baseUser, zapFeedViewModel)
|
WatchZapsAndUpdateFeed(baseUser, zapFeedViewModel)
|
||||||
|
|||||||
Reference in New Issue
Block a user