Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Losing draft posts since it stores multiple draft posts in the same auto-saved value in Local Storage when you draft multiple posts in parallel that may be from different Spaces #295

Open
ltfschoen opened this issue Feb 24, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@ltfschoen
Copy link
Contributor

Current Behavior:

If you are drafting multiple Posts under the same or different Spaces that you haven't published yet in different browser tabs, they all auto-save to the same value in Local Storage, so if you lose your connection, you'll only be able to recover the draft post that you last modified

Expected Behavior:

It should store each post in Local Storage under a Space + Post key, instead of just storing them all in the same place, so if you'll be able to recover multiple draft Posts each from the same or a different Space

Steps To Reproduce:

Refer to the "How to find out what is auto-saved in Local Storage if you draft two posts in parallel that use a different Space?" section in this post https://polkaverse.com/12864/how-to-avoid-losing-your-draft-posts-on-polka-verse-74158

Environment

@ltfschoen ltfschoen added the bug Something isn't working label Feb 24, 2024
@olehmell
Copy link
Contributor

Hello! Thanks for the report!

Tbh Polkaverse doesn't have the functionality of multiple drafts of posts yet.

I know how we can add one draft for each location. Will this be enough for you?

@teodorus-nathaniel
Copy link
Contributor

What I'm thinking of is having 1 draft for each type of editor
Right now we have modal editor (the popup one, which appears whether you click "New Post" or "Write Something...") and full editor

So I think it would make better sense to do these 2 things:

  1. Save content of modal editor in separate localstorage key
  2. Make modal editor loads the draft instead of having blank editor each time

What do you think? Will that solves the issue?

@ltfschoen
Copy link
Contributor Author

ltfschoen commented Feb 27, 2024

I think the all the following things have to be done:

1. Rename "Write Something..." to "Write New Post..."

2a.

  • If the user clicks "New Post" in the header, then default to using the SPACE_ID of their Profile Space, which it already does, but store that value of new post under the appropriate Key "ACCOUNT_ID-SPACE_ID" in local storage, where ACCOUNT_ID is the SS58 account address of the current user, and:
    • Update the routes so that the URL shows the RESTful route for Creating a post that has this pattern (that creates new post in a specific space associated with the current account): https://polkaverse.com/accounts/<ACCOUNT_ID>/spaces/<SPACE_ID>`
  • If there is already an existing value stored under that Key "ACCOUNT_ID-SPACE_ID", then display an "Edit Post" button as well in the header, and if they click that it will restore the value stored in local storage under that Key "ACCOUNT_ID-SPACE_ID" associated with their Profile Space. Whereas if they click the "New Post" button in the header then it resets the value stored in local storage under that Key "ACCOUNT_ID-SPACE_ID" associated with their Profile Space, where ACCOUNT_ID is the SS58 account address of the current user.
  • Note: that way if they switch between accounts it stores the draft posts associated with each different account and doesn't overwrite them.

2b. If the user clicks the "Write Something..." (which is currently shown in My Feed section, and Posts), then default to using the SPACE_ID of their Profile Space, which it already does, but store the value of that new post under the appropriate Key "ACCOUNT_ID-SPACE_ID" in local storage as mentioned above in 1), where ACCOUNT_ID is the SS58 account address of the current user, and:

  • Update the routes so that the URL shows the RESTful route for Creating a post that has this pattern (that creates new post in a specific space associated with the current account): https://polkaverse.com/accounts/<ACCOUNT_ID>/spaces/<SPACE_ID>`

3. If the user goes to My Spaces, where it lists their spaces, and they click the menu of a specific Space (i.e. their Profile space or one of their other Custom spaces) and choose "Write Post", then using the SPACE_ID of the specific space that they chose to create the post within, then default to using their Profile Space, which it already does, but store that new post under the appropriate Key "ACCOUNT_ID-SPACE_ID" in local storage as mentioned above in 1), where ACCOUNT_ID is the SS58 account address of the current user, and:

  • Update the routes so that the URL shows the RESTful route for Creating a post that has this pattern (that creates new post in a specific space associated with the current account): https://polkaverse.com/accounts/<ACCOUNT_ID>/spaces/<SPACE_ID>`

4. If the user goes to My Spaces, where it lists their spaces, and they click the menu of a specific Space (i.e. their Profile space or one of their other Custom spaces), then we want the user to have an extra item called "Edit Post" to be shown, but only if there is a Key "ACCOUNT_ID-SPACE_ID" in local storage where that ACCOUNT_ID matches the current user, and the SPACE_ID matches the menu of the specific Space that they are interacting with, and:

  • Update the routes so that the URL shows the RESTful route for Editing a post that has this pattern (that edits an existing post of a specific space associated with the current account by restoring the value stored under that Key in local storage): https://polkaverse.com/accounts/<ACCOUNT_ID>/spaces/<SPACE_ID>`.
  • Note: Despite what I mentioned previously here about having a different route for editing a draft post, I actually think that from the Single Responsibility Principle they share similar functionality of ultimately creating a post, only that we load the existing value from local storage if there is one if they click the "Edit Post" button.

@teodorus-nathaniel
Copy link
Contributor

Hey! thank you for the detailed explanation, but we are currently developing other big things 👀, so we will check this issue out after we finished the update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants