mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-06-25 17:10:43 +00:00
Update controller.ts
This commit is contained in:
parent
8421ec75da
commit
2e5a02a85a
1 changed files with 15 additions and 2 deletions
|
|
@ -139,13 +139,26 @@ export class RoomController {
|
|||
});
|
||||
|
||||
engineEvents.on('changeSelectedState', ({ selected }) => {
|
||||
this.selected.value = selected;
|
||||
this.selected.value = JSON.parse(JSON.stringify(selected));
|
||||
});
|
||||
|
||||
engineEvents.on('changeRoomState', ({ roomState }) => {
|
||||
if (deepEqual(this.roomState.value, roomState)) return; // vueのリアクティビティが反応して無限ループになることがあるため
|
||||
this.roomState.value = JSON.parse(JSON.stringify(roomState));
|
||||
triggerRef(this.selected);
|
||||
if (this.selected.value != null) {
|
||||
// そのまま入れると「オブジェクト(newSelected)の内容」は変わってるけど「オブジェクトの参照」そのものは変化していないから、
|
||||
// その状態で代入しようがtriggerRef呼ぼうがVueは「子に対しては」更新があったと見做してくれない(親から当該refをwatchする場合は発火する)っぽい(バグか仕様かは不明)
|
||||
// そのため新しい参照にするためにdeepClone
|
||||
const newSelected = JSON.parse(JSON.stringify(roomState.installedObjects.find(o => o.id === this.selected.value.objectId)));
|
||||
if (newSelected) {
|
||||
this.selected.value = {
|
||||
objectId: newSelected.id,
|
||||
objectState: newSelected,
|
||||
};
|
||||
} else {
|
||||
this.selected.value = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
engineEvents.on('playSfxUrl', ({ url, options }) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue