Skip to content

Commit

Permalink
fixing urls
Browse files Browse the repository at this point in the history
  • Loading branch information
dlopezalvas committed Sep 25, 2023
1 parent 073aac6 commit 01a99a2
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions app/services/pilas-bloques-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@ export default Service.extend({

// SOLUTIONS
openChallenge(challengeId) {
if(this.isCreatorURL()) return
this._send('POST', 'challenges', { challengeId }, false).catch(logger('openChallenge'))
},

lastSolution(challengeId) {
if (!this.getUser() || this.isCreatorURL()) return null
if (!this.getUser()) return null
return this._send('GET', `challenges/${challengeId}/solution`, undefined, false).catch(() => null)
},

runProgram(challengeId, metadata) {
if(this.isCreatorURL()) return null
const solutionId = uuidv4()
const data = {
challengeId,
Expand All @@ -39,14 +37,13 @@ export default Service.extend({
},

executionFinished(solutionId, staticAnalysis, executionResult) {
if(this.isCreatorURL()) return
this._send('PUT', `solutions/${solutionId}`, { staticAnalysis, executionResult }, false).catch(logger('executionFinished'))
},

isCreatorURL(){
const currentURL = window.location.href
const creatorURLs = ['creador/ver', 'desafioImportado']
return !creatorURLs.some(url => currentURL.includes(url))
const creatorURLs = ['react-imported-challenge']
return creatorURLs.some(url => currentURL.includes(url))
},

// LOGIN - REGISTER
Expand Down Expand Up @@ -108,6 +105,8 @@ export default Service.extend({
},

async _send(method, resource, body, critical = true) {
if(resource.includes('solutions') && this.isCreatorURL()) return //Should not send or get solution when using the creator

const user = this.getUser()
const url = `${baseURL}/${resource}`
const flag = `loading.${resource.split('?')[0].replace('/', '-')}`
Expand Down

0 comments on commit 01a99a2

Please sign in to comment.