From bcb46fc54a5568eed2a964f7fb99e2b62fbd7814 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Fri, 25 Jun 2021 20:12:31 +0530 Subject: [PATCH] Make tile vm support disambiguation Signed-off-by: RMidhunSuresh --- .../session/rightpanel/MemberTileViewModel.js | 36 ++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/src/domain/session/rightpanel/MemberTileViewModel.js b/src/domain/session/rightpanel/MemberTileViewModel.js index 899f2b7b..3ee201db 100644 --- a/src/domain/session/rightpanel/MemberTileViewModel.js +++ b/src/domain/session/rightpanel/MemberTileViewModel.js @@ -4,19 +4,47 @@ export class MemberTileViewModel extends ViewModel { constructor(options) { super(options); this._member = this._options.member; - this._shouldDisambiguate = options.shouldDisambiguate; + this._previousName = null; + this._nameChanged = true; } get name() { - return this._member.name; + return `${this._member.name}${this._disambiguationPart}`; + } + + get _disambiguationPart() { + return this._disambiguate ? ` (${this.userId})` : ""; } get userId() { return this._member.userId; } - updateFrom(newMember) { - this._member = newMember; + get previousName() { + return this._previousName; } + get nameChanged() { + return this._nameChanged; + } + + _updatePreviousName(newName) { + const currentName = this._member.name; + if (currentName !== newName) { + this._previousName = currentName; + this._nameChanged = true; + } else { + this._nameChanged = false; + } + } + + setDisambiguation(status) { + this._disambiguate = status; + this.emitChange(); + } + + updateFrom(newMember) { + this._updatePreviousName(newMember.name); + this._member = newMember; + } }