mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-04 20:06:06 +02:00
wip
This commit is contained in:
@@ -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
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user