aptkingston / budibase-comment-box

A comment box component plugin for Budibase
15 stars 7 forks source link

Comment Box not visualizing _existing_ comment records supplied from a DB text field #13

Open aMacDawg opened 1 week ago

aMacDawg commented 1 week ago

Expected/desired outcome: As a Budibase user, I have a table that stores 'chat logs' that I would like to use the Budibase Comment Box for visualizing these logs as individual chats similar to how the conversation would be experienced by an end-user in a conventional chat/messneger application

Current outcome: no 'comments' or messages are displayed despite a table being connected specifically with a comment string/text field that stores (stringified) JSON that conforms to this schema:

{
  "message": "This is a sample comment.",
  "email": "user@example.com",
  "name": "John Doe",
  "timestamp": 1633036800000
}

Current outcome/test case 2: I attempted to submit a new comment into my connected postgres environment, but upon entering some text and clicking the post button, I didn't see any request attempt when simultaneously inspecting the dev console

Edit: clarifying the relational (postgres) DB table - currently I'm storing each "comment" as its own record in a table specifically for storing these comments/messages. The comment field maps to my understanding of the model as storing a single stringified JSON in the schema described above, the other fields of this chat_comment table are:

| id | created_at (timestamp) | conversation_id (convo id as written from application logic) | comment (string) |

I have the comment box nested in a Data Provider component that maps from the table and I filter on each conversation_id value since this comment box component is opened in a modal

aMacDawg commented 1 week ago

Okay, this is not a "ready to close and move on" comment just yet, but I was able to answer my own question with additional research.

tl;dr - the JSON strings are actually base64 encoded, and delimited by a | (not actually stored as an array of objects, which is uhh an interesting decision)

The Row ID seems pretty (annoyingly) stuck on the row id itself (a user would absolutely never want to dynamically assign which column to map to, that would be crazy) so I had to do some weird hacking and wrangling with my own data sandbox.

Hopefully helpful if/when this plugin ever gets worked on again

aptkingston commented 2 days ago

Glad you worked out the data structure! To be totally honest I can't remember why I opted to encode each comment individually. I might have been thinking about future enhancements, where doing it this way meant you'd be able to append comments without first having to read all comments, decode, append and encode again, but I genuinely can't remember. There was probably a reason!

Are you having any other issues displaying comments now that you've worked out the correct structure?