Skip to content

Commit

Permalink
Fixes: PostListMainViewModel multiple starts
Browse files Browse the repository at this point in the history
  • Loading branch information
pantstamp committed Apr 12, 2024
1 parent 8089791 commit 0f4f175
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ class PostListMainViewModel @Inject constructor(
private val uploadStarter: UploadStarter,
private val postConflictResolutionFeatureUtils: PostConflictResolutionFeatureUtils
) : ViewModel(), CoroutineScope {
private var isStarted = false

private val lifecycleOwner = object : LifecycleOwner {
val lifecycleRegistry = LifecycleRegistry(this)
override val lifecycle: Lifecycle = lifecycleRegistry
Expand Down Expand Up @@ -241,6 +243,7 @@ class PostListMainViewModel @Inject constructor(
currentBottomSheetPostId: LocalId,
editPostRepository: EditPostRepository
) {
if (isStarted) return
this.site = site
this.editPostRepository = editPostRepository

Expand Down Expand Up @@ -300,6 +303,8 @@ class PostListMainViewModel @Inject constructor(
savePostToDbUseCase.savePostToDb(editPostRepository, site)
})
}

isStarted = true
}

override fun onCleared() {
Expand Down

0 comments on commit 0f4f175

Please sign in to comment.