Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MMB-178] Add members namespace #101

Merged
merged 6 commits into from
Aug 8, 2023
Merged

Conversation

dpiatek
Copy link
Contributor

@dpiatek dpiatek commented Aug 3, 2023

Add a new members namespace, as per MMDR14.

To make this possible, a new for managing presence state was introduced. Internally, all messages now need to replay a members state, and "touch" updates which are new. On the subscriber side, all updates are applied, but only the "touched" updates get emitted as events.

This is first stage of a move towards not using a "shadow" presence set and having consistent, internal "update presence" API for spaces (it's fairly manual right now).

A couple of clean up tasks have been done as well:

  • removed the mock-server tests, as they didn't deliver the value we hoped they would
  • renamed mockClient tests to just test.ts
  • cleaned up constants which have much less use with our TS typings
  • removed the option to initiate with an internal client
  • ...and many more small improvements

This PR does not contain a docs update and will be part of a bigger release.

src/Locations.ts Show resolved Hide resolved
@lmars lmars mentioned this pull request Aug 3, 2023
@dpiatek dpiatek force-pushed the mmb-178-add-members-namespace branch 3 times, most recently from 2ae176d to c89efe6 Compare August 3, 2023 14:19
@dpiatek dpiatek marked this pull request as ready for review August 3, 2023 14:19
@dpiatek dpiatek force-pushed the mmb-178-add-members-namespace branch 2 times, most recently from f0c71fa to 9d0e6e1 Compare August 3, 2023 14:33
@dpiatek dpiatek self-assigned this Aug 3, 2023
Copy link
Member

@lmars lmars left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

src/Locations.ts Outdated Show resolved Hide resolved
Dominik Piatek added 4 commits August 8, 2023 09:05
These are split into an external and internal ones, the latter being ones that we might want to change without introducing breaking changes.
Update as newer types were incompatible.
These tests add significant complexity to setup, and don't bring enough value on contrast to the mock tests.
@dpiatek dpiatek force-pushed the mmb-178-add-members-namespace branch from 490ecc4 to d4d0013 Compare August 8, 2023 07:12
Dominik Piatek added 2 commits August 8, 2023 09:15
This commit changes how we handle updates for presence spaces. An presence update becomes a PresenceMember:

export type PresenceMember = {
  data: {
    profileUpdate: {
      id: string | null;
      current: ProfileData;
    };
    locationUpdate: {
      id: string | null;
      previous: unknown;
      current: unknown;
    };
  };
} & Omit<Types.PresenceMessage, 'data'>;

Which then gets translated for the developer to a SpaceMember:

export type SpaceMember = {
  clientId: string;
  connectionId: string;
  isConnected: boolean;
  profileData: ProfileData;
  location: unknown;
  lastEvent: {
    name: Types.PresenceAction;
    timestamp: number;
  };
};

data on PresenceMember contains the last update for profileData an location. The current key is the value of these properties on SpaceMember.

profileUpdate and locationUpdate contain an id. This id is set on publish, but only when we are providing new data, not copying already set data.
The handlers check the id to decide if an update should be emitted (it will still be applied, and it should be the same).
@dpiatek dpiatek force-pushed the mmb-178-add-members-namespace branch from d4d0013 to 33c5990 Compare August 8, 2023 07:16
@dpiatek dpiatek merged commit f900c7d into main Aug 8, 2023
5 checks passed
@dpiatek dpiatek deleted the mmb-178-add-members-namespace branch August 8, 2023 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants