Skip to content

Commit

Permalink
Take into account the current user for message displaying
Browse files Browse the repository at this point in the history
  • Loading branch information
martinRenou committed Dec 15, 2022
1 parent 82d32f1 commit 4f666a0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
17 changes: 14 additions & 3 deletions src/annotation/message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,32 @@ import { User } from '@jupyterlab/services';
import * as React from 'react';

interface IProps {
/*
* The message content.
**/
message: string;
index: number;

/*
* Whether the message was originated from the current user.
**/
self: boolean;

/*
* The user who originated the message.
**/
user?: User.IIdentity;
}

export const Message = (props: IProps): JSX.Element => {
const { index, message, user } = props;
const { self, message, user } = props;
const color = user?.color ?? 'black';
const author = user?.display_name ?? '';
const initials = user?.initials ?? '';
return (
<div
className="jcad-Annotation-Message"
style={{
flexFlow: index % 2 === 0 ? 'row' : 'row-reverse'
flexFlow: self ? 'row' : 'row-reverse'
}}
>
<div
Expand Down
6 changes: 6 additions & 0 deletions src/annotation/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface IAnnotation {
position: [number, number, number];
contents: IAnnotationContent[];
}

export class AnnotationModel {
constructor(options: AnnotationModel.IOptions) {
this._getCoordinate = options.getCoordinate;
Expand All @@ -25,9 +26,14 @@ export class AnnotationModel {
return this._updateSignal;
}

get user(): User.IIdentity | undefined {
return this._user;
}

update(): void {
this._updateSignal.emit(null);
}

getAnnotation(id: string): IAnnotation | undefined {
const rawData = this._sharedModel.metadata.get(id);
if (rawData) {
Expand Down
2 changes: 1 addition & 1 deletion src/annotation/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const Annotation = (props: IProps): JSX.Element => {
<Message
user={content.user}
message={content.value}
index={index}
self={model.user?.username === content.user?.username}
/>
);
})}
Expand Down

0 comments on commit 4f666a0

Please sign in to comment.