diff --git a/client/constants.js b/client/constants.js index 1e50f5b7..8c59d051 100644 --- a/client/constants.js +++ b/client/constants.js @@ -41,7 +41,6 @@ export const SET_SELECTED_FILE = 'SET_SELECTED_FILE'; export const SHOW_MODAL = 'SHOW_MODAL'; export const HIDE_MODAL = 'HIDE_MODAL'; export const CREATE_FILE = 'CREATE_FILE'; -export const SET_BLOB_URL = 'SET_BLOB_URL'; export const EXPAND_SIDEBAR = 'EXPAND_SIDEBAR'; export const COLLAPSE_SIDEBAR = 'COLLAPSE_SIDEBAR'; diff --git a/client/modules/IDE/actions/files.js b/client/modules/IDE/actions/files.js index 86dde601..c599424b 100644 --- a/client/modules/IDE/actions/files.js +++ b/client/modules/IDE/actions/files.js @@ -1,8 +1,5 @@ import * as ActionTypes from '../../../constants'; import axios from 'axios'; -import blobUtil from 'blob-util'; -import xhr from 'xhr'; -import fileType from 'file-type'; import objectID from 'bson-objectid'; const ROOT_URL = location.href.indexOf('localhost') > 0 ? 'http://localhost:8000/api' : '/api'; @@ -36,38 +33,6 @@ export function updateFileContent(name, content) { }; } -export function getBlobUrl(file) { - return (dispatch) => { - xhr({ - uri: file.url, - responseType: 'arraybuffer', - useXDR: true - }, (err, body, res) => { - if (err) throw err; - const typeOfFile = fileType(new Uint8Array(res)); - blobUtil.arrayBufferToBlob(res, typeOfFile.mime) - .then(blobUtil.createObjectURL) - .then(objectURL => { - dispatch({ - type: ActionTypes.SET_BLOB_URL, - name: file.name, - blobURL: objectURL - }); - }); - }); - - // blobUtil.imgSrcToBlob(file.url, undefined, { crossOrigin: 'Anonymous' }) - // .then(blobUtil.createObjectURL) - // .then(objectURL => { - // dispatch({ - // type: ActionTypes.SET_BLOB_URL, - // name: file.name, - // blobURL: objectURL - // }); - // }); - }; -} - export function createFile(formProps) { return (dispatch, getState) => { const state = getState(); @@ -89,9 +54,6 @@ export function createFile(formProps) { }; axios.post(`${ROOT_URL}/projects/${state.project.id}/files`, postParams, { withCredentials: true }) .then(response => { - if (response.data.url) { - getBlobUrl(response.data)(dispatch); - } dispatch({ type: ActionTypes.CREATE_FILE, ...response.data, @@ -106,9 +68,6 @@ export function createFile(formProps) { error: response.data })); } else { - if (formProps.url) { - getBlobUrl(formProps)(dispatch); - } const id = objectID().toHexString(); dispatch({ type: ActionTypes.CREATE_FILE, diff --git a/client/modules/IDE/actions/project.js b/client/modules/IDE/actions/project.js index dfd4fddc..00552467 100644 --- a/client/modules/IDE/actions/project.js +++ b/client/modules/IDE/actions/project.js @@ -4,25 +4,13 @@ import axios from 'axios'; import JSZip from 'jszip'; import JSZipUtils from 'jszip-utils'; import { saveAs } from 'file-saver'; -import { getBlobUrl } from './files'; import { showToast, setToastText } from './toast'; import { setUnsavedChanges } from './ide'; const ROOT_URL = location.href.indexOf('localhost') > 0 ? 'http://localhost:8000/api' : '/api'; -export function getProjectBlobUrls() { - return (dispatch, getState) => { - const state = getState(); - state.files.forEach(file => { - if (file.url) { - getBlobUrl(file)(dispatch); - } - }); - }; -} - export function getProject(id) { - return (dispatch, getState) => { + return (dispatch) => { axios.get(`${ROOT_URL}/projects/${id}`, { withCredentials: true }) .then(response => { // browserHistory.push(`/projects/${id}`); @@ -32,7 +20,6 @@ export function getProject(id) { files: response.data.files, owner: response.data.user }); - getProjectBlobUrls()(dispatch, getState); dispatch(setUnsavedChanges(false)); }) .catch(response => dispatch({ diff --git a/client/modules/IDE/components/PreviewFrame.js b/client/modules/IDE/components/PreviewFrame.js index 3c2ec073..ab77c041 100644 --- a/client/modules/IDE/components/PreviewFrame.js +++ b/client/modules/IDE/components/PreviewFrame.js @@ -181,7 +181,7 @@ class PreviewFrame extends React.Component { const fileName = filePathArray[filePathArray.length - 1]; mediaFiles.forEach(file => { if (file.name === fileName) { - newJSFile.content = newJSFile.content.replace(filePath, file.blobURL); // eslint-disable-line + newJSFile.content = newJSFile.content.replace(filePath, file.url); // eslint-disable-line } }); } diff --git a/client/modules/IDE/reducers/files.js b/client/modules/IDE/reducers/files.js index 27cd527c..3b1b17cd 100644 --- a/client/modules/IDE/reducers/files.js +++ b/client/modules/IDE/reducers/files.js @@ -119,13 +119,6 @@ const files = (state, action) => { return Object.assign({}, file, { content: action.content }); }); - case ActionTypes.SET_BLOB_URL: - return state.map(file => { - if (file.name !== action.name) { - return file; - } - return Object.assign({}, file, { blobURL: action.blobURL }); - }); case ActionTypes.NEW_PROJECT: return [...action.files]; case ActionTypes.SET_PROJECT: diff --git a/package.json b/package.json index c5b29390..6de6c86f 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,6 @@ "axios": "^0.12.0", "babel-core": "^6.8.0", "bcrypt-nodejs": "0.0.3", - "blob-util": "^1.2.1", "body-parser": "^1.15.1", "bson-objectid": "^1.1.4", "classnames": "^2.2.5",