Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: remove encoding in homepage and when saving edit contact us #406

Merged
merged 4 commits into from
Apr 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/layouts/EditContactUs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import React, { useEffect, useState } from 'react';
import axios from 'axios';
import _ from 'lodash';
import { Base64 } from 'js-base64';
import PropTypes from 'prop-types';
import update from 'immutability-helper';
import { DragDropContext } from 'react-beautiful-dnd';
Expand Down Expand Up @@ -147,7 +146,7 @@ const EditContactUs = ({ match }) => {
id: null,
type: '',
})
const [showDeletedText, setShowDeletedText] = useState(false)
const [showDeletedText, setShowDeletedText] = useState(true)

useEffect(() => {
let _isMounted = true
Expand Down Expand Up @@ -583,10 +582,9 @@ const EditContactUs = ({ match }) => {
if (!filteredFrontMatter.locations.length) delete filteredFrontMatter.locations

const content = concatFrontMatterMdBody(filteredFrontMatter, '');
const base64EncodedContent = Base64.encode(content);

const frontMatterParams = {
content: base64EncodedContent,
content,
sha: frontMatterSha,
};

Expand Down
7 changes: 2 additions & 5 deletions src/layouts/EditHomepage.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useEffect, createRef, useState } from 'react';
import axios from 'axios';
import _ from 'lodash';
import { Base64 } from 'js-base64';
import PropTypes from 'prop-types';
import update from 'immutability-helper';
import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd';
Expand Down Expand Up @@ -164,8 +163,7 @@ const EditHomepage = ({ match }) => {
withCredentials: true,
});
const { content, sha } = resp.data;
const base64DecodedContent = Base64.decode(content);
const { frontMatter } = frontMatterParser(base64DecodedContent);
const { frontMatter } = frontMatterParser(content);
// Compute hasResources and set displaySections
let hasResources = false;
const displaySections = [];
Expand Down Expand Up @@ -906,10 +904,9 @@ const EditHomepage = ({ match }) => {
return newSection
})
const content = concatFrontMatterMdBody(filteredFrontMatter, '');
const base64EncodedContent = Base64.encode(content);

const params = {
content: base64EncodedContent,
content,
sha: sha,
};

Expand Down
1 change: 0 additions & 1 deletion src/layouts/EditPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { useQuery, useMutation } from 'react-query';
import PropTypes from 'prop-types';
import SimpleMDE from 'react-simplemde-editor';
import marked from 'marked';
import { Base64 } from 'js-base64';
import Policy from 'csp-parse';

import SimplePage from '../templates/SimplePage';
Expand Down