NTP-40239 | Crm notification fixes and Additional Params in CRMWebViewActivity (#15308)

This commit is contained in:
Soumya Ranjan Patra
2025-03-11 19:01:25 +05:30
committed by GitHub
parent ea8520f0c9
commit e3bb54bfc2
8 changed files with 50 additions and 37 deletions

View File

@@ -32,8 +32,14 @@ class NaviChatWebBridge(
private val hideOrShowScreenLoader: (Boolean) -> Unit = {},
private val viewModel: CRMWebSharedViewModel,
private val ctaDataListener: (CtaData) -> Unit,
private val onToggleNotificationVisibility: (Boolean) -> Unit,
) {
@JavascriptInterface
fun blockNotification(value: Boolean) {
onToggleNotificationVisibility(value)
}
@JavascriptInterface
fun toggleLoader(show: String) {
lifecycleScope.launch {

View File

@@ -88,7 +88,6 @@ class CRMWebViewActivity : BaseActivity() {
val fromActiveChat = intent.getStringExtra(ACTIVE_CHAT_CONV)
val conversationId = intent.getStringExtra(CONVERSATION_ID_PARAM)
webViewIntent =
WebViewIntent(
naviClickActionUrl = intent.getStringExtra(NAVI_CLICK_ACTION_URL),
@@ -226,6 +225,7 @@ class CRMWebViewActivity : BaseActivity() {
},
viewModel = viewModel,
ctaDataListener = { ctaData -> handleNavigation(this, ctaData) },
onToggleNotificationVisibility = { updateBlockNotification(it) },
)
webView.addJavascriptInterface(bridge, NAVI_JAVA_SCRIPT)
@@ -254,4 +254,23 @@ class CRMWebViewActivity : BaseActivity() {
}
}
}
override fun onStop() {
super.onStop()
blockNotification = false
}
override fun onDestroy() {
super.onDestroy()
blockNotification = false
}
private fun updateBlockNotification(value: Boolean) {
blockNotification = value
}
companion object {
var blockNotification = false
private set
}
}

View File

@@ -27,13 +27,8 @@ fun getCrmWebViewIntent(
): Intent {
val targetActivity =
when {
FirebaseRemoteConfigHelper.getBoolean(CRM_WEB_VIEW_ENABLED, false) -> {
when (ctaUrl) {
PRODUCT_HELP_PAGE,
ALL_TICKETS_V2,
CHAT_ACTIVITY -> CRMWebViewActivity::class.java
else -> NaviHelpCenterActivity::class.java
}
FirebaseRemoteConfigHelper.getBoolean(CRM_WEB_VIEW_ENABLED, true) -> {
CRMWebViewActivity::class.java
}
else -> {
when (ctaUrl) {
@@ -46,17 +41,15 @@ fun getCrmWebViewIntent(
}
return Intent(activity, targetActivity).apply {
if (ctaUrl == PRODUCT_HELP_PAGE || ctaUrl == CHAT_ACTIVITY || ctaUrl == ALL_TICKETS_V2) {
putExtra(NAVI_CLICK_ACTION_URL, ctaUrl)
putExtra(ACTIVE_CHAT_CONV, fromActiveChat)
putExtra(CONVERSATION_ID_PARAM, conversationId)
}
putExtra(NAVI_CLICK_ACTION_URL, ctaUrl)
putExtra(ACTIVE_CHAT_CONV, fromActiveChat)
putExtra(CONVERSATION_ID_PARAM, conversationId)
}
}
fun navigateToCrm(activity: Activity?, bundle: Bundle?, path: String?) {
val intent =
if (FirebaseRemoteConfigHelper.getBoolean(CRM_WEB_VIEW_ENABLED, false)) {
if (FirebaseRemoteConfigHelper.getBoolean(CRM_WEB_VIEW_ENABLED, true)) {
Intent(activity, CRMWebViewActivity::class.java)
} else {
when (path) {
@@ -66,7 +59,7 @@ fun navigateToCrm(activity: Activity?, bundle: Bundle?, path: String?) {
else -> Intent(activity, NaviHelpCenterActivity::class.java)
}
}
if (FirebaseRemoteConfigHelper.getBoolean(CRM_WEB_VIEW_ENABLED, false)) {
if (FirebaseRemoteConfigHelper.getBoolean(CRM_WEB_VIEW_ENABLED, true)) {
bundle?.putString(NAVI_CLICK_ACTION_URL, path)
}
intent.putExtras(bundle ?: Bundle())

View File

@@ -205,9 +205,11 @@ constructor(
webViewIntent.orderId?.let {
pathUrl.append(AMPERSAND).append(ORDER_ID).append(EQUALS).append(it)
}
webViewIntent.productType?.let {
pathUrl.append(AMPERSAND).append(PRODUCT).append(EQUALS).append(it)
}
return pathUrl.toString()
}