Skip to content

Commit

Permalink
Merge pull request #569 from ethereum-push-notification-service/fix/s…
Browse files Browse the repository at this point in the history
…pace-leave-end

fix(spaces): fix end, leave space methods
  • Loading branch information
madhur-push authored Jul 20, 2023
2 parents 9807c93 + 5a6a520 commit eab55bb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/restapi/src/lib/space/leave.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export async function leave(this: Space): Promise<void> {
// handle the case where a listner is leaving

// disconnect with every incoming peer in the mesh connection
this.data.incoming.forEach(({ address }) => {
this.data.incoming.slice(1).forEach(({ address }) => {
this.disconnect({
peerAddress: address,
details: {
Expand Down
2 changes: 1 addition & 1 deletion packages/restapi/src/lib/space/stop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export async function stop(this: Space): Promise<void> {
- disconnect with every incoming peer in the mesh connection
- other peers should also end their connections as we want to destroy the mesh connection
*/
this.data.incoming.forEach(({ address }) => {
this.data.incoming.slice(1).forEach(({ address }) => {
this.disconnect({
peerAddress: address,
details: {
Expand Down
3 changes: 3 additions & 0 deletions packages/restapi/src/lib/video/Video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const initVideoCallData: VideoCallData = {
video: null,
address: '',
},
// TODO: Remove the default element in incoming array
incoming: [
{
stream: null,
Expand Down Expand Up @@ -754,6 +755,8 @@ export class Video {
const { peerAddress, details } = options || {};

try {
console.log("DISCONNECT OPTIONS", options);

const incomingIndex = getIncomingIndexFromAddress(
this.data.incoming,
peerAddress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export const LiveWidgetContent: React.FC<LiveWidgetContentProps> = ({
spacesObjectRef.current = null;
setSpaceObjectData?.(PushAPI.space.initSpaceData);
setSpaceStatusState?.(SpaceStatus.Ended);
setIsLoading(false);
};

const handleLeaveSpace = async () => {
Expand All @@ -99,6 +100,7 @@ export const LiveWidgetContent: React.FC<LiveWidgetContentProps> = ({
spacesObjectRef.current = null;
setSpaceObjectData?.(PushAPI.space.initSpaceData);
}
setIsLoading(false);
};

// for listener
Expand Down

0 comments on commit eab55bb

Please sign in to comment.