mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-27 01:25:52 -05:00
Set token for project metadata request
This commit is contained in:
parent
6f457ff1da
commit
8b4c692e33
2 changed files with 11 additions and 1 deletions
|
@ -11,9 +11,18 @@ class Storage extends ScratchStorage {
|
|||
super();
|
||||
this.addWebSource(
|
||||
[this.AssetType.Project],
|
||||
projectAsset => `${PROJECT_HOST}/${projectAsset.assetId}`
|
||||
this.getProjectGetConfig.bind(this)
|
||||
);
|
||||
}
|
||||
setProjectToken (projectToken) {
|
||||
this.projectToken = projectToken;
|
||||
}
|
||||
getProjectGetConfig (projectAsset) {
|
||||
const path = `${PROJECT_HOST}/${projectAsset.assetId}`;
|
||||
const qs = this.projectToken ? `?token=${this.projectToken}` : '';
|
||||
return path + qs;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const storage = new Storage();
|
||||
|
|
|
@ -159,6 +159,7 @@ class Preview extends React.Component {
|
|||
}
|
||||
}
|
||||
if (this.props.projectInfo.id !== prevProps.projectInfo.id) {
|
||||
storage.setProjectToken(this.props.projectInfo.project_token);
|
||||
if (typeof this.props.projectInfo.id === 'undefined') {
|
||||
this.initCounts(0, 0);
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue