Skip to content

Commit

Permalink
Merge pull request #2024 from element-hq/feature/fga/invite_list_back…
Browse files Browse the repository at this point in the history
…_navigation

Improve back-navigation for invitations
  • Loading branch information
ganfra authored Dec 14, 2023
2 parents 80408a8 + cbd5b24 commit a5a7f5a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import io.element.android.libraries.di.SessionScope
import io.element.android.libraries.matrix.api.MatrixClient
import io.element.android.libraries.matrix.api.core.MAIN_SPACE
import io.element.android.libraries.matrix.api.core.RoomId
import io.element.android.libraries.matrix.api.roomlist.RoomList
import io.element.android.libraries.matrix.api.sync.SyncState
import io.element.android.libraries.push.api.notifications.NotificationDrawerManager
import io.element.android.services.appnavstate.api.AppNavigationStateService
Expand Down Expand Up @@ -149,6 +150,23 @@ class LoggedInFlowNode @AssistedInject constructor(
}
)
observeSyncStateAndNetworkStatus()
observeInvitesLoadingState()
}

private fun observeInvitesLoadingState() {
lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.STARTED) {
matrixClient.roomListService.invites.loadingState
.collect { inviteState ->
when (inviteState) {
is RoomList.LoadingState.Loaded -> if (inviteState.numberOfRooms == 0) {
backstack.removeLast(NavTarget.InviteList)
}
RoomList.LoadingState.NotLoaded -> Unit
}
}
}
}
}

@OptIn(FlowPreview::class)
Expand Down
1 change: 1 addition & 0 deletions changelog.d/2022.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Always close the invite list screen when there is no more invite.

0 comments on commit a5a7f5a

Please sign in to comment.