From 8b4c692e336c119d156fe1169f23d012d5b2ef63 Mon Sep 17 00:00:00 2001 From: rschamp Date: Fri, 6 May 2022 14:13:55 -0400 Subject: [PATCH] Set token for project metadata request --- src/lib/storage.js | 11 ++++++++++- src/views/preview/project-view.jsx | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/lib/storage.js b/src/lib/storage.js index 3de36efe6..0224ac6b0 100644 --- a/src/lib/storage.js +++ b/src/lib/storage.js @@ -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(); diff --git a/src/views/preview/project-view.jsx b/src/views/preview/project-view.jsx index b5793f502..1dd927299 100644 --- a/src/views/preview/project-view.jsx +++ b/src/views/preview/project-view.jsx @@ -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 {