-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfetchPatchJavaScriptFile.js
More file actions
39 lines (35 loc) · 1001 Bytes
/
fetchPatchJavaScriptFile.js
File metadata and controls
39 lines (35 loc) · 1001 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { getScript } from 'utils';
import {
API_END_POINT,
} from 'constants';
import newDialog from './newDialog';
const fetchPatchJavaScriptFile = (patch) => {
return (dispatch) => {
dispatch({
type: 'REQUEST_PATCH_JAVASCRIPT'
});
return getScript(API_END_POINT + '/builds/'+ patch._id +'?format=js&download=0&cachebust='+ new Date().getTime())
.then(()=>{
dispatch({
type: 'LOADED_PATCH_JAVASCRIPT',
isFetching: false,
patchId: patch._id
});
}).catch(err => {
console.error(err);
dispatch({
type: 'RESET_PATCH_JAVASCRIPT'
});
dispatch(newDialog({
header: 'Error trying to run the patch',
isError: true,
tabs: [{
header: 'Error',
isError: true,
contents: 'There was an error trying to load or run this patch in the browser.'
}]
}));
})
}
}
export default fetchPatchJavaScriptFile;