Invites : open room instead of invite list when clicking an invite notification
This commit is contained in:
parent
0e65ea8eb8
commit
8f583d78ac
12 changed files with 1 additions and 49 deletions
|
|
@ -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()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
private fun canShowRoomList(): Boolean {
|
||||||
return ftueService.state.value is FtueState.Complete
|
return ftueService.state.value is FtueState.Complete
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -290,7 +290,6 @@ class RootFlowNode @AssistedInject constructor(
|
||||||
when (deeplinkData) {
|
when (deeplinkData) {
|
||||||
is DeeplinkData.Root -> attachRoomList()
|
is DeeplinkData.Root -> attachRoomList()
|
||||||
is DeeplinkData.Room -> attachRoom(deeplinkData.roomId)
|
is DeeplinkData.Room -> attachRoom(deeplinkData.roomId)
|
||||||
is DeeplinkData.InviteList -> attachInviteList(deeplinkData)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,3 @@ package io.element.android.libraries.deeplink
|
||||||
|
|
||||||
internal const val SCHEME = "elementx"
|
internal const val SCHEME = "elementx"
|
||||||
internal const val HOST = "open"
|
internal const val HOST = "open"
|
||||||
|
|
||||||
object DeepLinkPaths {
|
|
||||||
const val INVITE_LIST = "invites"
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,4 @@ sealed interface DeeplinkData {
|
||||||
/** The target is a room, with the given [sessionId], [roomId] and optionally a [threadId]. */
|
/** 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
|
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
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,6 @@ class DeeplinkParser @Inject constructor() {
|
||||||
|
|
||||||
return when (val screenPathComponent = pathBits.elementAtOrNull(1)) {
|
return when (val screenPathComponent = pathBits.elementAtOrNull(1)) {
|
||||||
null -> DeeplinkData.Root(sessionId)
|
null -> DeeplinkData.Root(sessionId)
|
||||||
DeepLinkPaths.INVITE_LIST -> DeeplinkData.InviteList(sessionId)
|
|
||||||
else -> {
|
else -> {
|
||||||
val roomId = screenPathComponent.let(::RoomId)
|
val roomId = screenPathComponent.let(::RoomId)
|
||||||
val threadId = pathBits.elementAtOrNull(2)?.let(::ThreadId)
|
val threadId = pathBits.elementAtOrNull(2)?.let(::ThreadId)
|
||||||
|
|
|
||||||
|
|
@ -34,10 +34,4 @@ class DeepLinkCreatorTest {
|
||||||
.isEqualTo("elementx://open/@alice:server.org/!aRoomId:domain/\$aThreadId")
|
.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")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,6 @@ class DeeplinkParserTest {
|
||||||
"elementx://open/@alice:server.org/!aRoomId:domain"
|
"elementx://open/@alice:server.org/!aRoomId:domain"
|
||||||
const val A_URI_WITH_ROOM_WITH_THREAD =
|
const val A_URI_WITH_ROOM_WITH_THREAD =
|
||||||
"elementx://open/@alice:server.org/!aRoomId:domain/\$aThreadId"
|
"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()
|
private val sut = DeeplinkParser()
|
||||||
|
|
@ -50,8 +48,6 @@ class DeeplinkParserTest {
|
||||||
.isEqualTo(DeeplinkData.Room(A_SESSION_ID, A_ROOM_ID, null))
|
.isEqualTo(DeeplinkData.Room(A_SESSION_ID, A_ROOM_ID, null))
|
||||||
assertThat(sut.getFromIntent(createIntent(A_URI_WITH_ROOM_WITH_THREAD)))
|
assertThat(sut.getFromIntent(createIntent(A_URI_WITH_ROOM_WITH_THREAD)))
|
||||||
.isEqualTo(DeeplinkData.Room(A_SESSION_ID, A_ROOM_ID, A_THREAD_ID))
|
.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
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,4 @@ interface IntentProvider {
|
||||||
threadId: ThreadId?,
|
threadId: ThreadId?,
|
||||||
): Intent
|
): Intent
|
||||||
|
|
||||||
/**
|
|
||||||
* Provide an intent to start the application on the invite list.
|
|
||||||
*/
|
|
||||||
fun getInviteListIntent(sessionId: SessionId): Intent
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,7 @@ class NotificationCreator @Inject constructor(
|
||||||
// .addAction(acceptInvitationActionFactory.create(inviteNotifiableEvent))
|
// .addAction(acceptInvitationActionFactory.create(inviteNotifiableEvent))
|
||||||
.apply {
|
.apply {
|
||||||
// Build the pending intent for when the notification is clicked
|
// 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) {
|
if (inviteNotifiableEvent.noisy) {
|
||||||
// Compat
|
// Compat
|
||||||
|
|
|
||||||
|
|
@ -128,9 +128,4 @@ class PendingIntentFactory @Inject constructor(
|
||||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
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)!!
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue