fix(dm): MainActivity chat path 라우팅을 보정한다
This commit is contained in:
@@ -56,6 +56,7 @@ import kr.co.vividnext.sodalive.settings.event.EventDetailActivity
|
||||
import kr.co.vividnext.sodalive.settings.notification.NotificationSettingsDialog
|
||||
import kr.co.vividnext.sodalive.user.login.LoginActivity
|
||||
import kr.co.vividnext.sodalive.v2.creator.channel.CreatorChannelActivity
|
||||
import kr.co.vividnext.sodalive.v2.main.chat.dm.DmChatRoomActivity
|
||||
import org.koin.android.ext.android.inject
|
||||
import java.util.Locale
|
||||
import kotlinx.coroutines.Job
|
||||
@@ -316,8 +317,10 @@ class MainActivity : BaseActivity<ActivityMainBinding>(ActivityMainBinding::infl
|
||||
private fun executeBundleDeeplink(bundle: Bundle): Boolean {
|
||||
val deepLinkUrl = bundle.getString("deep_link")
|
||||
if (!deepLinkUrl.isNullOrBlank()) {
|
||||
val deepLinkBundle = buildBundleFromDeepLinkUrl(deepLinkUrl)
|
||||
return executeBundleRoute(deepLinkBundle ?: bundle)
|
||||
val deepLinkBundle = Bundle(bundle).apply {
|
||||
buildBundleFromDeepLinkUrl(deepLinkUrl)?.let { putAll(it) }
|
||||
}
|
||||
return executeBundleRoute(deepLinkBundle)
|
||||
}
|
||||
|
||||
return executeBundleRoute(bundle)
|
||||
@@ -339,6 +342,11 @@ class MainActivity : BaseActivity<ActivityMainBinding>(ActivityMainBinding::infl
|
||||
val communityPostId = bundle.getString(Constants.EXTRA_COMMUNITY_POST_ID)?.toLongOrNull()
|
||||
?: bundle.getLong(Constants.EXTRA_COMMUNITY_POST_ID).takeIf { it > 0 }
|
||||
when {
|
||||
isDmChatDeepLink(bundle) && roomId != null && roomId > 0 -> {
|
||||
startActivity(DmChatRoomActivity.newIntentByRoomId(applicationContext, roomId))
|
||||
return true
|
||||
}
|
||||
|
||||
roomId != null && roomId > 0 -> {
|
||||
viewModel.clickTab(MainViewModel.CurrentTab.LIVE)
|
||||
|
||||
@@ -493,6 +501,12 @@ class MainActivity : BaseActivity<ActivityMainBinding>(ActivityMainBinding::infl
|
||||
putIfAbsent("deep_link_sub5", pathId)
|
||||
}
|
||||
|
||||
"chat" -> {
|
||||
putIfAbsent("room_id", pathId)
|
||||
putIfAbsent("deep_link_value", "chat")
|
||||
putIfAbsent("deep_link_sub5", pathId)
|
||||
}
|
||||
|
||||
"content" -> {
|
||||
putIfAbsent("content_id", pathId)
|
||||
putIfAbsent("deep_link_value", "content")
|
||||
@@ -620,6 +634,10 @@ class MainActivity : BaseActivity<ActivityMainBinding>(ActivityMainBinding::infl
|
||||
}
|
||||
}
|
||||
|
||||
private fun isDmChatDeepLink(bundle: Bundle): Boolean {
|
||||
return bundle.getString("deep_link_value") == "chat"
|
||||
}
|
||||
|
||||
private fun clearDeferredDeepLink() {
|
||||
SharedPreferenceManager.marketingUtmSource = ""
|
||||
SharedPreferenceManager.marketingUtmMedium = ""
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package kr.co.vividnext.sodalive.main
|
||||
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
|
||||
class MainActivitySourceTest {
|
||||
|
||||
@Test
|
||||
fun `MainActivity는 deep_link를 원본 bundle에 merge하고 chat_type을 사용하지 않는다`() {
|
||||
val source = projectFile("app/src/main/java/kr/co/vividnext/sodalive/main/MainActivity.kt").readText()
|
||||
|
||||
assertTrue(source.contains("Bundle(bundle).apply"))
|
||||
assertTrue(source.contains("buildBundleFromDeepLinkUrl(deepLinkUrl)?.let { putAll(it) }"))
|
||||
assertFalse(source.contains("chat_type"))
|
||||
assertFalse(source.contains("isUserCreatorChat"))
|
||||
assertTrue(source.contains("return bundle.getString(\"deep_link_value\") == \"chat\""))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `MainActivity는 chat path deep_link 단독 payload를 DM 채팅방으로 라우팅한다`() {
|
||||
val source = projectFile("app/src/main/java/kr/co/vividnext/sodalive/main/MainActivity.kt").readText()
|
||||
|
||||
val chatPathIndex = source.indexOf("\"chat\" ->")
|
||||
val dmRouteIndex = source.indexOf("isDmChatDeepLink(bundle) && roomId != null && roomId > 0")
|
||||
val liveRouteIndex = source.indexOf("roomId != null && roomId > 0 ->")
|
||||
|
||||
assertTrue(source.contains("import kr.co.vividnext.sodalive.v2.main.chat.dm.DmChatRoomActivity"))
|
||||
assertTrue(chatPathIndex >= 0)
|
||||
assertTrue(source.contains("putIfAbsent(\"room_id\", pathId)"))
|
||||
assertTrue(source.contains("putIfAbsent(\"deep_link_value\", \"chat\")"))
|
||||
assertTrue(source.contains("private fun isDmChatDeepLink(bundle: Bundle): Boolean"))
|
||||
assertTrue(source.contains("DmChatRoomActivity.newIntentByRoomId(applicationContext, roomId)"))
|
||||
assertTrue(dmRouteIndex >= 0)
|
||||
assertTrue(liveRouteIndex >= 0)
|
||||
assertTrue(dmRouteIndex < liveRouteIndex)
|
||||
}
|
||||
|
||||
private fun projectFile(relativePath: String): File {
|
||||
val candidates = listOf(File(relativePath), File("../$relativePath"))
|
||||
return candidates.firstOrNull { it.exists() }
|
||||
?: error("Project file not found: $relativePath")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user