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

Add Comment#timestamp #58

Closed
wants to merge 1 commit into from
Closed

Add Comment#timestamp #58

wants to merge 1 commit into from

Conversation

rschnekenbu
Copy link

What it does

Add Comment#timestamp optional property
This adds the timeStamp optional property from Comment to improve vscode api coverage. It also displays the timestamp of each comments in the Comment Thread widget

Fixes eclipse-theia#11702

Contributed on behalf of ST Microelectronics

How to test

Note: there are currently some issues with menus, since theia 1.28.0. This is due to eclipse-theia#11290, integrated in 1.28.0. Prior to this change, the comment sample works on theia 1.27.0. So to test this change, I cherry-picked my commit on top of 1.27.0 tag. Please see also eclipse-theia#11730 for this menu issues.

  1. Install forked extension #comment-sample-0.0.1 vsix file

  2. Create a comment using the side bar while comparing 2 test files.
    addCommentTimeStamp

  3. The timestamp should be displayed along the user name.

Review checklist

Reminder for reviewers

@rschnekenbu
Copy link
Author

rschnekenbu commented Dec 6, 2022

As a note, the 4 first commits are commits on theia/master not yet available on eclipsesource/master. Only 2df36ae is relevant

@rschnekenbu rschnekenbu changed the title Issues/11702 Add Comment#timestamp Dec 6, 2022
if (timeStamp === undefined) {
return '';
}
return timeStamp.toLocaleDateString();
Copy link

@lucas-koehler lucas-koehler Dec 13, 2022

Choose a reason for hiding this comment

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

When I test this rebased onto v1.27.0, timestamp was already a string here. Thus, this method did not exist and an exception was thrown.
From the console:

comments-contribution.ts:114 Uncaught (in promise) TypeError: timeStamp.toLocaleDateString is not a function
    at ReviewComment.timeStamp (comment-thread-widget.tsx:504:26)
    at ReviewComment.render (comment-thread-widget.tsx:480:58)
    at finishClassComponent (react-dom.development.js:17160:1)
    at updateClassComponent (react-dom.development.js:17110:1)
    at beginWork (react-dom.development.js:18620:1)
    at HTMLUnknownElement.callCallback (react-dom.development.js:188:1)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:237:1)
    at invokeGuardedCallback (react-dom.development.js:292:1)
    at beginWork$1 (react-dom.development.js:23203:1)
    at performUnitOfWork (react-dom.development.js:22157:1)

@rschnekenbu
Copy link
Author

New 'basic' version of timestamp support using a string rather than a date.
Best would may be to develop a DateDTO, but currently Date is only used for Comment#timeStamp in the VS Code APIs.

Copy link

@lucas-koehler lucas-koehler left a comment

Choose a reason for hiding this comment

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

Showing the timestamp works now, thanks!
However, I think a better way to serialize the date is using the ISO date format instead of serializing the full JSON object.
See inline suggestions for changing this and other minor fixes

packages/plugin-ext/src/plugin/comments.ts Outdated Show resolved Hide resolved
packages/plugin-ext/src/plugin/comments.ts Outdated Show resolved Hide resolved
packages/plugin-ext/src/common/plugin-api-rpc-model.ts Outdated Show resolved Hide resolved
@rschnekenbu
Copy link
Author

Thanks for your review, @lucas-koehler. I tested again the branch on 1.27.0, the timestamp is still displayed with your last suggestions.
I can now push it to main repo.

@rschnekenbu rschnekenbu force-pushed the issues/11702 branch 2 times, most recently from 376dbca to 5d615cd Compare December 20, 2022 10:30
Contributed on behalf of STMicroelectronics

Fixes eclipse-theia#11702
@rschnekenbu
Copy link
Author

close PR as the one on main fork has been merged (eclipse-theia#12007)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[vscode] Support optional property Comment#timestamp
2 participants