Skip to content

Commit

Permalink
Optimization of speaker stats display names jitsi#9751
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitardelchev93 committed Sep 24, 2021
1 parent 68de353 commit fb4d3b1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 20 deletions.
52 changes: 35 additions & 17 deletions react/features/speaker-stats/components/SpeakerStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,24 +140,9 @@ class SpeakerStats extends Component<Props> {
const dominantSpeakerTime = statsModel.getTotalDominantSpeakerTime();
const hasLeft = statsModel.hasLeft();

let displayName;

if (statsModel.isLocalStats()) {
const { t } = this.props;
const meString = t('me');

displayName = this.props._localDisplayName;
displayName
= displayName ? `${displayName} (${meString})` : meString;
} else {
displayName
= this.props._stats[userId].getDisplayName()
|| interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME;
}

return (
<SpeakerStatsItem
displayName = { displayName }
displayName = { statsModel.getDisplayName() }
dominantSpeakerTime = { dominantSpeakerTime }
hasLeft = { hasLeft }
isDominantSpeaker = { isDominantSpeaker }
Expand Down Expand Up @@ -187,7 +172,40 @@ class SpeakerStats extends Component<Props> {
* @private
*/
_updateStats() {
this.props.dispatch(initUpdateStats(() => this.props.conference.getSpeakerStats()));
this.props.dispatch(initUpdateStats(() => this._getSpeakerStats()));
}

/**
* Update the internal state with the latest speaker stats.
*
* @returns {Object}
* @private
*/
_getSpeakerStats() {
const stats = { ...this.props.conference.getSpeakerStats() };

for (const userId in stats) {
if (stats[userId]) {
if (stats[userId].isLocalStats()) {
const { t } = this.props;
const meString = t('me');

stats[userId].setDisplayName(
this.props._localDisplayName
? `${this.props._localDisplayName} (${meString})`
: meString
);
}

if (!stats[userId].getDisplayName()) {
stats[userId].setDisplayName(
interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME
);
}
}
}

return stats;
}
}

Expand Down
4 changes: 1 addition & 3 deletions react/features/speaker-stats/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,7 @@ export function filterBySearchCriteria(state: Object, stats: ?Object) {
if (filteredStats[id].hasOwnProperty('_isLocalStats')) {
const name = filteredStats[id].getDisplayName();

if (!name || !name.match(searchRegex)) {
filteredStats[id].hidden = true;
}
filteredStats[id].hidden = !name || !name.match(searchRegex);
}
}
}
Expand Down

0 comments on commit fb4d3b1

Please sign in to comment.