whtwnd / whitewind-blog

Repository to manage WhiteWind atproto blogging platform codes
GNU Affero General Public License v3.0
70 stars 6 forks source link

Fix duplicated or undeletable entry #23

Closed K-Nksm closed 1 month ago

K-Nksm commented 1 month ago

Currently, even when the page transition happens when the user creates or deletes an entry, the autosave timer is not cleared. Duplicated entry mechanism:

  1. Open editor to create a new entry
  2. Edit the content (starts autosave timer)
  3. Click floppy button (starts save sequence and calls createRecord)
  4. After saving, the page transition occurs
  5. After 10 sec from 2, autosave timer fires. The timer function does not know the newly given rkey. Therefore it calls createRecord, resulting in duplicated entry

Undeletable entry mechanism:

  1. Open editor to open an existing entry
  2. Edit something (starts autosave timer)
  3. Click delete
  4. After deleting, the page transition occurs
  5. After 10 sec from 2, autosave timer fires. This calls putRecord and deleted entry is recovered.

Furthermore, when there are duplicated entries and the user tries to resolve the rkey from entry name, the server-side remembers rkey of that entry because of cache mechanism of Next.js. If the user deletes that entry, the server still uses old name-rkey correspondence.

This PR addresses the problems above.