Skip to content

Save flow metadata fix#39

Open
diiviikk5 wants to merge 3 commits intoseetadev:mainfrom
diiviikk5:save-flow-metadata-fix
Open

Save flow metadata fix#39
diiviikk5 wants to merge 3 commits intoseetadev:mainfrom
diiviikk5:save-flow-metadata-fix

Conversation

@diiviikk5
Copy link
Copy Markdown

Summary

Refers to #38
This PR fixes local persistence reliability in the Ionic React app by making save flows async-safe and null-safe.

Changes

  • Govt-Billing-React/src/components/Menu/Menu.tsx
    • Made doSave async and awaited _getFile(...).
    • Preserved created timestamp and updated modified.
    • Added safe fallback toast on missing metadata/save failure.
    • Awaited _saveFile(...) in doSaveAs.
  • Govt-Billing-React/src/components/NewFile/NewFile.tsx
    • Made newFile async and awaited _getFile(...).
    • Added guard alerts for missing metadata/save failure.
  • Govt-Billing-React/src/components/Storage/LocalStorage.ts
    • Made _getFile null-safe for missing/invalid JSON.
    • Updated _getAllFiles to skip invalid entries.

Why

Previously, _getFile(...) promises were used like resolved objects in save flows, which could break metadata handling and lead to inconsistent file persistence.

Flow Diagram

flowchart TD
  subgraph Before
    A1[Save/New File] --> B1[_getFile returns Promise]
    B1 --> C1[Read data.created immediately]
    C1 --> D1[Invalid metadata may be written]
  end

  subgraph After
    A2[Save/New File] --> B2[await _getFile]
    B2 --> C2{Data valid?}
    C2 -- Yes --> D2[Preserve created, update modified]
    D2 --> E2[await _saveFile]
    C2 -- No --> F2[Show alert/toast and stop safely]
  end
Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant