Merge pull request #1983 from vector-im/feature/live_display_name

Make user displayName live in the setting, it should fix #1926
This commit is contained in:
Benoit Marty 2020-08-24 13:43:08 +02:00 committed by GitHub
commit f745e22a52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 3 deletions

View File

@ -8,7 +8,7 @@ Improvements 🙌:
-
Bugfix 🐛:
-
- Display name not shown under Settings/General (#1926)
Translations 🗣:
-

View File

@ -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() }