-
Notifications
You must be signed in to change notification settings - Fork 23
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 Tracker: Fix edited comment appears as read instead of unread #1773
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Finally got around to it, just a few comments.
if (!author) { | ||
return; | ||
return {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This messes with the logic, because of:
comment = await this.comments_getInfo(
matches[i],
Scope.current?.sourceLink || sourceLink,
endless ? this.esgst.users : JSON.parse(getValue('users')),
main
);
if (comment) {
comments.push(comment);
}
So the empty object will be added to the array and might cause issues with features that rely on this array for actual comment objects.
Better to return null
instead.
comment.actions = element; | ||
} | ||
if (!comment.actions) { | ||
return {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to return null
instead.
return comment; | ||
} | ||
} | ||
return {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to return null
instead.
for (let i = matches.length - 1; i >= 0; --i) { | ||
if (!sourceLink) { | ||
continue; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't make much sense here, because sourceLink
is queried outside of the loop, so if it doesn't exist, we can return before the loop instead of evaluating it again for each match.
However, I'm not sure that it's a good idea to add this check, as I'm not sure that sourceLink
will always exist. This might break the feature in some places. Better to make sourceLink
accept HTMLElement | undefined
.
element = comment.comment.parentElement; | ||
if (element) { | ||
comment.parent = element; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
element = comment.comment.parentElement
would already receive either an HTMLElement
or null
, so there's no need to assign it under a conditional.
element = comment.comment.querySelector('.comment__summary, .comment_body'); | ||
if (element) { | ||
comment.summary = element; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment.summary = comment.comment.querySelector('.comment__summary, .comment_body')
would already receive either an HTMLElement
or undefined
, so there's no need to assign it under a conditional.
element = comment.comment.querySelector('.comment__display-state, .comment_body_default'); | ||
if (element) { | ||
comment.displayState = element; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment.displayState = comment.comment.querySelector('.comment__display-state, .comment_body_default')
would already receive either an HTMLElement
or undefined
, so there's no need to assign it under a conditional.
.replace(/[^A-Za-z]/g, '') | ||
.match(/^(havea|takea|thanksand|thankyou)?bump(ing|ity|o)?$/i); | ||
if (reMatches) { | ||
comment.bump = reMatches; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment.bump
would already receive null
if there are no matches, so there's no need to assign it under a conditional.
element = comment.comment.querySelector('.comment__actions, .action_list'); | ||
if (element) { | ||
comment.actions = element; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment.actions = comment.comment.querySelector('.comment__actions, .action_list')
would already receive either an HTMLElement
or undefined
, so there's no need to assign it under a conditional.
Steps to reproduce:
https://www.steamgifts.com/go/comment/vYbrsc9
Actual results:
about:debugging#/runtime/this-firefox
browser.storage.local.get('discussions').then((item) => {console.log(JSON.parse(item.discussions)['tnWVh'].readComments['vYbrsc9'])})
1688003432
is returned1688003432
and the edited timestamp is1688154585
.Expected results:
In this PR, I would like to add the following changes: