mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-07-17 22:52:26 +02:00
Reducing the need to start/stop home and chatroom lists to see if performance increases
This commit is contained in:
@ -33,7 +33,6 @@ object ServiceManager {
|
|||||||
NostrAccountDataSource.account = myAccount
|
NostrAccountDataSource.account = myAccount
|
||||||
NostrHomeDataSource.account = myAccount
|
NostrHomeDataSource.account = myAccount
|
||||||
NostrChatroomListDataSource.account = myAccount
|
NostrChatroomListDataSource.account = myAccount
|
||||||
NostrGlobalDataSource.account = myAccount
|
|
||||||
|
|
||||||
// Notification Elements
|
// Notification Elements
|
||||||
NostrAccountDataSource.start()
|
NostrAccountDataSource.start()
|
||||||
|
@ -123,10 +123,12 @@ abstract class NostrDataSource(val debugName: String) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
open fun start() {
|
open fun start() {
|
||||||
|
println("DataSource: ${this.javaClass.simpleName} Start")
|
||||||
resetFilters()
|
resetFilters()
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun stop() {
|
open fun stop() {
|
||||||
|
println("DataSource: ${this.javaClass.simpleName} Stop")
|
||||||
subscriptions.values.forEach { channel ->
|
subscriptions.values.forEach { channel ->
|
||||||
Client.close(channel.id)
|
Client.close(channel.id)
|
||||||
channel.typedFilters = null
|
channel.typedFilters = null
|
||||||
|
@ -8,7 +8,6 @@ import nostr.postr.JsonFilter
|
|||||||
import nostr.postr.events.TextNoteEvent
|
import nostr.postr.events.TextNoteEvent
|
||||||
|
|
||||||
object NostrGlobalDataSource: NostrDataSource("GlobalFeed") {
|
object NostrGlobalDataSource: NostrDataSource("GlobalFeed") {
|
||||||
lateinit var account: Account
|
|
||||||
fun createGlobalFilter() = TypedFilter(
|
fun createGlobalFilter() = TypedFilter(
|
||||||
types = setOf(FeedType.GLOBAL),
|
types = setOf(FeedType.GLOBAL),
|
||||||
filter = JsonFilter(
|
filter = JsonFilter(
|
||||||
|
@ -94,7 +94,8 @@ fun ObserveDisplayNip05Status(baseUser: User) {
|
|||||||
|
|
||||||
user.nip05()?.let { nip05 ->
|
user.nip05()?.let { nip05 ->
|
||||||
if (nip05.split("@").size == 2) {
|
if (nip05.split("@").size == 2) {
|
||||||
val nip05Verified by nip05VerificationAsAState(user.info!!, user.pubkeyHex)
|
|
||||||
|
val nip05Verified by nip05VerificationAsAState(user.info!!, user.pubkeyHex)
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||||
if (nip05.split("@")[0] != "_")
|
if (nip05.split("@")[0] != "_")
|
||||||
Text(
|
Text(
|
||||||
|
@ -87,31 +87,11 @@ fun TabKnown(accountViewModel: AccountViewModel, navController: NavController) {
|
|||||||
ChatroomListKnownFeedFilter.account = account
|
ChatroomListKnownFeedFilter.account = account
|
||||||
val feedViewModel: NostrChatroomListKnownFeedViewModel = viewModel()
|
val feedViewModel: NostrChatroomListKnownFeedViewModel = viewModel()
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(accountViewModel) {
|
||||||
NostrChatroomListDataSource.resetFilters()
|
NostrChatroomListDataSource.resetFilters()
|
||||||
feedViewModel.invalidateData()
|
feedViewModel.invalidateData()
|
||||||
}
|
}
|
||||||
|
|
||||||
val lifeCycleOwner = LocalLifecycleOwner.current
|
|
||||||
DisposableEffect(accountViewModel) {
|
|
||||||
val observer = LifecycleEventObserver { source, event ->
|
|
||||||
if (event == Lifecycle.Event.ON_RESUME) {
|
|
||||||
println("Chatroom List Start")
|
|
||||||
NostrChatroomListDataSource.start()
|
|
||||||
feedViewModel.invalidateData()
|
|
||||||
}
|
|
||||||
if (event == Lifecycle.Event.ON_PAUSE) {
|
|
||||||
println("Chatroom List Stop")
|
|
||||||
NostrChatroomListDataSource.stop()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lifeCycleOwner.lifecycle.addObserver(observer)
|
|
||||||
onDispose {
|
|
||||||
lifeCycleOwner.lifecycle.removeObserver(observer)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Column(Modifier.fillMaxHeight()) {
|
Column(Modifier.fillMaxHeight()) {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier.padding(vertical = 0.dp)
|
modifier = Modifier.padding(vertical = 0.dp)
|
||||||
@ -129,29 +109,9 @@ fun TabNew(accountViewModel: AccountViewModel, navController: NavController) {
|
|||||||
ChatroomListNewFeedFilter.account = account
|
ChatroomListNewFeedFilter.account = account
|
||||||
val feedViewModel: NostrChatroomListNewFeedViewModel = viewModel()
|
val feedViewModel: NostrChatroomListNewFeedViewModel = viewModel()
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(accountViewModel) {
|
||||||
NostrChatroomListDataSource.resetFilters()
|
NostrChatroomListDataSource.resetFilters()
|
||||||
feedViewModel.refresh() // refresh view
|
feedViewModel.invalidateData() // refresh view
|
||||||
}
|
|
||||||
|
|
||||||
val lifeCycleOwner = LocalLifecycleOwner.current
|
|
||||||
DisposableEffect(accountViewModel) {
|
|
||||||
val observer = LifecycleEventObserver { source, event ->
|
|
||||||
if (event == Lifecycle.Event.ON_RESUME) {
|
|
||||||
println("Chatroom List Start")
|
|
||||||
NostrChatroomListDataSource.start()
|
|
||||||
feedViewModel.invalidateData()
|
|
||||||
}
|
|
||||||
if (event == Lifecycle.Event.ON_PAUSE) {
|
|
||||||
println("Chatroom List Stop")
|
|
||||||
NostrChatroomListDataSource.stop()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lifeCycleOwner.lifecycle.addObserver(observer)
|
|
||||||
onDispose {
|
|
||||||
lifeCycleOwner.lifecycle.removeObserver(observer)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(Modifier.fillMaxHeight()) {
|
Column(Modifier.fillMaxHeight()) {
|
||||||
|
@ -56,27 +56,6 @@ fun HomeScreen(accountViewModel: AccountViewModel, navController: NavController)
|
|||||||
feedViewModelReplies.invalidateData()
|
feedViewModelReplies.invalidateData()
|
||||||
}
|
}
|
||||||
|
|
||||||
val lifeCycleOwner = LocalLifecycleOwner.current
|
|
||||||
DisposableEffect(accountViewModel) {
|
|
||||||
val observer = LifecycleEventObserver { source, event ->
|
|
||||||
if (event == Lifecycle.Event.ON_RESUME) {
|
|
||||||
println("Home Start")
|
|
||||||
NostrHomeDataSource.start()
|
|
||||||
feedViewModel.invalidateData()
|
|
||||||
feedViewModelReplies.invalidateData()
|
|
||||||
}
|
|
||||||
if (event == Lifecycle.Event.ON_PAUSE) {
|
|
||||||
println("Home Stop")
|
|
||||||
NostrHomeDataSource.stop()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lifeCycleOwner.lifecycle.addObserver(observer)
|
|
||||||
onDispose {
|
|
||||||
lifeCycleOwner.lifecycle.removeObserver(observer)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Column(Modifier.fillMaxHeight()) {
|
Column(Modifier.fillMaxHeight()) {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier.padding(vertical = 0.dp)
|
modifier = Modifier.padding(vertical = 0.dp)
|
||||||
|
Reference in New Issue
Block a user