Sync model mutations into shared universe state - #20
Merged
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR extends the “shared universe” Redux state so it stays in sync with legacy model-suite mutations (focus updates, project/model/modelview property updates, and model/modelview reordering) while preserving the existing legacy reducer/dispatch paths used by the GoJS/AKMM code.
Changes:
- Run the shared
universeReduceron every action and only fall back to rebuilding universe-from-legacy when the universe reducer does not handle the action. - Add shared-universe handling for legacy focus actions and selected model-suite mutation actions (
UPDATE_*_PROPERTIES,REORDER_*) by mutatingworld.worldModel.metisand (when applicable) focus. - Adjust
/modelusername fetching to avoid dispatchingsetUniverseUserwith potentially stalephUserstate.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/store.tsx |
Updates the root reducer to always reduce the shared universe state and rebuild-from-legacy only when needed. |
src/sharedUniverse/universeSlice.ts |
Adds handling to mirror legacy focus + model/modelview mutations into world.worldModel.metis (and focus when applicable). |
src/pages/model.tsx |
Refactors username fetch flow to stage the fetched name before dispatching setUniverseUser. |
Comment on lines
+325
to
+344
| if (action.type === 'UPDATE_MODEL_PROPERTIES' || action.type === 'UPDATE_TARGETMODEL_PROPERTIES') { | ||
| const metis = asRecord(state.world.worldModel.metis); | ||
| const models: any[] = Array.isArray(metis.models) ? metis.models : []; | ||
| if (!models.length) return state; | ||
|
|
||
| const patch = asRecord(action.data); | ||
| const modelIndex = findModelIndex(models, asRecord(state.world.focus), patch.id); | ||
| if (modelIndex < 0 || !models[modelIndex]) return state; | ||
|
|
||
| const nextModels = replaceArrayItem(models, modelIndex, { | ||
| ...models[modelIndex], | ||
| ...patch, | ||
| }); | ||
| const focus = updateFocusedItem(asRecord(state.world.focus), 'focusModel', patch); | ||
|
|
||
| return updateMetis(state, { | ||
| ...metis, | ||
| models: nextModels, | ||
| }, focus); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
universe.world.worldModel.metisfor project/model/modelview property updates and model/modelview reordering.Verification
npm run buildpassed.npm testpassed.Notes