Skip to content

Commit d894a05

Browse files
committed
Remove unused get/upload image api calls
I also searched out logs for for editor endpoints to confirm that these aren't used
1 parent 17f1f8e commit d894a05

3 files changed

Lines changed: 0 additions & 57 deletions

File tree

src/redux/EditorSlice.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,6 @@ export const EditorSlice = createSlice({
183183
state.focussedFileIndices[action.payload.panelIndex] =
184184
action.payload.fileIndex;
185185
},
186-
updateImages: (state, action) => {
187-
if (!state.project.image_list) {
188-
state.project.image_list = [];
189-
}
190-
state.project.image_list = action.payload;
191-
},
192186
setWebComponent: (state, action) => {
193187
state.webComponent = action.payload;
194188
},
@@ -470,7 +464,6 @@ export const {
470464
triggerDraw,
471465
triggerSave,
472466
updateComponentName,
473-
updateImages,
474467
updateProjectComponent,
475468
updateProjectName,
476469
showBetaModal,

src/utils/apiCallHandler.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ const ApiCallHandler = ({ reactAppApiEndpoint }) => {
5050
);
5151
};
5252

53-
const getImage = async (url) => {
54-
return await get(url, headers());
55-
};
56-
5753
const loadRemix = async (projectIdentifier, accessToken) => {
5854
return await get(
5955
`${host}/api/projects/${projectIdentifier}/remix`,
@@ -92,20 +88,6 @@ const ApiCallHandler = ({ reactAppApiEndpoint }) => {
9288
});
9389
};
9490

95-
const uploadImages = async (projectIdentifier, accessToken, images) => {
96-
var formData = new FormData();
97-
98-
images.forEach((image) => {
99-
formData.append("images[]", image, image.name);
100-
});
101-
102-
return await post(
103-
`${host}/api/projects/${projectIdentifier}/images`,
104-
formData,
105-
{ ...headers(accessToken), "Content-Type": "multipart/form-data" },
106-
);
107-
};
108-
10991
const createError = async (
11092
projectIdentifier,
11193
userId,
@@ -130,13 +112,11 @@ const ApiCallHandler = ({ reactAppApiEndpoint }) => {
130112
put,
131113
createOrUpdateProject,
132114
deleteProject,
133-
getImage,
134115
loadRemix,
135116
createRemix,
136117
readProject,
137118
loadAssets,
138119
readProjectList,
139-
uploadImages,
140120
createError,
141121
};
142122
};

src/utils/apiCallHandler.test.js

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@ const authHeaders = {
1111
};
1212

1313
const {
14-
getImage,
1514
createOrUpdateProject,
1615
readProject,
1716
loadAssets,
1817
createRemix,
19-
uploadImages,
2018
readProjectList,
2119
createError,
2220
} = ApiCallHandler({ reactAppApiEndpoint: host });
@@ -168,34 +166,6 @@ describe("Testing project API calls", () => {
168166
authHeaders,
169167
);
170168
});
171-
172-
test("Upload image", async () => {
173-
const projectIdentifier = "my-amazing-project";
174-
const image = new File(["(⌐□_□)"], "image1.png", { type: "image/png" });
175-
axios.post.mockImplementationOnce(() =>
176-
Promise.resolve({ status: 200, url: "google.drive.com/image1.png" }),
177-
);
178-
179-
var formData = new FormData();
180-
formData.append("images[]", image, image.name);
181-
182-
await uploadImages(projectIdentifier, accessToken, [image]);
183-
expect(axios.post).toHaveBeenCalledWith(
184-
`${host}/api/projects/${projectIdentifier}/images`,
185-
formData,
186-
{ ...authHeaders, "Content-Type": "multipart/form-data" },
187-
);
188-
});
189-
190-
test("Get image", async () => {
191-
const image = new File(["(⌐□_□)"], "image1.png", { type: "image/png" });
192-
const imageUrl = "google.drive.com/image1.png";
193-
194-
axios.get.mockImplementationOnce(() => Promise.resolve({ image: image }));
195-
196-
await getImage(imageUrl);
197-
expect(axios.get).toHaveBeenCalledWith(imageUrl, defaultHeaders);
198-
});
199169
});
200170

201171
describe("Index page API calls", () => {

0 commit comments

Comments
 (0)