mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-12-17 19:12:40 -05:00
Allow URLs to be passed for the project input
This commit is contained in:
parent
4f6a583277
commit
4fcdf9b99f
1 changed files with 11 additions and 2 deletions
|
@ -60,7 +60,16 @@ const generateProjectListItem = (postBody, infoBody) => ({
|
||||||
avatar: infoBody.author.profile.images
|
avatar: infoBody.author.profile.images
|
||||||
});
|
});
|
||||||
|
|
||||||
const addProject = projectId => ((dispatch, getState) => new Promise((resolve, reject) => {
|
const addProject = projectIdOrUrl => ((dispatch, getState) => new Promise((resolve, reject) => {
|
||||||
|
// Strings are passed by the open input, numbers by the project browser
|
||||||
|
let projectId = projectIdOrUrl;
|
||||||
|
if (typeof projectIdOrUrl === 'string') {
|
||||||
|
const matches = projectIdOrUrl.match(/(\d+)/g);
|
||||||
|
if (!matches) return reject(Errors.UNKNOWN_PROJECT);
|
||||||
|
// Take the last match, in case we are on localhost and there are port numbers, e.g.
|
||||||
|
projectId = parseInt(matches[matches.length - 1], 10);
|
||||||
|
}
|
||||||
|
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const studioId = selectStudioId(state);
|
const studioId = selectStudioId(state);
|
||||||
const token = selectToken(state);
|
const token = selectToken(state);
|
||||||
|
|
Loading…
Reference in a new issue