summaryrefslogtreecommitdiff
path: root/packages/client/src/widgets/widget.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2022-11-17 09:31:07 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2022-11-17 09:31:07 +0900
commitd5aee2ea58a16e0cf65213fab9e46192882feba9 (patch)
tree037be7ad7b26abf647faa0f4ee6a6a96ba37fa95 /packages/client/src/widgets/widget.ts
parentfix typo on CleanRemoteFilesProcessorService (#9171) (diff)
downloadsharkey-d5aee2ea58a16e0cf65213fab9e46192882feba9.tar.gz
sharkey-d5aee2ea58a16e0cf65213fab9e46192882feba9.tar.bz2
sharkey-d5aee2ea58a16e0cf65213fab9e46192882feba9.zip
improve performance
Diffstat (limited to 'packages/client/src/widgets/widget.ts')
-rw-r--r--packages/client/src/widgets/widget.ts7
1 files changed, 4 insertions, 3 deletions
diff --git a/packages/client/src/widgets/widget.ts b/packages/client/src/widgets/widget.ts
index 9fdfe7f3e1..8bd56a5966 100644
--- a/packages/client/src/widgets/widget.ts
+++ b/packages/client/src/widgets/widget.ts
@@ -2,6 +2,7 @@ import { reactive, watch } from 'vue';
import { throttle } from 'throttle-debounce';
import { Form, GetFormResultType } from '@/scripts/form';
import * as os from '@/os';
+import { deepClone } from '@/scripts/clone';
export type Widget<P extends Record<string, unknown>> = {
id: string;
@@ -32,7 +33,7 @@ export const useWidgetPropsManager = <F extends Form & Record<string, { default:
save: () => void;
configure: () => void;
} => {
- const widgetProps = reactive(props.widget ? JSON.parse(JSON.stringify(props.widget.data)) : {});
+ const widgetProps = reactive(props.widget ? deepClone(props.widget.data) : {});
const mergeProps = () => {
for (const prop of Object.keys(propsDef)) {
@@ -43,14 +44,14 @@ export const useWidgetPropsManager = <F extends Form & Record<string, { default:
};
watch(widgetProps, () => {
mergeProps();
- }, { deep: true, immediate: true, });
+ }, { deep: true, immediate: true });
const save = throttle(3000, () => {
emit('updateProps', widgetProps);
});
const configure = async () => {
- const form = JSON.parse(JSON.stringify(propsDef));
+ const form = deepClone(propsDef);
for (const item of Object.keys(form)) {
form[item].default = widgetProps[item];
}