-
Notifications
You must be signed in to change notification settings - Fork 7
fix: preserve intentionally cleared project metadata (#531-A) #546
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
502a4cf
fix: preserve intentionally cleared project metadata
qnbs 5b360d0
fix: keep imported projects out of fresh-user bootstrap
qnbs ba3ef47
fix: distinguish hydrated project seed authority
qnbs fc93320
fix: harden project bootstrap seed authority
qnbs 68ad9aa
test: cover project seed authority wiring
qnbs 890fd94
fix: validate persisted project bootstrap payload
qnbs a0acf4a
fix: normalize desktop project bootstrap data
qnbs b0286f0
fix: preserve canonical project hydration data
qnbs b9c5fba
chore: document hydration regression rationale
qnbs 312b96d
fix: preserve imported entity IDs during hydration
qnbs 6a22a62
fix: preserve prototype-safe imported entities
qnbs 86910a3
docs: document hydration helpers
qnbs 6edbb9f
fix: preserve prototype IDs through project imports
qnbs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,26 @@ | ||
| import type { EntityState } from '@reduxjs/toolkit'; | ||
| import { createEntityAdapter } from '@reduxjs/toolkit'; | ||
| import type { Character, World } from '../../types'; | ||
|
|
||
| export const charactersAdapter = createEntityAdapter<Character>(); | ||
| export const worldsAdapter = createEntityAdapter<World>(); | ||
| // QNBS-v3: the stable no-op comparer selects RTK's object-safe update path without changing entity insertion order. | ||
| const preserveEntityOrder = () => 0; | ||
|
|
||
| // QNBS-v3: imported string IDs must survive EntityState construction even when they collide with Object.prototype. | ||
| /** Builds a JSON-safe EntityState without treating prototype names as inherited properties. */ | ||
| export function createPrototypeSafeEntityState<T extends { id: string }>( | ||
| items: readonly T[], | ||
| ): EntityState<T, string> | undefined { | ||
| const ids: string[] = []; | ||
| const entities = Object.create(null) as Record<string, T>; | ||
| for (const item of items) { | ||
| if (Object.hasOwn(entities, item.id)) return undefined; | ||
| ids.push(item.id); | ||
| entities[item.id] = item; | ||
| } | ||
| return { ids, entities }; | ||
| } | ||
|
|
||
| export const charactersAdapter = createEntityAdapter<Character>({ | ||
| sortComparer: preserveEntityOrder, | ||
|
qnbs marked this conversation as resolved.
qnbs marked this conversation as resolved.
|
||
| }); | ||
| export const worldsAdapter = createEntityAdapter<World>({ sortComparer: preserveEntityOrder }); | ||
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.