diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-02-21 15:30:03 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-02-21 15:30:03 +0900 |
| commit | de6d77d0cbd2905e021a075b667b6688cd5e06f6 (patch) | |
| tree | 4f960a3943926295ca1017bdd1cd35bc33dfe223 /src/web/app/common/define-widget.ts | |
| parent | wip (diff) | |
| download | misskey-de6d77d0cbd2905e021a075b667b6688cd5e06f6.tar.gz misskey-de6d77d0cbd2905e021a075b667b6688cd5e06f6.tar.bz2 misskey-de6d77d0cbd2905e021a075b667b6688cd5e06f6.zip | |
wip
Diffstat (limited to 'src/web/app/common/define-widget.ts')
| -rw-r--r-- | src/web/app/common/define-widget.ts | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/web/app/common/define-widget.ts b/src/web/app/common/define-widget.ts index 6088efd7e5..930a7c5868 100644 --- a/src/web/app/common/define-widget.ts +++ b/src/web/app/common/define-widget.ts @@ -2,7 +2,7 @@ import Vue from 'vue'; export default function<T extends object>(data: { name: string; - props?: T; + props?: () => T; }) { return Vue.extend({ props: { @@ -17,20 +17,9 @@ export default function<T extends object>(data: { }, data() { return { - props: data.props || {} as T + props: data.props ? data.props() : {} as T }; }, - watch: { - props(newProps, oldProps) { - if (JSON.stringify(newProps) == JSON.stringify(oldProps)) return; - (this as any).api('i/update_home', { - id: this.id, - data: newProps - }).then(() => { - (this as any).os.i.client_settings.home.find(w => w.id == this.id).data = newProps; - }); - } - }, created() { if (this.props) { Object.keys(this.props).forEach(prop => { @@ -39,6 +28,18 @@ export default function<T extends object>(data: { } }); } + + this.$watch('props', newProps => { + console.log(this.id, newProps); + (this as any).api('i/update_home', { + id: this.id, + data: newProps + }).then(() => { + (this as any).os.i.client_settings.home.find(w => w.id == this.id).data = newProps; + }); + }, { + deep: true + }); } }); } |