Skip to content
This repository has been archived by the owner on Jul 29, 2023. It is now read-only.

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

Open
Fastjur opened this issue Mar 9, 2016 · 2 comments
Open
Assignees
Labels

Comments

@Fastjur
Copy link

Fastjur commented Mar 9, 2016

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
Copy link
Author

Fastjur commented Mar 9, 2016

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

image

@xentan
Copy link

xentan commented Jun 22, 2016

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.

@SuperManifolds SuperManifolds self-assigned this Dec 30, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants