diff --git a/demo/src/hooks/useElementSelect.ts b/demo/src/hooks/useElementSelect.ts index be873b66..d29adbf3 100644 --- a/demo/src/hooks/useElementSelect.ts +++ b/demo/src/hooks/useElementSelect.ts @@ -42,7 +42,7 @@ export const useClickOutside = (ref: MutableRefObject, self? await space.locations.set({ slide: self.location?.slide, element: undefined }); // TODO delete this workaround when spaces API is ready await delay(60); - await releaseMyLocks(space, self); + await releaseMyLocks(space); } }; diff --git a/demo/src/utils/locking.ts b/demo/src/utils/locking.ts index b1fbe331..5615b9dc 100644 --- a/demo/src/utils/locking.ts +++ b/demo/src/utils/locking.ts @@ -1,10 +1,7 @@ import { Space } from '@ably/spaces'; -import { Member } from './types'; -export const releaseMyLocks = async (space: Space, self: Member) => { - await Promise.all([ - ...space.locks.getLocksForConnectionId(self.connectionId).map((lock) => space.locks.release(lock.id)), - ]); +export const releaseMyLocks = async (space: Space) => { + await Promise.all([...space.locks.getSelf().map((lock) => space.locks.release(lock.id))]); }; export const buildLockId = (slide: string | undefined, element: string | undefined) => diff --git a/src/Locks.ts b/src/Locks.ts index c0b94b6c..8e6eba2f 100644 --- a/src/Locks.ts +++ b/src/Locks.ts @@ -292,7 +292,7 @@ export default class Locks extends EventEmitter { return locks.delete(connectionId); } - getLocksForConnectionId(connectionId: string): Lock[] { + private getLocksForConnectionId(connectionId: string): Lock[] { const requests: Lock[] = []; for (const locks of this.locks.values()) {