Skip to content

Commit

Permalink
Fix speaker stats search for empty string jitsi#9751
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitardelchev93 committed Sep 24, 2021
1 parent fb4d3b1 commit 2cf3a2f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
4 changes: 2 additions & 2 deletions react/features/speaker-stats/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import {
/**
* Starts a search by criteria.
*
* @param {string} criteria - The search criteria.
* @param {string | null} criteria - The search criteria.
* @returns {Object}
*/
export function initSearch(criteria: string) {
export function initSearch(criteria: string | null) {
return {
type: INIT_SEARCH,
criteria
Expand Down
10 changes: 4 additions & 6 deletions react/features/speaker-stats/components/SpeakerStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { connect } from '../../base/redux';
import { escapeRegexp } from '../../base/util';
import { initUpdateStats, initSearch } from '../actions';
import { SPEAKER_STATS_RELOAD_INTERVAL } from '../constants';
import { getSpeakerStats, getSearchCriteria } from '../functions';
import { getSpeakerStats } from '../functions';

import SpeakerStatsItem from './SpeakerStatsItem';
import SpeakerStatsLabels from './SpeakerStatsLabels';
Expand All @@ -36,7 +36,7 @@ type Props = {
/**
* The search criteria.
*/
_criteria: string,
_criteria: string | null,

/**
* The JitsiConference from which stats will be pulled.
Expand Down Expand Up @@ -216,8 +216,7 @@ class SpeakerStats extends Component<Props> {
* @private
* @returns {{
* _localDisplayName: ?string,
* _stats: Object,
* _criteria: string,
* _stats: Object
* }}
*/
function _mapStateToProps(state) {
Expand All @@ -231,8 +230,7 @@ function _mapStateToProps(state) {
* @type {string|undefined}
*/
_localDisplayName: localParticipant && localParticipant.name,
_stats: getSpeakerStats(state),
_criteria: getSearchCriteria(state)
_stats: getSpeakerStats(state)
};
}

Expand Down
6 changes: 3 additions & 3 deletions react/features/speaker-stats/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ export function getSpeakerStats(state: Object) {
* Gets speaker stats search criteria.
*
* @param {*} state - The redux state.
* @returns {string} - The search criteria.
* @returns {string | null} - The search criteria.
*/
export function getSearchCriteria(state: Object) {
return state['features/speaker-stats']?.criteria ?? '';
return state['features/speaker-stats']?.criteria;
}

/**
Expand Down Expand Up @@ -161,7 +161,7 @@ export function filterBySearchCriteria(state: Object, stats: ?Object) {
const filteredStats = _.cloneDeep(stats ?? getSpeakerStats(state));
const criteria = getSearchCriteria(state);

if (criteria) {
if (criteria !== null) {
const searchRegex = new RegExp(criteria, 'gi');

for (const id in filteredStats) {
Expand Down
2 changes: 1 addition & 1 deletion react/features/speaker-stats/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
const INITIAL_STATE = {
stats: {},
pendingReorder: true,
criteria: ''
criteria: null
};

ReducerRegistry.register('features/speaker-stats', (state = _getInitialState(), action) => {
Expand Down

0 comments on commit 2cf3a2f

Please sign in to comment.