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

Take into account the current user for message displaying #61

Merged
merged 3 commits into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 2 additions & 2 deletions src/annotation/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ export const Annotation = (props: IProps): JSX.Element => {
}}
/>
<div style={{ paddingBottom: 10, maxHeight: 400, overflow: 'auto' }}>
{contents.map((content, index) => {
{contents.map(content => {
return (
<Message
user={content.user}
message={content.value}
index={index}
martinRenou marked this conversation as resolved.
Show resolved Hide resolved
self={model.user?.username === content.user?.username}
/>
);
})}
Expand Down