alientube icon indicating copy to clipboard operation
alientube copied to clipboard

Cannot post comment: Cannot read property 'commentThread' of undefined

Open Fastjur opened this issue 8 years ago • 2 comments

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 Image 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) selection_021 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:

  1. Goto the video
  2. Attempt to post a top level comment

I have tried relogging and reinstalling the extension

Fastjur avatar Mar 09 '16 10:03 Fastjur

Update: Apparently alientube does post the comments. It's just not displaying (refreshing) correctly.

image

Fastjur avatar Mar 09 '16 10:03 Fastjur

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.

xentan avatar Jun 22 '16 20:06 xentan