lemmy
lemmy copied to clipboard
Add ability to save draft
Add the necessary backend changes to enable saving of unpublished/unsent messages, for posts/comments as well as private messages.
This feature is directly related to this FR for the UI: Add ability to save draft: https://github.com/LemmyNet/lemmy-ui/issues/1180
#3069 might require a similar DB structure to be added.
I'd be happy to have a go at this if no one else has already claimed it. I've started putting something together at https://github.com/rosalogia/lemmy/tree/add_drafts. I can make a PR if/when others would like for ease of viewing. It's my understanding that creating what's more or less a subset of the Post table for storing Drafts (without columns for things like time posted, locked, deleted, etc.), and then implementing some CRUD routes in the API for managing drafts should be more or less enough here? Correct me if I'm wrong or am misguided.
@rosalogia I'm not a developer here, and I do not know the DB structure exactly, but I have some knowledge about databases. In order to make it as efficient as possible, I would assess in which way the DB is going to be used. Meaning, whatever functionality that related ticket on the UI will bring to plan will in the end influence the new DB structures. I will add some more detailed suggestions to https://github.com/LemmyNet/lemmy-ui/issues/1180 .
The main (and perhaps most DB-intensive) action will probably be writing comments directly in the comment tree, then saving, and later re-loading the comment tree. Then, as there are drafts in that tree, we'd have a button at the comment which is being replied to, in order to continue editing, or we could have the editor load automatically in that spot.
With this procedure, we would have to retrieve information about the presence of drafts every time a comment tree is loaded. Having the drafts in a separate table however, will make for at least one more select operation and an additional effort to sort those drafts into their places within the tree.
So by making that thought experiment, I already get some clue that I could perhaps make it tremendously more efficient if I'd just add an "isdraft" flag to the Post table. That way I would make the draft(s) sort naturally into the tree, without much additional computation.
The other operations will likely be done from the "messages" pane (private message as well as comments), but those selects will probably be less demanding.
But edit, one more time, just to make sure i will not get torn apart here. 😬 I really have no exact idea about the DB structure. There are other things to consider as well, like not federating drafts and such. Also, all that select-by-post-and-user/order-by-comment logic might be already in place -- perhaps with the handling of votes, idk. -- In such a case it might be efficient to handle the new data structure together with that, and so on. Query cache-ability is also a thing to consider. ... All I want to really suggest by heart, is to make the thing much more time- and energy-efficient than what it currently appears to be. Doesn't matter if a handful of developers spend some days ironing out the software, if it in the long run saves tremendous amounts of user lifetime and tons of CO2.
Lets try to implement drafts for comments before Reddit does it
I thought about this and really dont think its worth the effort. If you want to write a draft, you can already do it in the text/markdown editor of your choice. Implementing this in Lemmy would be a lot of work as it would essentially require separate implementations for post draft, comment draft and private message draft.