Invites : open room instead of invite list when clicking an invite notification

This commit is contained in:
ganfra
2024-04-16 13:20:43 +02:00
parent 0e65ea8eb8
commit 8f583d78ac
12 changed files with 1 additions and 49 deletions

View File

@@ -46,10 +46,4 @@ class IntentProviderImpl @Inject constructor(
}
}
override fun getInviteListIntent(sessionId: SessionId): Intent {
return Intent(context, MainActivity::class.java).apply {
action = Intent.ACTION_VIEW
data = deepLinkCreator.inviteList(sessionId).toUri()
}
}
}

View File

@@ -362,12 +362,6 @@ class LoggedInFlowNode @AssistedInject constructor(
}
}
internal suspend fun attachInviteList(deeplinkData: DeeplinkData.InviteList) = withContext(lifecycleScope.coroutineContext) {
if (!canShowRoomList()) return@withContext
notificationDrawerManager.clearMembershipNotificationForSession(deeplinkData.sessionId)
backstack.singleTop(NavTarget.RoomList)
}
private fun canShowRoomList(): Boolean {
return ftueService.state.value is FtueState.Complete
}

View File

@@ -290,7 +290,6 @@ class RootFlowNode @AssistedInject constructor(
when (deeplinkData) {
is DeeplinkData.Root -> attachRoomList()
is DeeplinkData.Room -> attachRoom(deeplinkData.roomId)
is DeeplinkData.InviteList -> attachInviteList(deeplinkData)
}
}
}

View File

@@ -18,7 +18,3 @@ package io.element.android.libraries.deeplink
internal const val SCHEME = "elementx"
internal const val HOST = "open"
object DeepLinkPaths {
const val INVITE_LIST = "invites"
}

View File

@@ -36,13 +36,4 @@ class DeepLinkCreator @Inject constructor() {
}
}
}
fun inviteList(sessionId: SessionId): String {
return buildString {
append("$SCHEME://$HOST/")
append(sessionId.value)
append("/")
append(DeepLinkPaths.INVITE_LIST)
}
}
}

View File

@@ -30,6 +30,4 @@ sealed interface DeeplinkData {
/** The target is a room, with the given [sessionId], [roomId] and optionally a [threadId]. */
data class Room(override val sessionId: SessionId, val roomId: RoomId, val threadId: ThreadId?) : DeeplinkData
/** The target is the invites list, with the given [sessionId]. */
data class InviteList(override val sessionId: SessionId) : DeeplinkData
}

View File

@@ -39,7 +39,6 @@ class DeeplinkParser @Inject constructor() {
return when (val screenPathComponent = pathBits.elementAtOrNull(1)) {
null -> DeeplinkData.Root(sessionId)
DeepLinkPaths.INVITE_LIST -> DeeplinkData.InviteList(sessionId)
else -> {
val roomId = screenPathComponent.let(::RoomId)
val threadId = pathBits.elementAtOrNull(2)?.let(::ThreadId)

View File

@@ -34,10 +34,4 @@ class DeepLinkCreatorTest {
.isEqualTo("elementx://open/@alice:server.org/!aRoomId:domain/\$aThreadId")
}
@Test
fun inviteList() {
val sut = DeepLinkCreator()
assertThat(sut.inviteList(A_SESSION_ID))
.isEqualTo("elementx://open/@alice:server.org/invites")
}
}

View File

@@ -36,8 +36,6 @@ class DeeplinkParserTest {
"elementx://open/@alice:server.org/!aRoomId:domain"
const val A_URI_WITH_ROOM_WITH_THREAD =
"elementx://open/@alice:server.org/!aRoomId:domain/\$aThreadId"
const val A_URI_FOR_INVITE_LIST =
"elementx://open/@alice:server.org/invites"
}
private val sut = DeeplinkParser()
@@ -50,8 +48,6 @@ class DeeplinkParserTest {
.isEqualTo(DeeplinkData.Room(A_SESSION_ID, A_ROOM_ID, null))
assertThat(sut.getFromIntent(createIntent(A_URI_WITH_ROOM_WITH_THREAD)))
.isEqualTo(DeeplinkData.Room(A_SESSION_ID, A_ROOM_ID, A_THREAD_ID))
assertThat(sut.getFromIntent(createIntent(A_URI_FOR_INVITE_LIST)))
.isEqualTo(DeeplinkData.InviteList(A_SESSION_ID))
}
@Test

View File

@@ -31,8 +31,4 @@ interface IntentProvider {
threadId: ThreadId?,
): Intent
/**
* Provide an intent to start the application on the invite list.
*/
fun getInviteListIntent(sessionId: SessionId): Intent
}

View File

@@ -157,7 +157,7 @@ class NotificationCreator @Inject constructor(
// .addAction(acceptInvitationActionFactory.create(inviteNotifiableEvent))
.apply {
// Build the pending intent for when the notification is clicked
setContentIntent(pendingIntentFactory.createInviteListPendingIntent(inviteNotifiableEvent.sessionId))
setContentIntent(pendingIntentFactory.createOpenRoomPendingIntent(inviteNotifiableEvent.sessionId, inviteNotifiableEvent.roomId))
if (inviteNotifiableEvent.noisy) {
// Compat

View File

@@ -128,9 +128,4 @@ class PendingIntentFactory @Inject constructor(
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
)
}
fun createInviteListPendingIntent(sessionId: SessionId): PendingIntent {
val intent = intentProvider.getInviteListIntent(sessionId)
return PendingIntentCompat.getActivity(context, 0, intent, 0, false)!!
}
}