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

Comment section: Use int for part hash. #10965

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 8 additions & 4 deletions browser/src/canvas/sections/CommentListSection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,8 @@ export class CommentSection extends app.definitions.canvasSectionObject {
// Make sure that comment is not transitioning and comment menu is not open.
var tempFunction = function() {
setTimeout(function() {
if (String(annotation.sectionProperties.container.dataset.transitioning) === 'true' || annotation.sectionProperties.contextMenu === true) {
if (annotation.sectionProperties.container && annotation.sectionProperties.contextMenu === true
) {
tempFunction();
}
else {
Expand Down Expand Up @@ -1305,8 +1306,11 @@ export class CommentSection extends app.definitions.canvasSectionObject {
}

public add (comment: any): cool.Comment {
if (!comment.sectionProperties)
comment = new cool.Comment(comment, comment.id === 'new' ? {noMenu: true} : {}, this);
if (!comment.sectionProperties) {
const temp = new cool.Comment(comment, comment.id === 'new' ? {noMenu: true} : {}, this);
temp.sectionProperties.data = comment;
gokaysatir marked this conversation as resolved.
Show resolved Hide resolved
comment = temp;
}

comment.sectionProperties.noMenu = comment.sectionProperties.data.id === 'new' ? true : false;

Expand Down Expand Up @@ -1751,7 +1755,7 @@ export class CommentSection extends app.definitions.canvasSectionObject {
private adjustCommentFileBasedView (comment: any): void {
// Below calculations are the same with the ones we do while drawing tiles in fileBasedView.
var partHeightTwips = app.map._docLayer._partHeightTwips + app.map._docLayer._spaceBetweenParts;
var index = app.impress.getIndexFromSlideHash(comment.parthash);
var index = app.impress.getIndexFromSlideHash(parseInt(comment.parthash));
gokaysatir marked this conversation as resolved.
Show resolved Hide resolved
var yAddition = index * partHeightTwips;
comment.yAddition = yAddition; // We'll use this while we save the new position of the comment.

Expand Down
4 changes: 2 additions & 2 deletions browser/src/canvas/sections/CommentSection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class Comment extends CanvasSectionObject {
this.sectionProperties.showSelectedCoordinate = true; // Writer.

if (app.map._docLayer._docType === 'presentation' || app.map._docLayer._docType === 'drawing') {
this.sectionProperties.parthash = this.sectionProperties.data.parthash;
this.sectionProperties.parthash = parseInt(this.sectionProperties.data.parthash);
Copy link
Contributor

Choose a reason for hiding this comment

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

if parthash inside data should be always a number, shouldn't we do it once when we receive that data and assign to sectionProperties? so we don't have to convert again.
Can we have number type assigned to it so TS compiler will warn about incorrect usage?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is the right place. This is constructor and sectionProperties.data is an input parameter.

this.sectionProperties.partIndex = app.impress.getIndexFromSlideHash(this.sectionProperties.parthash);
}

Expand Down Expand Up @@ -736,7 +736,7 @@ export class Comment extends CanvasSectionObject {
if (this.sectionProperties.data.rectangle === null)
return;

const showMarker = app.impress.partList[app.map._docLayer._selectedPart].hash === parseInt(this.sectionProperties.data.parthash) ||
const showMarker = app.impress.partList[app.map._docLayer._selectedPart].hash === this.sectionProperties.data.parthash ||
app.file.fileBasedView;

this.sectionProperties.commentMarkerSubSection = new CommentMarkerSubSection(
Expand Down