Bug 1520662 - Ensure undeterministic load order is not causing crashes
This commit is contained in:
Родитель
c1ef27cfd6
Коммит
651d814668
|
@ -59,7 +59,7 @@ const INITIAL_STATE = {
|
|||
spocs: {
|
||||
spocs_endpoint: "",
|
||||
lastUpdated: null,
|
||||
data: [],
|
||||
data: {}, // {spocs: []}
|
||||
},
|
||||
},
|
||||
Search: {
|
||||
|
|
|
@ -37,7 +37,7 @@ export class _DiscoveryStreamBase extends React.PureComponent {
|
|||
items={component.properties.items} />);
|
||||
case "Hero":
|
||||
const items = Math.min(MAX_ROWS_HERO,
|
||||
component.properties.items || component.data ? component.data.recommendations.length : 0);
|
||||
component.properties.items || (component.data ? component.data.recommendations.length : 0));
|
||||
const rows = component.data ? component.data.recommendations.slice(0, items) : [];
|
||||
return (
|
||||
<ImpressionStats rows={rows} dispatch={this.props.dispatch} source={component.type}>
|
||||
|
|
|
@ -46,7 +46,7 @@ export function _List(props) {
|
|||
|
||||
return (
|
||||
<div>
|
||||
<h3 className="ds-list-title">{props.header.title}</h3>
|
||||
<h3 className="ds-list-title">{props.header && props.header.title}</h3>
|
||||
<hr className="ds-list-border" />
|
||||
<ul className="ds-list">{recMarkup}</ul>
|
||||
</div>
|
||||
|
|
|
@ -4,7 +4,7 @@ function calculateSpocs(component, spocs) {
|
|||
let spocIndex = 0;
|
||||
return component.spocs.positions.map(position => {
|
||||
const rickRoll = Math.random();
|
||||
if (rickRoll <= component.spocs.probability) {
|
||||
if (spocs.data.spocs[spocIndex] && rickRoll <= component.spocs.probability) {
|
||||
return {
|
||||
...position,
|
||||
result: spocs.data.spocs[spocIndex++],
|
||||
|
@ -37,7 +37,7 @@ export const selectLayoutRender = createSelector(
|
|||
}
|
||||
|
||||
// Calculate if we should display a spoc or not.
|
||||
if (component.spocs) {
|
||||
if (component.spocs && spocs.data.spocs && spocs.data.spocs.length) {
|
||||
component.spocs = {
|
||||
...component.spocs,
|
||||
positions: calculateSpocs(component, spocs),
|
||||
|
|
Загрузка…
Ссылка в новой задаче