Merge pull request #7018 from vector-im/bugfix/eric/new-layout-login-avatar

App Layout - Fixes avatar not showing on fresh login
This commit is contained in:
Eric Decanini 2022-09-06 08:25:19 +02:00 committed by GitHub
commit d6b7fcebde
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -58,14 +58,11 @@ import im.vector.app.features.settings.VectorSettingsActivity.Companion.EXTRA_DI
import im.vector.app.features.spaces.SpaceListBottomSheet import im.vector.app.features.spaces.SpaceListBottomSheet
import im.vector.app.features.workers.signout.BannerState import im.vector.app.features.workers.signout.BannerState
import im.vector.app.features.workers.signout.ServerBackupStatusViewModel import im.vector.app.features.workers.signout.ServerBackupStatusViewModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import org.matrix.android.sdk.api.session.Session import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.crypto.model.DeviceInfo import org.matrix.android.sdk.api.session.crypto.model.DeviceInfo
import org.matrix.android.sdk.api.session.room.model.RoomSummary import org.matrix.android.sdk.api.session.room.model.RoomSummary
import org.matrix.android.sdk.api.util.toMatrixItem
import javax.inject.Inject import javax.inject.Inject
@AndroidEntryPoint @AndroidEntryPoint
@ -322,12 +319,6 @@ class NewHomeDetailFragment :
private fun setupToolbar() { private fun setupToolbar() {
setupToolbar(views.toolbar) setupToolbar(views.toolbar)
lifecycleScope.launch(Dispatchers.IO) {
session.userService().getUser(session.myUserId)?.let { user ->
avatarRenderer.render(user.toMatrixItem(), views.avatar)
}
}
views.collapsingToolbar.debouncedClicks(::openSpaceSettings) views.collapsingToolbar.debouncedClicks(::openSpaceSettings)
views.toolbar.debouncedClicks(::openSpaceSettings) views.toolbar.debouncedClicks(::openSpaceSettings)
@ -373,9 +364,16 @@ class NewHomeDetailFragment :
vectorPreferences.developerShowDebugInfo() vectorPreferences.developerShowDebugInfo()
) )
refreshAvatar()
hasUnreadRooms = it.hasUnreadMessages hasUnreadRooms = it.hasUnreadMessages
} }
private fun refreshAvatar() = withState(viewModel) { state ->
state.myMatrixItem?.let { user ->
avatarRenderer.render(user, views.avatar)
}
}
override fun onTapToReturnToCall() { override fun onTapToReturnToCall() {
callManager.getCurrentCall()?.let { call -> callManager.getCurrentCall()?.let { call ->
VectorCallActivity.newIntent( VectorCallActivity.newIntent(