Skip to content

Commit c126ee1

Browse files
committed
Fix create jotting bug, unescape bug, v1.1.1
* Get entire response object in createJotting request rather than only data (data was null, threw error) * Unescape double quotes in unescapeSlashes(str) v1.1.1
1 parent 90dd68d commit c126ee1

5 files changed

Lines changed: 266 additions & 3062 deletions

File tree

components/CreateJottingButton/createJottingButton.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,13 @@ export default function CreateJottingButton({
5656
if (e.key == "Enter") {
5757
const jotName = e.target.value;
5858
try {
59-
const response = await Requests[requestFunc](
59+
await Requests[requestFunc](
6060
requestArg1,
6161
jotName
6262
);
63-
64-
const jotsCopy = jots.slice();
65-
jotsCopy.push({ ...response, title: jotName, body: ""});
66-
setJots(jotsCopy);
6763
} catch (e) {
6864
console.error(e);
69-
window.alert(e);
65+
window.alert("A system error occurred");
7066
} finally {
7167
clearInput();
7268
showBtn();

libs/Datastore/requests.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,12 @@ export async function updateTaskStatus(id, completed) {
155155
*/
156156
export async function createJotting(jotType, jotName) {
157157
const queryString = `${jotType.toLowerCase()}`;
158-
const { data } = await BorumJotRequest.initialize(queryString)
158+
const response = await BorumJotRequest.initialize(queryString)
159159
.authorize()
160160
.post(`name=${jotName}`)
161161
.makeRequest();
162162

163-
return {
164-
id: data.id,
165-
title: jotName,
166-
};
163+
return response.data ?? response;
167164
}
168165

169166
export async function createSubtask(id, jotName) {

libs/Datastore/responseHelpers.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export function unescapeSlashes(str) {
1010
// because an odd number crashes the JSON.parse
1111
let parsedStr = str.replace(/\\'/gm, `'`);
1212
parsedStr = parsedStr.replace(/\\n/gm, `\n`);
13+
parsedStr = parsedStr.replace(/\\"/gm, `"`);
1314

1415
return parsedStr;
1516
}

0 commit comments

Comments
 (0)