VirtusLab-Open-Source / strapi-plugin-comments

A plugin for Strapi Headless CMS that provides end to end comments feature with their moderation panel, bad words filtering, abuse reporting and more.
MIT License
405 stars 63 forks source link

Cannot read properties of undefined (reading 'id') #187

Closed themtaysw closed 1 year ago

themtaysw commented 1 year ago

Whenever I try to display a thread by clicking a button with eye icon (Drirrdown) I am left with blank white screen. The error in console says:

TypeError: Cannot read properties of undefined (reading 'id') at I (main.8ae5fa74.js:2762:2575) at Xu (main.8ae5fa74.js:3682:55163) at Kc (main.8ae5fa74.js:3686:9219) at Tc (main.8ae5fa74.js:3686:996) at _u (main.8ae5fa74.js:3686:924) at vs (main.8ae5fa74.js:3686:774) at Wo (main.8ae5fa74.js:3684:11323) at main.8ae5fa74.js:3682:39858 at n.unstable_runWithPriority (main.8ae5fa74.js:3728:3787) at Vs (main.8ae5fa74.js:3682:39632) and the next one is the same: main.8ae5fa74.js:2762 Uncaught TypeError: Cannot read properties of undefined (reading 'id') at I (main.8ae5fa74.js:2762:2575) at Xu (main.8ae5fa74.js:3682:55163) at Kc (main.8ae5fa74.js:3686:9219) at Tc (main.8ae5fa74.js:3686:996) at _u (main.8ae5fa74.js:3686:924) at vs (main.8ae5fa74.js:3686:774) at Wo (main.8ae5fa74.js:3684:11323) at main.8ae5fa74.js:3682:39858 at n.unstable_runWithPriority (main.8ae5fa74.js:3728:3787) at Vs (main.8ae5fa74.js:3682:39632)

I didnt do any modifications to the plugin, only using as-is. My config: (maybe my config is wrongly done idk) comments: { enabled: true, config: { entryLabel: { "*": ["Title", "title", "Name", "name", "Subject", "subject"], "api::post.post": ["Comment"], "api::video.video": ["Comment"], "api::short.short": ["Comment"], }, reportReasons: { BAD_LANGUAGE: "BAD_LANGUAGE", }, }, },

Any help please?

cyp3rius commented 1 year ago

@themtaysw thanks for reporting this issue. Are you able to provide more details about your setup?

  1. Environment (node js version, database type and version)
  2. Screenshot of Settings->Comments->Configuration
themtaysw commented 1 year ago

yes yes so my env: ❯ yarn -v 1.22.19 ❯ node -v v16.12.0 "strapi-plugin-comments": "^2.2.4"

Screenshot 2023-02-01 at 8 42 03
cyp3rius commented 1 year ago

Settings looks legit. Which DB you're using? And if I can ask you for example payload for comment response you're POST'ing. Maybe comments are not properly nested so drilldown fails.

themtaysw commented 1 year ago

So I am using MariaDB 10.5. and the payload is:

{content: "test thread",…} author : {id: 1, firstname: "Matej", lastname: "LN", username: "usrname, email: "email@email.com",…} blocked : false createdAt : "2022-02-19T16:35:31.380Z" email : "email" firstname : "Matej" id : 1 isActive : true lastname : "LN" preferedLanguage : "en" updatedAt : "2022-07-10T08:50:55.717Z" username : "username" content : "test thread"

(i edited the personal data)

edit: so far i have been only adding comments from within the admin panel. I didnt code the option to add replies from users app yet

cyp3rius commented 1 year ago

Ah you see, adding comments via admin Panel is not a way here because of custom logic for POST/PUT endpoints of the plugin exposed on client end.

That seems a reason of. Have you added them directly from the Moderation Panel via admin response (should not be possible) or using the Collections?

themtaysw commented 1 year ago
Screenshot 2023-02-01 at 9 07 43

i clicked this 😅

cyp3rius commented 1 year ago

So seems something fails in admin response ;) Let us investigate your issue.

cyp3rius commented 1 year ago

Fixed in v2.2.5

themtaysw commented 1 year ago

thanks really much❤️working now