-
Notifications
You must be signed in to change notification settings - Fork 1
Add batching to the skybrowser topic #209
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,9 +42,13 @@ export const skyBrowserSlice = createSlice({ | |
| state.isInitialized = true; | ||
| return state; | ||
| }, | ||
| updateSkyBrowser: (state, action: PayloadAction<SkyBrowserUpdate>) => { | ||
| state.cameraInSolarSystem = action.payload.cameraInSolarSystem; | ||
| state.selectedBrowserId = action.payload.selectedBrowserId; | ||
| updateSkyBrowser: (state, action: PayloadAction<Partial<SkyBrowserUpdate>>) => { | ||
| if (action.payload.cameraInSolarSystem !== undefined) { | ||
| state.cameraInSolarSystem = action.payload.cameraInSolarSystem; | ||
| } | ||
| if (action.payload.selectedBrowserId !== undefined) { | ||
| state.selectedBrowserId = action.payload.selectedBrowserId; | ||
| } | ||
|
|
||
| if (action.payload.browsers && state.selectedBrowserId in action.payload.browsers) { | ||
|
Comment on lines
+49
to
53
|
||
| state.browsers = action.payload.browsers; | ||
|
|
@@ -54,15 +58,10 @@ export const skyBrowserSlice = createSlice({ | |
| typeof idx === 'string' ? parseInt(idx) : idx | ||
| ); | ||
| } | ||
|
|
||
| // Derived state for easier access | ||
| state.browserIds = Object.keys(action.payload.browsers) ?? []; | ||
| state.browserColors = state.browserIds.map( | ||
| (id) => action.payload.browsers[id].color | ||
| ); | ||
| state.browserNames = state.browserIds.map( | ||
| (id) => action.payload.browsers[id].name | ||
| ); | ||
| state.browserIds = Object.keys(state.browsers); | ||
| state.browserColors = state.browserIds.map((id) => state.browsers[id].color); | ||
| state.browserNames = state.browserIds.map((id) => state.browsers[id].name); | ||
| } else { | ||
| // If the update is invalid, reset the state | ||
| state.selectedBrowserId = ''; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch