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

Poems buffer #21

Open
pokeghosst opened this issue Jun 24, 2024 · 0 comments
Open

Poems buffer #21

pokeghosst opened this issue Jun 24, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@pokeghosst
Copy link
Owner

pokeghosst commented Jun 24, 2024

1. Saving new poem

  1. User initiates saving the poem.
  2. The poem is saved with the local storage driver.
  3. The poem is saved to the buffer storage with Capacitor Filesystem interface.

Doing so allows us to: (1) keep the same interface for all platforms and (2) on Android, buffered poems will be saved to the device's storage instead of IndexedDB, which can be cleared by the OS.

The buffered poem is serialized with JSON and has the following structure:

{
   "id": "URI (for filesystem) or ID (for cloud providers)",
   "name": "String",
   "timestamp": "Number",
   "unsavedChanges": "Boolean",
   "poem": {
      "text": "String",
      "note": "String"
   }
}

2. Loading the list of poems

  1. Read the poem directory.
  2. For each entry in the poem directory:
    2.1. If a buffered poem with the corresponding URI exists, continue.
    2.2. If there's no buffered poem for the URI, read the file and save it to the buffered poem.
  3. Render the list of poems from the buffer, ordered by timestamp. Display name, preview of the poem text, and a marking that shows whether this poem has unsaved changes.

3. Loading individual poem

  1. User clicks the poem to navigate to.
  2. Load the poem from the buffer.
    2.1. If there are unsaved changed, display appropriate indication.
  3. Render the poem.

In this way, we always interact with the poem directory through the buffer abstraction.

4. Editing previously saved poem

  1. User navigates to the required poem.
  2. Similarly to the draft, all changes are saved to the buffered poem on the fly.
    2.1. Since we're working directly with the filesystem, the saving operation is debounced.
    2.2. Depending on the debounce time, a flag preventing user from navigating away has to be added. If the changes haven't been written yet, show alert asking user to wait.
  3. If there are no unsaved changes, user saves the poem.
    3.1. The poem is updated.
    3.2. The buffered poem is updated.
  4. If there are unsaved changes, user can accept or discard them.
    4.1. If the user accepts the changes, the poem is updated with contents of the buffer and the status of the buffer is updated (no more unsaved changes). Optionally, user can make changed to the buffered version.
    4.2. If the user discards the buffered version, the original poem is loaded and the buffered version is updated along with its status.

5. Deleting the poem

  1. User initiates deleting the poem.
  2. The poem is deleted.
  3. The buffered poem is deleted.
@pokeghosst pokeghosst added the enhancement New feature or request label Jun 24, 2024
@pokeghosst pokeghosst self-assigned this Jun 24, 2024
@pokeghosst pokeghosst changed the title WIP: Local copy of poem list with unsaved changes Jun 27, 2024
@pokeghosst pokeghosst changed the title WIP: Poems buffer Jun 27, 2024
@pokeghosst pokeghosst added the WIP Working on defining the issue, not ready for development label Jun 27, 2024
@pokeghosst pokeghosst removed the WIP Working on defining the issue, not ready for development label Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
1 participant