This repository has been archived by the owner on Oct 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #753 from SuperViz/fix/video-bugs
hotfix: video bugs
- Loading branch information
Showing
11 changed files
with
147 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { coreBridge } from '.'; | ||
|
||
const localParticipantSpy = jest.fn(); | ||
const participantsSpy = jest.fn(); | ||
jest.mock('../../common/utils/use-store', () => ({ | ||
useStore: () => ({ | ||
localParticipant: { | ||
publish: localParticipantSpy, | ||
}, | ||
participants: { | ||
publish: participantsSpy, | ||
}, | ||
}), | ||
})); | ||
|
||
describe('coreBridge', () => { | ||
describe('updateLocalParticipant', () => { | ||
test('should log "updateLocalParticipant" and call localParticipant.publish', () => { | ||
const data = { id: '1' }; | ||
const logSpy = jest.spyOn(coreBridge['logger'], 'log'); | ||
|
||
coreBridge.updateLocalParticipant(data); | ||
|
||
expect(logSpy).toHaveBeenCalledWith('updateLocalParticipant', data); | ||
expect(localParticipantSpy).toHaveBeenCalledWith(data); | ||
}); | ||
}); | ||
|
||
describe('updateParticipantsList', () => { | ||
test('should log "updateParticipantsList" and call participants.publish', () => { | ||
const data = { 1: { id: '1' } }; | ||
const logSpy = jest.spyOn(coreBridge['logger'], 'log'); | ||
|
||
coreBridge.updateParticipantsList(data); | ||
|
||
expect(logSpy).toHaveBeenCalledWith('updateParticipantsList', data); | ||
expect(participantsSpy).toHaveBeenCalledWith(data); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Participant } from '../../common/types/participant.types'; | ||
import { StoreType } from '../../common/types/stores.types'; | ||
import { Logger } from '../../common/utils'; | ||
import { useStore } from '../../common/utils/use-store'; | ||
|
||
class CoreBridge { | ||
private logger: Logger; | ||
constructor() { | ||
this.logger = new Logger('@superviz/sdk/core-bridge'); | ||
this.logger.log('CoreBridge initialized'); | ||
} | ||
|
||
public updateLocalParticipant(data: Participant) { | ||
this.logger.log('updateLocalParticipant', data); | ||
const { localParticipant } = useStore(StoreType.CORE); | ||
localParticipant.publish(data); | ||
} | ||
|
||
public updateParticipantsList(data: Record<Participant['id'], Participant>) { | ||
this.logger.log('updateParticipantsList', data); | ||
const { participants } = useStore(StoreType.CORE); | ||
participants.publish(data); | ||
} | ||
} | ||
|
||
export const coreBridge = new CoreBridge(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Participant } from '../../../common/types/participant.types'; | ||
import { Singleton } from '../common/types'; | ||
import { CreateSingleton } from '../common/utils'; | ||
import subject from '../subject'; | ||
|
||
const instance: Singleton<CoreStore> = CreateSingleton<CoreStore>(); | ||
|
||
class CoreStore { | ||
public localParticipant = subject<Participant>({} as Participant); | ||
public participants = subject<Record<Participant['id'], Participant>>({}); | ||
|
||
constructor() { | ||
if (instance.value) { | ||
throw new Error('CoreStore is a singleton. There can only be one instance of it.'); | ||
} | ||
|
||
instance.value = this; | ||
} | ||
|
||
public destroy() { | ||
this.localParticipant.destroy(); | ||
this.participants.destroy(); | ||
} | ||
} | ||
|
||
const store = new CoreStore(); | ||
const destroy = store.destroy.bind(store); | ||
|
||
const localParticipant = store.localParticipant.expose(); | ||
const participants = store.participants.expose(); | ||
|
||
export function useCoreStore() { | ||
return { | ||
localParticipant, | ||
participants, | ||
destroy, | ||
}; | ||
} |