Skip to content

Commit

Permalink
remove block set
Browse files Browse the repository at this point in the history
  • Loading branch information
RSamaium committed Aug 22, 2023
1 parent 05d399e commit f411fa7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions sync-server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sync-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simple-room",
"version": "2.3.2",
"version": "2.4.0",
"description": "",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
Expand Down
9 changes: 5 additions & 4 deletions sync-server/src/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,10 @@ export class Room {
return new Proxy(object, {
set(target, key: string, val, receiver) {
const { fullPath: p, infoDict, genericPath } = getInfoDict(path, key, dictPath)
if (target._isDeleted) {
return false
}
// TODO: block set if deleted. Not apply in player
// if (target._isDeleted) {
// return false
// }
if (typeof val == 'object' && infoDict && val != null) {
const valProxy = deepProxy(val, p, genericPath)
if (path == 'users') {
Expand Down Expand Up @@ -235,7 +236,7 @@ export class Room {
},
deleteProperty(target, key) {
const { fullPath: p, infoDict } = getInfoDict(path, key, dictPath)
target[key]._isDeleted = true
//target[key]._isDeleted = true
Reflect.deleteProperty(target, key)
if (infoDict) self.detectChanges(room, null, p)
return true
Expand Down
3 changes: 2 additions & 1 deletion sync-server/tests/room.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ test('change current state', () => {
})
})

/*
test('sync state but is already deleted', async () => {
await expect(async () => {
class Room {
Expand All @@ -232,4 +233,4 @@ test('sync state but is already deleted', async () => {
room.events['test'] = new CharaEvent('test', room)
room.events['test'].onDead()
}).rejects.toThrow('\'set\' on proxy: trap returned falsish for property \'name\'');
})
})*/

0 comments on commit f411fa7

Please sign in to comment.