Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
fix: create participant when entering room instead of when adding com…
Browse files Browse the repository at this point in the history
…ponent
  • Loading branch information
carlossantos74 committed Dec 23, 2023
1 parent fdda0ab commit c5a2930
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/components/comments/canvas-pin-adapter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class CanvasPin implements PinAdapter {
}

this.canvasSides = this.canvas.getBoundingClientRect();

document.body.style.position = 'relative';
this.onPinFixedObserver = new Observer({ logger: this.logger });
this.divWrapper = this.renderDivWrapper();
Expand Down
21 changes: 16 additions & 5 deletions src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,24 @@ const init = async (apiKey: string, options: SuperVizSdkOptions): Promise<Launch
throw new Error('Failed to validate API key');
}

const environment = await ApiService.fetchConfig(apiUrl, apiKey);
const limits = await ApiService.fetchLimits(apiUrl, apiKey);
const waterMark = await ApiService.fetchWaterMark(apiUrl, apiKey);
const [environment, limits, waterMark] = await Promise.all([
ApiService.fetchConfig(apiUrl, apiKey),
ApiService.fetchLimits(apiUrl, apiKey),
ApiService.fetchWaterMark(apiUrl, apiKey),
]).catch(() => {
throw new Error('Failed to load configuration from server');
});

if (!environment || !environment.ablyKey) {
throw new Error('Failed to load configuration from server');
}

const { ablyKey } = environment;
const { participant, roomId } = options;

const isEnteringTwice = await ApiService.validadeParticipantIsEnteringTwice(
options.participant,
options.roomId,
participant,
roomId,
apiKey,
ablyKey,
);
Expand All @@ -126,6 +131,12 @@ const init = async (apiKey: string, options: SuperVizSdkOptions): Promise<Launch
colors: options.customColors,
});

ApiService.createOrUpdateParticipant({
name: participant.name,
participantId: participant.id,
avatar: participant.avatar?.imageUrl,
});

return LauncherFacade(options);
};

Expand Down
5 changes: 0 additions & 5 deletions src/core/launcher/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ export class Launcher extends Observable implements DefaultLauncher {
this.realtime.updateMyProperties({ activeComponents: this.activeComponents });

ApiService.sendActivity(this.participant.id, this.group.id, this.group.name, component.name);
ApiService.createOrUpdateParticipant({
name: this.participant?.name,
participantId: this.participant?.id,
avatar: this.participant?.avatar.imageUrl,
});
};

/**
Expand Down

0 comments on commit c5a2930

Please sign in to comment.