diff --git a/CHANGES.md b/CHANGES.md index e0f0780270..d3a16c9b29 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,7 +8,7 @@ Improvements 🙌: - Bugfix 🐛: - - + - Display name not shown under Settings/General (#1926) Translations 🗣: - diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsGeneralFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsGeneralFragment.kt index 6c406aa682..31de5ddd67 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsGeneralFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsGeneralFragment.kt @@ -128,6 +128,7 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() { super.onViewCreated(view, savedInstanceState) observeUserAvatar() + observeUserDisplayName() } private fun observeUserAvatar() { @@ -140,6 +141,22 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() { .disposeOnDestroyView() } + private fun observeUserDisplayName() { + session.rx() + .liveUser(session.myUserId) + .unwrap() + .map { it.displayName ?: "" } + .distinctUntilChanged() + .observeOn(AndroidSchedulers.mainThread()) + .subscribe { displayName -> + mDisplayNamePreference.let { + it.summary = displayName + it.text = displayName + } + } + .disposeOnDestroyView() + } + override fun bindPref() { // Avatar mUserAvatarPreference.let { @@ -151,8 +168,6 @@ class VectorSettingsGeneralFragment : VectorSettingsBaseFragment() { // Display name mDisplayNamePreference.let { - it.summary = session.getUser(session.myUserId)?.displayName ?: "" - it.text = it.summary.toString() it.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue -> newValue ?.let { value -> (value as? String)?.trim() }