alientube
alientube copied to clipboard
Cannot post comment: Cannot read property 'commentThread' of undefined
Hi,
When I try to make a top level comment on this video to /r/roadcams (the only subreddit showing op for this video) it doesn't get posted.
The error in chrome console is this
Code
Uncaught TypeError: Cannot read property 'commentThread' of undefined
(anonymous function) @ script.js:1676
(anonymous function) @ script.js:328
This is the script that errors (lines 1673 to 1677)
Code
/* Send the comment to Reddit */
new AlienTube.Reddit.CommentRequest(thing_id, inputField.value, function (responseText) {
var responseObject = JSON.parse(responseText);
var comment = new AlienTube.Comment(responseObject.json.data.things[0].data, this.commentThread); //this.commentThread is undefined, causing the error
this.parentClass.children.push(comment);
Steps to reproduce:
- Goto the video
- Attempt to post a top level comment
I have tried relogging and reinstalling the extension
Update: Apparently alientube does post the comments. It's just not displaying (refreshing) correctly.
I also have this problem.
I have partly figured out what is going on. I am not proficient enough to fix it.
The code:
/* Send the comment to Reddit */
new AlienTube.Reddit.CommentRequest(thing_id, inputField.value, function (responseText) {
var responseObject = JSON.parse(responseText);
var comment = new AlienTube.Comment(responseObject.json.data.things[0].data, this.commentThread);
this.parentClass.children.push(comment);
/* Find the correct insert location and append the new comment to DOM */
if (this.parentClass instanceof AlienTube.CommentThread) {
this.parentClass.threadContainer.appendChild(comment.representedHTMLElement);
new CommentField(this.parentClass);
}
else {
this.parentClass.representedHTMLElement.querySelector(".at_replies").appendChild(comment.representedHTMLElement);
}
this.parentClass.children.push(comment);
/* Scroll the new comment in to view */
comment.representedHTMLElement.scrollIntoView(false);
/* The comment box is no longer needed, remove it and clear outselves out of memory */
this.representedHTMLElement.parentNode.removeChild(this.representedHTMLElement);
});;
The code sets up a function with this code:
new AlienTube.Reddit.CommentRequest(thing_id, inputField.value, function (responseText) {
});
With in this scope
function (responseText) {
});
you can not call this
as it is undefined in that scope.