Skip to content

Commit d2c74c5

Browse files
authored
Merge pull request scratchfoundation#5385 from paulkaplan/libraries-3-format
Update library-item to handle 3.0 or 2.0 library formats
2 parents 797ce18 + 80e91a3 commit d2c74c5

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/containers/library-item.jsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,16 @@ class LibraryItem extends React.PureComponent {
9292
this.setState({iconIndex: nextIconIndex});
9393
}
9494
curIconMd5 () {
95+
const iconMd5Prop = this.props.iconMd5;
9596
if (this.props.icons &&
9697
this.state.isRotatingIcon &&
97-
this.state.iconIndex < this.props.icons.length &&
98-
this.props.icons[this.state.iconIndex] &&
99-
this.props.icons[this.state.iconIndex].baseLayerMD5) {
100-
return this.props.icons[this.state.iconIndex].baseLayerMD5;
98+
this.state.iconIndex < this.props.icons.length) {
99+
const icon = this.props.icons[this.state.iconIndex] || {};
100+
return icon.md5ext || // 3.0 library format
101+
icon.baseLayerMD5 || // 2.0 library format, TODO GH-5084
102+
iconMd5Prop;
101103
}
102-
return this.props.iconMd5;
104+
return iconMd5Prop;
103105
}
104106
render () {
105107
const iconMd5 = this.curIconMd5();
@@ -151,7 +153,8 @@ LibraryItem.propTypes = {
151153
iconRawURL: PropTypes.string,
152154
icons: PropTypes.arrayOf(
153155
PropTypes.shape({
154-
baseLayerMD5: PropTypes.string
156+
baseLayerMD5: PropTypes.string, // 2.0 library format, TODO GH-5084
157+
md5ext: PropTypes.string // 3.0 library format
155158
})
156159
),
157160
id: PropTypes.number.isRequired,

0 commit comments

Comments
 (0)