Closed kiznick closed 1 year ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated |
---|---|---|---|---|
thread-gpt | ✅ Ready (Inspect) | Visit Preview | 💬 Add your feedback | Mar 11, 2023 at 6:49AM (UTC) |
@kiznick IMO the thread doesn’t need to know its parent. Here’s how I might implement the feature:
The parent can pass a prop onTweak: (messageToTweak: ThreadNode['message']) => void
to the children. Similar to how it passes a removeSelf
function here
Then in the children, when the “Tweak” menu item is clicked it can invoke the passed onTweak
prop. The onTweak handler can then copy the messageToTweak
into the CreateForm
.
Note that when tweaking a message, it’s supposed to create a copy in the parent.
However, note that once a message is created, it cannot be changed. So it may be enough to just copy the base message into the parent’s CreateForm.
Now, I can add Tweak message to parent, thanks to @dtinth, but idk why new message not appear until refresh
Thanks for the implementation krub! 🙏
The addition of defaultValue
and defaultRole
to the form is very helpful.
To answer your question, when the parent is changed, the parent needs to call query.refetch()
to reload the new data from IndexedDB. (It requires coordination with parent component.)
I went ahead and made a few further changes on top:
parentId
to make the facilitation between different components easier.isTweak
which reduces the complexity of the code.Thanks for contributing krub!
This PR for #4
Now Tweak message is working but I don't know how to find parent node This is my solution 1) add key "parent" to db (it will make old data can't tweak) 2) loop to all record, For example I have to find T3-1's parent
I have to loop in root to check all threat name, if not found I need to loop in every root's child to find T3-1
Do you have any other suggestions or which method should I use?