From 518e6d155f62217cbd3fdb04c1cc7c78f3bc46c8 Mon Sep 17 00:00:00 2001 From: peng-u-0807 Date: Sat, 9 Dec 2023 20:28:31 +0900 Subject: [PATCH] fix: fix non-user dialog not showing issue --- .../java/com/goliath/emojihub/usecases/UserUseCase.kt | 11 ++++++++++- .../main/java/com/goliath/emojihub/views/FeedPage.kt | 2 -- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/android/app/src/main/java/com/goliath/emojihub/usecases/UserUseCase.kt b/android/app/src/main/java/com/goliath/emojihub/usecases/UserUseCase.kt index acc75f3e..2f5997dc 100644 --- a/android/app/src/main/java/com/goliath/emojihub/usecases/UserUseCase.kt +++ b/android/app/src/main/java/com/goliath/emojihub/usecases/UserUseCase.kt @@ -40,7 +40,16 @@ class UserUseCaseImpl @Inject constructor( override val accessTokenState: StateFlow get() = _accessTokenState - private val _userState: MutableStateFlow = MutableStateFlow(User(UserDto(EmojiHubApplication.preferences.currentUser ?: ""))) + private val isCurrentUserEmpty = EmojiHubApplication.preferences.currentUser.isNullOrEmpty() + + private val _userState: MutableStateFlow = MutableStateFlow( + if (isCurrentUserEmpty) { + null + } else { + User(UserDto(EmojiHubApplication.preferences.currentUser!!)) + } + ) + override val userState: StateFlow get() = _userState diff --git a/android/app/src/main/java/com/goliath/emojihub/views/FeedPage.kt b/android/app/src/main/java/com/goliath/emojihub/views/FeedPage.kt index a81a9b63..2340dd92 100644 --- a/android/app/src/main/java/com/goliath/emojihub/views/FeedPage.kt +++ b/android/app/src/main/java/com/goliath/emojihub/views/FeedPage.kt @@ -25,7 +25,6 @@ import androidx.paging.compose.collectAsLazyPagingItems import com.goliath.emojihub.LocalBottomSheetController import com.goliath.emojihub.LocalNavController import com.goliath.emojihub.NavigationDestination -import com.goliath.emojihub.models.createDummyEmoji import com.goliath.emojihub.navigateAsOrigin import com.goliath.emojihub.ui.theme.Color import com.goliath.emojihub.ui.theme.Color.EmojiHubDividerColor @@ -48,7 +47,6 @@ fun FeedPage() { val currentUser = userViewModel.userState.collectAsState().value - val emojiList = (1..10).map { createDummyEmoji() } val postList = postViewModel.postList.collectAsLazyPagingItems() var showNonUserDialog by remember { mutableStateOf(false) }