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

feat: servers, projects, dbs, activation and deactivation, metadata overhaul #1347

Open
wants to merge 39 commits into
base: main
Choose a base branch
from

Conversation

PeterBaker0
Copy link
Contributor

@PeterBaker0 PeterBaker0 commented Feb 27, 2025

feat: servers, projects, dbs, activation, metadata overhaul

Description

Completely overhauls the app's handling of

  • listings (now called servers)
  • projects (i.e. surveys, notebooks etc)
  • activation
  • local DBs, syncs and remote DBs
  • sync attachments setting
  • notebook metadata
  • notebook ui spec

Does this by building from the ground up a redux-store slice named 'projects' which manages all of this.

It does this through a combination of

  • persisted serialisable state (for servers, projects, config etc)
  • services which index in-memory instantiated objects which don't persist through app refresh and are not serialisable (e.g. pouch DB, pouch sync, compiled UI specs (since these have JS in them))
  • reducers which act on the state, handling side effects where appropriate (e.g. activateProject is a single well defined action which does everything in one place)
  • asynchronous thunks which, in one place, handle interacting with the APIs to merge details into the existing store, overwriting and even updating connection details on live DBs where suitable
  • selectors which help with finding the right part of the state

Uses redux-persist to store data in local storage (works on all platforms). Expands the initialisation gate to safely dispatch all restore ops (e.g. generating DBs based on config, compiling UI specs) before the app loads.

Removes all DB sync/events logic - this could have implications for one spot I could see which is the auto head merging occurring to presumably minimise conflicts(?). I tested conflicts and it still seemed to work - so unsure what this actually does.

Also did a bunch of misc tidy up while deep in the code, including stripping out the annoying 'split project' vs 'unique project' etc etc which is not necessary - the app now knows which server a project refers to in all places and where only a project ID was available, I supplemented the routes to include the server ID.

Removes the metadata-db (there was no need for this to be a database, its just a static set of key value pairs which are one way sync'd from the API).

New features

  • deactivation
  • proper handling of stop/resume sync

TODO

  • fix unit tests (for API at least. probably data model too)
  • (deferred) migration approach
  • (ongoing) thorough testing
  • (deferred) conflict investigation
  • (deferred) replace instances of return <></> with a suitable real return value
  • linting
  • createdAt and lastUpdated properties of Project
  • isSyncing - what happens when you disable this?

How to Test

Test the entire app! There will be bugs.

Checklist

  • I have confirmed all commits have been signed.
  • I have added JSDoc style comments to any new functions or classes.
  • Relevant documentation such as READMEs, guides, and class comments are updated.

Signed-off-by: Peter Baker <peter.baker122@csiro.au>
Signed-off-by: Peter Baker <peter.baker122@csiro.au>
Signed-off-by: Peter Baker <peter.baker122@csiro.au>
Signed-off-by: Peter Baker <peter.baker122@csiro.au>
Signed-off-by: Peter Baker <peter.baker122@csiro.au>
Signed-off-by: Peter Baker <peter.baker122@csiro.au>
Signed-off-by: Peter Baker <peter.baker122@csiro.au>
Signed-off-by: Peter Baker <peter.baker122@csiro.au>
…dependency

Signed-off-by: Peter Baker <peter.baker122@csiro.au>
Signed-off-by: Peter Baker <peter.baker122@csiro.au>
Signed-off-by: Peter Baker <peter.baker122@csiro.au>
Signed-off-by: Peter Baker <peter.baker122@csiro.au>
…edux store should not directly hold non-serializable instances.

Signed-off-by: Peter Baker <peter.baker122@csiro.au>
Signed-off-by: Peter Baker <peter.baker122@csiro.au>
Signed-off-by: Peter Baker <peter.baker122@csiro.au>
Signed-off-by: Peter Baker <peter.baker122@csiro.au>
Signed-off-by: Peter Baker <peter.baker122@csiro.au>
…etween app vs api storage

Signed-off-by: Peter Baker <peter.baker122@csiro.au>
Signed-off-by: Peter Baker <peter.baker122@csiro.au>
Signed-off-by: Peter Baker <peter.baker122@csiro.au>
… with force

Signed-off-by: Peter Baker <peter.baker122@csiro.au>
Signed-off-by: Peter Baker <peter.baker122@csiro.au>
Signed-off-by: Peter Baker <peter.baker122@csiro.au>
Signed-off-by: Peter Baker <peter.baker122@csiro.au>
Signed-off-by: Peter Baker <peter.baker122@csiro.au>
Signed-off-by: Peter Baker <peter.baker122@csiro.au>
@PeterBaker0 PeterBaker0 removed the draft label Feb 28, 2025
Signed-off-by: Peter Baker <peter.baker122@csiro.au>
Signed-off-by: Peter Baker <peter.baker122@csiro.au>
Signed-off-by: Peter Baker <peter.baker122@csiro.au>
…chments - clarify naming

Signed-off-by: Peter Baker <peter.baker122@csiro.au>
Signed-off-by: Peter Baker <peter.baker122@csiro.au>
@PeterBaker0 PeterBaker0 changed the title feat: servers, projects, dbs, activation, metadata overhaul feat: servers, projects, dbs, activation and deactivation, metadata overhaul Mar 1, 2025
Signed-off-by: Peter Baker <peter.baker122@csiro.au>
Signed-off-by: Peter Baker <peter.baker122@csiro.au>
Copy link
Contributor

@stevecassidy stevecassidy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glorious! Well done. Only serious concern is about deleting databases on deactivation. A few minor comments.

Signed-off-by: Peter Baker <peter.baker122@csiro.au>
…th Object.values

Signed-off-by: Peter Baker <peter.baker122@csiro.au>
Signed-off-by: Peter Baker <peter.baker122@csiro.au>
Signed-off-by: Peter Baker <peter.baker122@csiro.au>
Signed-off-by: Peter Baker <peter.baker122@csiro.au>
@stevecassidy
Copy link
Contributor

Tests fine on IOS - no problem pointing it to existing server. One final suggestion - a confirmation dialog on deactivation might be good to prevent accidental button pushes.

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.

2 participants