@@ -2,7 +2,7 @@ import React, { Component } from 'react';
2
2
import { connect } from 'react-redux' ;
3
3
import PropTypes from 'prop-types' ;
4
4
import { withTranslation } from 'react-i18next' ;
5
- import { Set , List } from 'immutable' ;
5
+ import { List } from 'immutable' ;
6
6
import { withRouter } from 'react-router' ;
7
7
import classNames from 'classnames' ;
8
8
import { withStyles } from '@material-ui/core/styles' ;
@@ -66,7 +66,7 @@ class Home extends Component {
66
66
history : PropTypes . shape ( {
67
67
replace : PropTypes . func . isRequired ,
68
68
} ) . isRequired ,
69
- spaces : PropTypes . instanceOf ( Set ) . isRequired ,
69
+ spaces : PropTypes . instanceOf ( List ) . isRequired ,
70
70
activity : PropTypes . bool ,
71
71
favoriteSpaces : PropTypes . instanceOf ( List ) . isRequired ,
72
72
recentSpaces : PropTypes . instanceOf ( List ) . isRequired ,
@@ -80,8 +80,8 @@ class Home extends Component {
80
80
} ;
81
81
82
82
state = {
83
- filteredRecentSpaces : Set ( ) ,
84
- filteredFavoriteSpaces : Set ( ) ,
83
+ filteredRecentSpaces : List ( ) ,
84
+ filteredFavoriteSpaces : List ( ) ,
85
85
} ;
86
86
87
87
componentDidMount ( ) {
@@ -125,9 +125,13 @@ class Home extends Component {
125
125
126
126
filterSpaces = spaces => {
127
127
const { searchQuery, spaces : originalSpaces } = this . props ;
128
- let filteredSpaces = spaces . map ( id =>
129
- originalSpaces . find ( ( { id : spaceId } ) => id === spaceId )
130
- ) ;
128
+ // get space content by id
129
+ let filteredSpaces = spaces
130
+ . map ( id => originalSpaces . find ( ( { id : spaceId } ) => id === spaceId ) )
131
+ // remove undefined space
132
+ // this case can happen if originalSpaces is updated before spaces
133
+ . filter ( space => space ) ;
134
+
131
135
filteredSpaces = searchSpacesByQuery ( filteredSpaces , searchQuery ) ;
132
136
return filteredSpaces ;
133
137
} ;
0 commit comments