Skip to content

Commit

Permalink
Remove calls to .clone and replace them with {...object} as clone is …
Browse files Browse the repository at this point in the history
…no longer a method or required
  • Loading branch information
CADawg committed Mar 8, 2024
1 parent ad579a5 commit 8900c5e
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions ui/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<link rel="icon" type="image/svg+xml" href="/vite.svg"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>ConfigDN</title>
<script type="module" crossorigin src="/assets/index.6c0e64f1.js"></script>
<link rel="stylesheet" href="/assets/index.12bcf05e.css">
<script type="module" crossorigin src="/assets/index.be40edba.js"></script>
<link rel="stylesheet" href="/assets/index.f13f5edb.css">
</head>
<body>
<div id="app"></div>
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/dashboard/config/SettingCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function SettingCard(props: { flag: FlagRecord, originalValue: Va
const {flag, originalValue, value, setValue: setValue2, saveValue} = props;

function setValue(value: string) {
let clone = props.value.clone() as ValueRecordString;
let clone = {...props.value} as ValueRecordString;

clone.value = value;

Expand Down
22 changes: 11 additions & 11 deletions ui/src/routes/Dashboards/Config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,15 @@ export default function Config() {
const newValues = valuesInDB.map((v) => {
const type = flagsData.find(f => f.id === v.flag)?.type;

v = v.clone() as ValueRecordString;
v = {...v} as ValueRecordString;

v.value = specialJsonLoad(v.value, type);

return v as ValueRecordString;
});

setOriginalValues(newValues.map(v => v.clone() as ValueRecordString));
setEditedValues(newValues.map(v => v.clone() as ValueRecordString));
setOriginalValues(newValues.map(v => ({...v} as ValueRecordString)));
setEditedValues(newValues.map(v => ({...v} as ValueRecordString)));
}, [valuesInDB, flagsData]);

useEffect(() => {
Expand Down Expand Up @@ -190,14 +190,14 @@ export default function Config() {
value: getDefaultValue(newFlagType.value)
}).then((response) => {
setFlags(flags => {
return [...flags, responseFlag.clone() as FlagRecord];
return [...flags, {...responseFlag} as FlagRecord];
});

// update value to use string
response.value = specialJsonStringify(response.value, newFlagType.value);

setEditedValues(editedValues => [...editedValues, response.clone() as ValueRecordString]);
setOriginalValues(originalValues => [...originalValues, response.clone() as ValueRecordString]);
setEditedValues(editedValues => [...editedValues, {...response} as ValueRecordString]);
setOriginalValues(originalValues => [...originalValues, {...response} as ValueRecordString]);

setNewFlagDialogShowing(false);
}).catch((error) => {
Expand Down Expand Up @@ -294,8 +294,8 @@ export default function Config() {
// update value to use string
response.value = specialJsonStringify(response.value, flag.type);

setEditedValues(editedValues => [...editedValues, response.clone() as ValueRecordString]);
setOriginalValues(originalValues => [...originalValues, response.clone() as ValueRecordString]);
setEditedValues(editedValues => [...editedValues, {...response} as ValueRecordString]);
setOriginalValues(originalValues => [...originalValues, {...response} as ValueRecordString]);
}).catch((error) => {
console.error(error);
});
Expand Down Expand Up @@ -325,7 +325,7 @@ export default function Config() {
function toValueRecordString(value: ValueRecord): ValueRecordString {
const type = flagsData.find((f) => f.id === value.flag)?.type;

const newValue = value.clone();
const newValue = {...value};
newValue.value = specialJsonLoad(value.value, type);

return newValue as ValueRecordString;
Expand All @@ -340,7 +340,7 @@ export default function Config() {
const previousValue = originalValues[previousValueIndex];

if (JSON.stringify(previousValue.value) !== JSON.stringify(editedValues[i].value)) {
const editedValueClone = editedValue.clone();
const editedValueClone = {...editedValue}
editedValueClone.value = specialJsonParse(editedValue.value, flagsData.find((f) => f.id === editedValue.flag)?.type);

pocketbase.collection('value').update(editedValue.id, editedValueClone);
Expand All @@ -358,7 +358,7 @@ export default function Config() {
}

try {
const newVal = value.clone();
const newVal = {...value};
newVal.value = specialJsonParse(value.value, flagsData.find((f) => f.id === value.flag)?.type)

const record = await pocketbase.collection('value').update(value.id, newVal);
Expand Down
6 changes: 3 additions & 3 deletions ui/src/routes/Dashboards/Team.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import pocketbase from "../../libraries/Pocketbase";
import {useLoaderData, useNavigate} from "react-router-dom";
import {ProjectRecord, TeamRecord, UserRecord} from "../../types/Structures";
import DashboardUserSection from "../../components/dashboard/DashboardUserSection";
import React, {useEffect, useState} from "preact/compat";
import {useEffect, useState} from "preact/compat";
import DashboardObjects from "../../components/dashboard/DashboardObjects";
import DashboardObjectsTitle from "../../components/dashboard/DashboardObjectsTitle";
import DashboardObjectsList from "../../components/dashboard/DashboardObjectsList";
Expand Down Expand Up @@ -264,10 +264,10 @@ export default function Team() {
[userRole.value]: [...team[userRole.value], userToAdd.id],
}).then(() => {
// need to add it manually because otherwise we lose the extra data
const userObjectClone = userToAdd.clone() as UserRecord;
const userObjectClone = {...userToAdd} as UserRecord;

setTeam(team => {
let teamClone = team.clone() as TeamRecord;
let teamClone = {...team} as TeamRecord;

teamClone[userRole.value].push(userObjectClone.id);

Expand Down

0 comments on commit 8900c5e

Please sign in to comment.