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 d96246d commit 4d85824
Showing 1 changed file with 26 additions and 20 deletions.
46 changes: 26 additions & 20 deletions react/features/speaker-stats/components/SpeakerStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,36 @@ class SpeakerStats extends Component<Props, State> {
_getSpeakerStats() {
const stats = { ...this.props.conference.getSpeakerStats() };

for (const userId in stats) {
if (stats[userId]) {
let displayName;

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

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

stats[userId].displayName = displayName;
}
}

if (this.state?.criteria) {
const searchRegex = new RegExp(this.state.criteria, 'gi');

for (const id in stats) {
if (stats[id].hasOwnProperty('_isLocalStats')) {
const name = stats[id].isLocalStats() ? this.props._localDisplayName : stats[id].getDisplayName();
for (const userId in stats) {
if (stats[userId]) {
const name = stats[userId].getDisplayName();

if (!name || !name.match(searchRegex)) {
delete stats[id];
delete stats[userId];
}
}
}
Expand Down Expand Up @@ -166,24 +187,9 @@ class SpeakerStats extends Component<Props, State> {
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.state.stats[userId].getDisplayName()
|| interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME;
}

return (
<SpeakerStatsItem
displayName = { displayName }
displayName = { statsModel.getDisplayName() }
dominantSpeakerTime = { dominantSpeakerTime }
hasLeft = { hasLeft }
isDominantSpeaker = { isDominantSpeaker }
Expand Down

0 comments on commit 4d85824

Please sign in to comment.