Skip to content

Commit

Permalink
fix: saving resources
Browse files Browse the repository at this point in the history
  • Loading branch information
devcatalin committed Apr 20, 2023
1 parent c43587e commit b08ebc9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/molecules/Monaco/Monaco.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ const Monaco: React.FC<IProps> = props => {
fileMapRef
);

const debouncedSaveContent = useDebouncedCodeSave(originalCodeRef, selectedResource, selectedFilePathRef);
const debouncedSaveContent = useDebouncedCodeSave(originalCodeRef, selectedResourceRef, selectedFilePathRef);

useMonacoUiState(editorRef.current, selectedResourceIdRef.current, selectedFilePath);

Expand Down
6 changes: 3 additions & 3 deletions src/components/molecules/Monaco/useDebouncedCodeSave.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,23 @@ const debouncedCodeSave = debounce(

function useDebouncedCodeSave(
originalCodeRef: React.MutableRefObject<string>,
selectedResource: K8sResource | undefined,
selectedResourceRef: React.MutableRefObject<K8sResource | undefined>,
selectedPathRef: React.MutableRefObject<string | undefined>
) {
const dispatch = useAppDispatch();
const debouncedSaveContent = useCallback(
(code: string) => {
const success = debouncedCodeSave({
code,
selectedResource,
selectedResource: selectedResourceRef.current,
selectedPath: selectedPathRef.current,
dispatch,
});
if (success) {
originalCodeRef.current = code;
}
},
[selectedResource, selectedPathRef, dispatch, originalCodeRef]
[dispatch, originalCodeRef, selectedPathRef, selectedResourceRef]
);

return debouncedSaveContent;
Expand Down

0 comments on commit b08ebc9

Please sign in to comment.