From f8f2eead36bcafc01aaf4a38859429b28ac692df Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Mon, 19 Sep 2022 22:09:25 +0100 Subject: [PATCH] ignoring tab taps when already on the tab page --- .../kotlin/app/dapk/st/home/HomeViewModel.kt | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/features/home/src/main/kotlin/app/dapk/st/home/HomeViewModel.kt b/features/home/src/main/kotlin/app/dapk/st/home/HomeViewModel.kt index 56617f7..728c6c0 100644 --- a/features/home/src/main/kotlin/app/dapk/st/home/HomeViewModel.kt +++ b/features/home/src/main/kotlin/app/dapk/st/home/HomeViewModel.kt @@ -100,19 +100,27 @@ class HomeViewModel( Loading -> current is SignedIn -> { when (page) { - Page.Directory -> { - // do nothing + current.page -> current + else -> current.copy(page = page).also { + pageChangeSideEffects(page) } - - Page.Profile -> profileViewModel.reset() } - current.copy(page = page) } SignedOut -> current } } + private fun pageChangeSideEffects(page: Page) { + when (page) { + Page.Directory -> { + // do nothing + } + + Page.Profile -> profileViewModel.reset() + } + } + fun stop() { viewModelScope.cancel() }