Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
condenser
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
condenser
Commits
a6deb014
Commit
a6deb014
authored
4 years ago
by
Jason Salyers
Browse files
Options
Downloads
Patches
Plain Diff
[JES] Couple of quick null checks to get rid of console errors
parent
353a2de0
No related branches found
Branches containing commit
No related tags found
2 merge requests
!229
Develop
,
!228
[JES] Couple of quick null checks to get rid of console errors
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/app/components/pages/SearchIndex.jsx
+4
-14
4 additions, 14 deletions
src/app/components/pages/SearchIndex.jsx
src/app/redux/SearchReducer.js
+4
-6
4 additions, 6 deletions
src/app/redux/SearchReducer.js
with
8 additions
and
20 deletions
src/app/components/pages/SearchIndex.jsx
+
4
−
14
View file @
a6deb014
...
...
@@ -16,8 +16,7 @@ class SearchIndex extends React.Component {
q
:
PropTypes
.
string
,
s
:
PropTypes
.
string
,
}).
isRequired
,
scrollId
:
PropTypes
.
oneOfType
([
PropTypes
.
string
,
PropTypes
.
bool
])
.
isRequired
,
scrollId
:
PropTypes
.
oneOfType
([
PropTypes
.
string
,
PropTypes
.
bool
]).
isRequired
,
result
:
PropTypes
.
arrayOf
(
PropTypes
.
shape
({
app
:
PropTypes
.
string
,
...
...
@@ -71,12 +70,7 @@ class SearchIndex extends React.Component {
const
{
result
,
loading
,
params
,
performSearch
}
=
this
.
props
;
const
searchResults
=
(
<
PostsList
ref
=
"list"
posts
=
{
fromJS
(
result
)
}
loading
=
{
loading
}
loadMore
=
{
this
.
fetchMoreResults
}
/>
<
PostsList
ref
=
"list"
posts
=
{
fromJS
(
result
)
}
loading
=
{
loading
}
loadMore
=
{
this
.
fetchMoreResults
}
/>
);
return
(
...
...
@@ -94,11 +88,7 @@ class SearchIndex extends React.Component {
/>
</
div
>
</
div
>
{
!
loading
&&
result
.
length
===
0
?
(
<
Callout
>
{
'
Nothing was found.
'
}
</
Callout
>
)
:
(
searchResults
)
}
{
!
loading
&&
result
.
length
===
0
?
<
Callout
>
{
'
Nothing was found.
'
}
</
Callout
>
:
searchResults
}
</
article
>
</
div
>
);
...
...
@@ -112,7 +102,7 @@ module.exports = {
const
params
=
ownProps
.
location
.
query
;
return
{
loading
:
state
.
search
.
get
(
'
pending
'
),
result
:
state
.
search
.
get
(
'
result
'
).
toJS
(),
result
:
state
.
search
.
get
(
'
result
'
).
toJS
()
||
{}
,
scrollId
:
state
.
search
.
get
(
'
scrollId
'
),
isBrowser
:
process
.
env
.
BROWSER
,
params
,
...
...
This diff is collapsed.
Click to expand it.
src/app/redux/SearchReducer.js
+
4
−
6
View file @
a6deb014
...
...
@@ -31,6 +31,8 @@ export default function reducer(state = defaultSearchState, action) {
case
SEARCH_RESULT
:
{
const
{
hits
,
results
,
scroll_id
,
append
}
=
payload
;
if
(
results
===
null
||
results
===
undefined
)
return
state
;
const
posts
=
List
(
results
.
map
(
post
=>
{
post
.
created
=
post
.
created_at
;
...
...
@@ -42,15 +44,11 @@ export default function reducer(state = defaultSearchState, action) {
let
newState
=
{};
if
(
!
append
)
{
newState
=
state
.
set
(
'
result
'
,
posts
)
.
set
(
'
scrollId
'
,
scroll_id
);
newState
=
state
.
set
(
'
result
'
,
posts
).
set
(
'
scrollId
'
,
scroll_id
);
}
else
{
// If append is true. need to process results and append them to previous result
const
updatedResults
=
state
.
get
(
'
result
'
).
concat
(
posts
);
newState
=
state
.
setIn
([
'
result
'
],
new
List
(
updatedResults
))
.
setIn
([
'
scrollId
'
],
scroll_id
);
newState
=
state
.
setIn
([
'
result
'
],
new
List
(
updatedResults
)).
setIn
([
'
scrollId
'
],
scroll_id
);
}
return
newState
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment