Skip to content

Commit

Permalink
Merge pull request #263 from jtpio/rtc-colors-usernames
Browse files Browse the repository at this point in the history
Add RTC colors and usernames
  • Loading branch information
jtpio committed Jul 15, 2021
2 parents 15f2c0f + 23436d5 commit d0aafc4
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/application-extension/src/index.tsx
Expand Up @@ -16,7 +16,9 @@ import { IDocumentManager } from '@jupyterlab/docmanager';
import {
IDocumentProvider,
IDocumentProviderFactory,
ProviderMock
ProviderMock,
getAnonymousUserName,
getRandomColor
} from '@jupyterlab/docprovider';

import { IFileBrowserFactory } from '@jupyterlab/filebrowser';
Expand Down Expand Up @@ -47,6 +49,16 @@ class WebRtcProvider extends WebrtcProvider implements IDocumentProvider {
constructor(options: IDocumentProviderFactory.IOptions & { room: string }) {
super(`${options.room}${options.path}`, options.ymodel.ydoc);
this.awareness = options.ymodel.awareness;
const color = `#${getParam('--usercolor', getRandomColor().slice(1))}`;
const name = getParam('--username', getAnonymousUserName());
const currState = this.awareness.getLocalState();
// only set if this was not already set by another plugin
if (currState && !currState.name) {
this.awareness.setLocalStateField('user', {
name,
color
});
}
}

setPath() {
Expand Down

0 comments on commit d0aafc4

Please sign in to comment.