Makes sure it doesn't crash on starting.
This commit is contained in:
@@ -29,7 +29,9 @@ object NostrDiscoveryDataSource : NostrDataSource("DiscoveryFeed") {
|
|||||||
job?.cancel()
|
job?.cancel()
|
||||||
job = scope.launch(Dispatchers.IO) {
|
job = scope.launch(Dispatchers.IO) {
|
||||||
account.liveDiscoveryFollowLists.collect {
|
account.liveDiscoveryFollowLists.collect {
|
||||||
invalidateFilters()
|
if (this@NostrDiscoveryDataSource::account.isInitialized) {
|
||||||
|
invalidateFilters()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.start()
|
super.start()
|
||||||
|
|||||||
@@ -35,7 +35,9 @@ object NostrHomeDataSource : NostrDataSource("HomeFeed") {
|
|||||||
job?.cancel()
|
job?.cancel()
|
||||||
job = account.scope.launch(Dispatchers.IO) {
|
job = account.scope.launch(Dispatchers.IO) {
|
||||||
account.liveHomeFollowLists.collect {
|
account.liveHomeFollowLists.collect {
|
||||||
invalidateFilters()
|
if (this@NostrHomeDataSource::account.isInitialized) {
|
||||||
|
invalidateFilters()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.start()
|
super.start()
|
||||||
|
|||||||
@@ -24,7 +24,9 @@ object NostrVideoDataSource : NostrDataSource("VideoFeed") {
|
|||||||
job?.cancel()
|
job?.cancel()
|
||||||
job = scope.launch(Dispatchers.IO) {
|
job = scope.launch(Dispatchers.IO) {
|
||||||
account.liveStoriesFollowLists.collect {
|
account.liveStoriesFollowLists.collect {
|
||||||
invalidateFilters()
|
if (this@NostrVideoDataSource::account.isInitialized) {
|
||||||
|
invalidateFilters()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.start()
|
super.start()
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ fun HomeScreen(
|
|||||||
|
|
||||||
WatchAccountForHomeScreen(homeFeedViewModel, repliesFeedViewModel, accountViewModel)
|
WatchAccountForHomeScreen(homeFeedViewModel, repliesFeedViewModel, accountViewModel)
|
||||||
|
|
||||||
WatchLifeCycleChanges()
|
WatchLifeCycleChanges(accountViewModel)
|
||||||
|
|
||||||
AssembleHomeTabs(homeFeedViewModel, repliesFeedViewModel) { pagerState, tabItems ->
|
AssembleHomeTabs(homeFeedViewModel, repliesFeedViewModel) { pagerState, tabItems ->
|
||||||
AssembleHomePage(pagerState, tabItems, accountViewModel, nav)
|
AssembleHomePage(pagerState, tabItems, accountViewModel, nav)
|
||||||
@@ -109,11 +109,12 @@ fun ResolveNIP47(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun WatchLifeCycleChanges() {
|
private fun WatchLifeCycleChanges(accountViewModel: AccountViewModel) {
|
||||||
val lifeCycleOwner = LocalLifecycleOwner.current
|
val lifeCycleOwner = LocalLifecycleOwner.current
|
||||||
DisposableEffect(lifeCycleOwner) {
|
DisposableEffect(lifeCycleOwner) {
|
||||||
val observer = LifecycleEventObserver { _, event ->
|
val observer = LifecycleEventObserver { _, event ->
|
||||||
if (event == Lifecycle.Event.ON_RESUME) {
|
if (event == Lifecycle.Event.ON_RESUME) {
|
||||||
|
NostrHomeDataSource.account = accountViewModel.account
|
||||||
NostrHomeDataSource.invalidateFilters()
|
NostrHomeDataSource.invalidateFilters()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -219,6 +220,7 @@ fun WatchAccountForHomeScreen(
|
|||||||
val homeFollowList by accountViewModel.account.liveHomeFollowLists.collectAsStateWithLifecycle()
|
val homeFollowList by accountViewModel.account.liveHomeFollowLists.collectAsStateWithLifecycle()
|
||||||
|
|
||||||
LaunchedEffect(accountViewModel, homeFollowList) {
|
LaunchedEffect(accountViewModel, homeFollowList) {
|
||||||
|
NostrHomeDataSource.account = accountViewModel.account
|
||||||
NostrHomeDataSource.invalidateFilters()
|
NostrHomeDataSource.invalidateFilters()
|
||||||
homeFeedViewModel.checkKeysInvalidateDataAndSendToTop()
|
homeFeedViewModel.checkKeysInvalidateDataAndSendToTop()
|
||||||
repliesFeedViewModel.checkKeysInvalidateDataAndSendToTop()
|
repliesFeedViewModel.checkKeysInvalidateDataAndSendToTop()
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ fun NotificationScreen(
|
|||||||
DisposableEffect(lifeCycleOwner) {
|
DisposableEffect(lifeCycleOwner) {
|
||||||
val observer = LifecycleEventObserver { _, event ->
|
val observer = LifecycleEventObserver { _, event ->
|
||||||
if (event == Lifecycle.Event.ON_RESUME) {
|
if (event == Lifecycle.Event.ON_RESUME) {
|
||||||
|
NostrAccountDataSource.account = accountViewModel.account
|
||||||
NostrAccountDataSource.invalidateFilters()
|
NostrAccountDataSource.invalidateFilters()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -144,6 +145,7 @@ fun WatchAccountForNotifications(
|
|||||||
val listState by accountViewModel.account.liveStoriesFollowLists.collectAsStateWithLifecycle()
|
val listState by accountViewModel.account.liveStoriesFollowLists.collectAsStateWithLifecycle()
|
||||||
|
|
||||||
LaunchedEffect(accountViewModel, listState) {
|
LaunchedEffect(accountViewModel, listState) {
|
||||||
|
NostrAccountDataSource.account = accountViewModel.account
|
||||||
NostrAccountDataSource.invalidateFilters()
|
NostrAccountDataSource.invalidateFilters()
|
||||||
notifFeedViewModel.checkKeysInvalidateDataAndSendToTop()
|
notifFeedViewModel.checkKeysInvalidateDataAndSendToTop()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user