-
Notifications
You must be signed in to change notification settings - Fork 24
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
add sagas for all data layer methods #662
Conversation
gonpombo8
commented
Jun 21, 2023
•
edited
Loading
edited
- Remove all event emitters for fileChange and dirty state (canSave)
- Add sagas for each rpc method (save, undo, redo, importAsset, etc)
- Move assets catalog and dirty engine state to redux (app store)
- Fix types for data-layer rpc host
08c2811
to
72e95f4
Compare
Deploying with Cloudflare Pages
|
SetPreferences = 'set-preferences' | ||
} | ||
|
||
let dataLayerInterface: DataLayerRpcClient | undefined |
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.
the idea of this is to not serialize the dataLayer at all.
All the methods should be called via sagas
state.reconnectAttempts = 0 | ||
state.error = undefined | ||
}, | ||
error: (state, { payload }: PayloadAction<{ error: ErrorType }>) => { | ||
console.log('[WS] Error', payload.error) | ||
state.error = payload.error | ||
} | ||
}, | ||
save: () => {}, |
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.
we will have an action/saga for each method of the dataLayer
|
||
async function rpcHandler(serverPort: RpcServerPort<DataLayerContext>) { | ||
// TODO: dataLayer as any |
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.
any type fixed
Test this pull request
|
|
||
const FreeCameraInvertRotationIcon = preferences.freeCameraInvertRotation ? BiCheckboxChecked : BiCheckbox | ||
const AutosaveEnabledIcon = preferences.autosaveEnabled ? BiCheckboxChecked : BiCheckbox | ||
console.log('BOEDO: Changed', preferences) |
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.
oops
@@ -23,9 +25,9 @@ export const useSdkContext = () => { | |||
}, [dispatch]) | |||
|
|||
useEffect(() => { | |||
if (!catalog || !canvas || sdk || isLoading || !dataLayer) return | |||
if (!catalog || !canvas || sdk || isLoading || !dataLayer || !preferences) return |
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.
do we need the !dataLayer
if it's not used anymore by createSdkContext
?
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.
nope, i think that we are covered with the prefences. good catch
@@ -35,7 +37,7 @@ export const useSdkContext = () => { | |||
setError(e) | |||
}) | |||
.finally(() => setIsLoading(false)) | |||
}, [catalog, canvas, sdk, isLoading, dispatch, dataLayer]) | |||
}, [catalog, canvas, sdk, isLoading, dispatch, dataLayer, preferences]) |
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.
Same as above with the dataLayer
here
state.canSave = isDirty | ||
}, | ||
updatePreferences: (state, { payload }: PayloadAction<{ preferences: InspectorPreferences }>) => { | ||
console.log(' UPDATED ', payload.preferences) |
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.
log
export const getInspectorPreferences = (state: RootState): InspectorPreferences => { | ||
if (!state.app.preferences) { | ||
// TODO: send to sentry | ||
console.log('invalid inspector preferences') |
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.
log
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #662 +/- ##
==========================================
- Coverage 73.46% 73.37% -0.09%
==========================================
Files 289 296 +7
Lines 9661 9815 +154
Branches 1274 1277 +3
==========================================
+ Hits 7097 7202 +105
- Misses 2443 2491 +48
- Partials 121 122 +1
☔ View full report in Codecov by Sentry. |
0d9c17f
to
dcba58f
Compare
|
||
const fixedNumber = (val: number) => Math.round(val * 1e2) / 1e2 | ||
|
||
const Renderer: React.FC = () => { | ||
const canvasRef = React.useRef<HTMLCanvasElement>(null) | ||
useRenderer(() => canvasRef) | ||
const sdk = useSdk() | ||
const dataLayer = useAppSelector(getDataLayer) | ||
|
||
const dispatch = useAppDispatch() | ||
const [isLoading, setIsLoading] = useState(false) |
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.
This loading state might need to be controlled from the saga, otherwise right now it set to true
and then to false
right after the action is dispatched (because the dispatch does not await)
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.
will do it in another pr :)
undo: () => {}, | ||
redo: () => {}, | ||
importAsset: (_state, _payload: PayloadAction<ImportAssetRequest>) => {}, | ||
removeAsset: (_state, _payload: PayloadAction<Asset>) => {} |
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.
are these above unsued?
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.
no, this generates the action with that payload type.
So then in the saga you can listen to this importAsset action
e40f5b5
to
4e1b50a
Compare