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

Commit

Permalink
fix: make small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Raspincel committed Dec 8, 2023
1 parent cbb3608 commit a13a526
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 21 deletions.
5 changes: 2 additions & 3 deletions src/components/presence-mouse/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class MousePointers extends BaseComponent {
private divWrapper: HTMLElement;
private presences: Map<string, ParticipantMouse>;
private animateFrame: number;
private goToMouseCallback: PresenceMouseProps['onGoToPin'];
private goToMouseCallback: PresenceMouseProps['onGoToPresence'];
private following: string;

constructor(canvasId: string, options?: PresenceMouseProps) {
Expand All @@ -31,7 +31,7 @@ export class MousePointers extends BaseComponent {
this.divWrapper = this.renderDivWrapper();
this.animateFrame = requestAnimationFrame(this.animate);

this.goToMouseCallback = options?.onGoToPin;
this.goToMouseCallback = options?.onGoToPresence;
}

private get textColorValues(): number[] {
Expand Down Expand Up @@ -176,7 +176,6 @@ export class MousePointers extends BaseComponent {

if (this.following) {
const mouse = this.presences.get(this.following);
console.error('tsjfidsfs');
if (mouse) {
this.goToMouse(this.following);
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/presence-mouse/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ export interface ParticipantMouse extends Participant {
}

export interface PresenceMouseProps {
onGoToPin?: (position: { x: number; y: number }) => void;
onGoToPresence?: (position: { x: number; y: number }) => void;
}
17 changes: 9 additions & 8 deletions src/components/who-is-online/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { isEqual } from 'lodash';

import { RealtimeEvent } from '../../common/types/events.types';
import { Logger } from '../../common/utils';
import { AblyParticipant, ParticipantDataInput } from '../../services/realtime/ably/types';
import { AblyParticipant } from '../../services/realtime/ably/types';
import { WhoIsOnline as WhoIsOnlineElement } from '../../web-components';
import { BaseComponent } from '../base';
import { ComponentNames } from '../types';

import { WhoIsOnlinePosition, Position, Participant, Data } from './types';
import { WhoIsOnlinePosition, Position, Participant } from './types';

export class WhoIsOnline extends BaseComponent {
public name: ComponentNames;
Expand Down Expand Up @@ -108,14 +108,14 @@ export class WhoIsOnline extends BaseComponent {
});

const participants = updatedParticipants.map(({ data }) => {
const { slotIndex, id, name, avatar, activeComponents } = data as Data;
const { slotIndex, id, name, avatar, activeComponents } = data as Participant;
const { color } = this.realtime.getSlotColor(slotIndex);
const isLocal = this.localParticipant.id === id;
const joinedPresence = activeComponents.some((component) => component.includes('presence'));
// eslint-disable-next-line no-unused-expressions
isLocal && this.setDisableDropdown(!joinedPresence);

return { name, id, slotIndex, color, isLocal, joinedPresence };
this.setDisableDropdown(isLocal, !joinedPresence);

return { name, id, slotIndex, color, isLocal, joinedPresence, avatar };
});

if (isEqual(participants, this.participants)) return;
Expand All @@ -124,7 +124,9 @@ export class WhoIsOnline extends BaseComponent {
this.element.participants = this.participants;
};

private setDisableDropdown = (disable: boolean) => {
private setDisableDropdown = (local: boolean, disable: boolean) => {
if (!local) return;

this.element.disableDropdown = disable;
};

Expand Down Expand Up @@ -175,7 +177,6 @@ export class WhoIsOnline extends BaseComponent {
* @returns {void}
*/
private followMousePointer = ({ detail }: CustomEvent) => {
console.error('teste teste teste');
this.eventBus.publish(RealtimeEvent.REALTIME_FOLLOW_PARTICIPANT, detail.id);
};
}
10 changes: 1 addition & 9 deletions src/components/who-is-online/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,8 @@ export enum Position {
export interface Participant extends GeneralParticipant {
slotIndex: number;
isLocal?: boolean;
joinedPresence?: boolean | undefined;
joinedPresence?: boolean;
isPrivate?: boolean;
}

export type WhoIsOnlinePosition = Position | `${Position}` | string;

export type Data = {
slotIndex: number;
id: string;
name: string;
activeComponents: string[];
avatar: Avatar;
};

0 comments on commit a13a526

Please sign in to comment.