Skip to content

Commit

Permalink
Update demo after rename
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominik Piatek committed Jul 27, 2023
1 parent 898df10 commit f530464
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions demo/app/components/cursors.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Space } from '../../../src';
import { queryDataId } from '../utils/dom';
import type { MemberColor } from '../utils/colors';

Expand Down Expand Up @@ -45,14 +46,14 @@ const createCursor = (connectionId: string, profileData: { name: string; color:
return container;
};

const attachCursors = (space, slideId) => {
const attachCursors = (space: Space, slideId) => {
const slideContainer = document.querySelector('#slide-selected') as HTMLElement;
const cursorContainer = queryDataId(slideContainer, 'slide-cursor-container');
cursorContainer.innerHTML = '';

const self = space.getSelf();

space.cursors.on('cursorsUpdate', (update) => {
space.cursors.subscribe('cursorsUpdate', (update) => {
let cursorNode: HTMLElement = slideContainer.querySelector(`#cursor-${update.connectionId}`);

const membersOnSlide = space.getMembers().filter((member) => member.location?.slide === slideId);
Expand Down Expand Up @@ -99,7 +100,7 @@ const attachCursors = (space, slideId) => {
document.addEventListener('visibilitychange', cursorHandlers.tabLeft);

return () => {
space.cursors.off();
space.cursors.unsubscribe();
slideContainer.removeEventListener('mouseenter', cursorHandlers.enter);
slideContainer.removeEventListener('mousemove', cursorHandlers.move);
slideContainer.removeEventListener('mouseleave', cursorHandlers.leave);
Expand Down
6 changes: 3 additions & 3 deletions demo/app/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const space = await spaces.get(getSpaceNameFromUrl(), {
offlineTimeout: 10_000,
});

space.on(MEMBERS_UPDATE, (members) => {
space.subscribe(MEMBERS_UPDATE, (members) => {
renderAvatars(members.filter(memberIsNotSelf));
});

Expand All @@ -56,7 +56,7 @@ renderSelectedSlide(space);
renderComments();
let detachCursors = attachCursors(space, currentSlide().id);

space.locations.on('locationUpdate', ({ previousLocation, currentLocation }) => {
space.locations.subscribe('locationUpdate', ({ previousLocation, currentLocation }) => {
renderSlidePreviewMenu(space);
renderSelectedSlide(space);

Expand All @@ -65,7 +65,7 @@ space.locations.on('locationUpdate', ({ previousLocation, currentLocation }) =>
detachCursors = attachCursors(space, currentSlide().id);
});

space.on('membersUpdate', (members) => {
space.subscribe('membersUpdate', (members) => {
renderAvatars(members.filter(memberIsNotSelf));
});

Expand Down

0 comments on commit f530464

Please sign in to comment.