Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix : [딥 링크] 이후 뒤로 가기시 홈이 아닌 티켓 탭이 나오는 현상 수정 #252

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.nexters.boolti.presentation.screen.home

import android.content.Context
import android.content.Intent
import android.net.Uri
import androidx.annotation.DrawableRes
Expand All @@ -20,6 +21,7 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.Stable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
Expand All @@ -32,6 +34,7 @@ import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import androidx.navigation.navDeepLink
import com.nexters.boolti.presentation.R
import com.nexters.boolti.presentation.extension.requireActivity
import com.nexters.boolti.presentation.screen.HomeViewModel
import com.nexters.boolti.presentation.screen.my.MyScreen
import com.nexters.boolti.presentation.screen.show.ShowScreen
Expand All @@ -40,7 +43,6 @@ import com.nexters.boolti.presentation.screen.ticket.TicketScreen
import com.nexters.boolti.presentation.theme.Grey10
import com.nexters.boolti.presentation.theme.Grey50
import com.nexters.boolti.presentation.theme.Grey85
import kotlinx.coroutines.channels.consumeEach

@Composable
fun HomeScreen(
Expand All @@ -61,6 +63,8 @@ fun HomeScreen(

val loggedIn by viewModel.loggedIn.collectAsStateWithLifecycle()

removeInvalidDeepLink(LocalContext.current)

LaunchedEffect(Unit) {
viewModel.event.collect { deepLink ->
navController.navigate(Uri.parse(deepLink))
Expand Down Expand Up @@ -135,6 +139,19 @@ fun HomeScreen(
}
}

/**
* issue #209를 해결하기 위한 메서드.
* 처리하지 말아야 할 deep link가 부적절한 destination과 match되는 것을 방지하기 위함.
*/
private fun removeInvalidDeepLink(context: Context) {
runCatching {
val intent = context.requireActivity().intent
if (intent.action == null) return
val deepLink = intent.action!!
if (!deepLink.contains("home")) intent.setAction(null)
}
}

@Stable
private enum class Destination(
val route: String,
Expand Down
Loading