mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-26 17:16:11 -05:00
Merge pull request #2427 from chrisgarrity/issue/sb2-mod-info
Add moderator info for sb2 projects
This commit is contained in:
commit
594ce06b5b
2 changed files with 27 additions and 17 deletions
|
@ -454,8 +454,8 @@ const PreviewPresentation = ({
|
|||
</div>
|
||||
<ModInfo
|
||||
revisedDate={revisedDate}
|
||||
scripts={modInfo.scripts}
|
||||
sprites={modInfo.sprites}
|
||||
scripts={modInfo.scriptCount}
|
||||
sprites={modInfo.spriteCount}
|
||||
/>
|
||||
|
||||
</React.Fragment>
|
||||
|
@ -608,8 +608,8 @@ PreviewPresentation.propTypes = {
|
|||
loveCount: PropTypes.number,
|
||||
loved: PropTypes.bool,
|
||||
modInfo: PropTypes.shape({
|
||||
scripts: PropTypes.number,
|
||||
sprites: PropTypes.number
|
||||
scriptCount: PropTypes.number,
|
||||
spriteCount: PropTypes.number
|
||||
}),
|
||||
moreCommentsToLoad: PropTypes.bool,
|
||||
onAddComment: PropTypes.func,
|
||||
|
|
|
@ -99,8 +99,8 @@ class Preview extends React.Component {
|
|||
justShared: false,
|
||||
loveCount: 0,
|
||||
modInfo: {
|
||||
scripts: 0,
|
||||
sprites: 0
|
||||
scriptCount: 0,
|
||||
spriteCount: 0
|
||||
},
|
||||
projectId: parts[1] === 'editor' ? '0' : parts[1],
|
||||
reportOpen: false,
|
||||
|
@ -245,18 +245,28 @@ class Preview extends React.Component {
|
|||
}
|
||||
});
|
||||
}
|
||||
const sprites = projectData[0].targets.length - 1; // don't count stage
|
||||
const scripts = projectData[0].targets
|
||||
.map(target =>
|
||||
Object.values(target.blocks)
|
||||
.filter(block => block.topLevel).length
|
||||
)
|
||||
.reduce((accumulator, currentVal) => accumulator + currentVal, 0);
|
||||
let spriteCount = 0;
|
||||
let scriptCount = 0;
|
||||
if (projectData[0].projectVersion) {
|
||||
if (projectData[0].projectVersion === 3) {
|
||||
spriteCount = projectData[0].targets.length - 1; // don't count stage
|
||||
scriptCount = projectData[0].targets
|
||||
.map(target =>
|
||||
Object.values(target.blocks)
|
||||
.filter(block => block.topLevel).length
|
||||
)
|
||||
.reduce((accumulator, currentVal) => accumulator + currentVal, 0);
|
||||
} else if (projectData[0].projectVersion === 2) { // sb2 file
|
||||
spriteCount = projectData[0].info.spriteCount;
|
||||
scriptCount = projectData[0].info.scriptCount;
|
||||
}
|
||||
} // else sb (scratch 1.x) numbers will be zero
|
||||
|
||||
this.setState({
|
||||
extensions: Array.from(extensionSet),
|
||||
modInfo: {
|
||||
scripts: scripts,
|
||||
sprites: sprites
|
||||
scriptCount: scriptCount,
|
||||
spriteCount: spriteCount
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -265,8 +275,8 @@ class Preview extends React.Component {
|
|||
this.setState({
|
||||
extensions: [],
|
||||
modInfo: {
|
||||
scripts: 0,
|
||||
sprites: 0
|
||||
scriptCount: 0,
|
||||
spriteCount: 0
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue