When writing to the normalized cache (record), it's crucial to use _refs
for relationships to avoid many problems. Essentially, we only deal with
level 0 and generate all fields to be comfortable with their defaults.
When writing in queries (which should be very rare, the only cases are
prefetch and the case of activities due to the nested query; I've
reduced this to a single file for activities
usePrepareFindManyActivitiesQuery 🙂), it's important to use queryFields
to avoid bugs. I've implemented them on the side of query generation and
record generation.
When doing an updateOne / createOne, etc., it's necessary to distinguish
between optimistic writing (which we actually want to do with _refs) and
the server response without refs. This allows for a clean write in the
optimistic cache without worrying about nesting (as the first point).
To simplify the whole activities part, write to the normalized cache
first. Then, base queries on it in an idempotent manner. This way,
there's no need to worry about the current page or action. The
normalized cache is up-to-date, so I update the queries. Same idea as
for optimisticEffects, actually.
Finally, I've triggered optimisticEffects rather than the manual update
of many queries.
---------
Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
* on click focus on activity body editor
* acitivity editor hot key scope added
* classname prop added escape hot key scope call back added
* passing containerClassName prop for activity editor
* hot key scope added
* console log cleanup
* activity target escape hot key listener added
* tasks filter hot key scope refactor
* scope renaming refactor
* imports order linting refactor
* imports order linting refactor
* acitivity editor field focus state and body editor text listener added
* logic refactor removed state for activity editor fields focus
* removed conflicting click handler of inline cell creating new scope
* linting and formatting
* acitivity editor field focus state and body editor text listener added
* adding text at the end of line
* fix duplicate imports
* styling: gap fix activity editor
* format fix
* Added comments
* Fixes
* Remove useListenClickOutside, state, onFocus and onBlur
* Keep simplifying
* Complete review
* Fix lint
---------
Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
Co-authored-by: Charles Bochet <charles@twenty.com>