Skip to content
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

Fix: Ignore KCL changes when loading settings and fixed useEffect to use .current #5126

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably our WS BS that we're dealing with right now.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 1 addition & 12 deletions src/components/ModelingMachineProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ export const ModelingMachineProvider = ({
},
},
} = useSettingsAuthContext()
const previousAllowOrbitInSketchMode = useRef(allowOrbitInSketchMode.current)
const navigate = useNavigate()
const { context, send: fileMachineSend } = useFileContext()
const { file } = useLoaderData() as IndexLoaderData
Expand Down Expand Up @@ -1205,14 +1204,6 @@ export const ModelingMachineProvider = ({
}, [engineCommandManager.engineConnection, modelingSend])

useEffect(() => {
// Only trigger this if the state actually changes, if it stays the same do not reload the camera
if (
previousAllowOrbitInSketchMode.current === allowOrbitInSketchMode.current
) {
//no op
previousAllowOrbitInSketchMode.current = allowOrbitInSketchMode.current
return
}
const inSketchMode = modelingState.matches('Sketch')

// If you are in sketch mode and you disable the orbit, return back to the normal view to the target
Expand All @@ -1235,9 +1226,7 @@ export const ModelingMachineProvider = ({
if (inSketchMode) {
sceneInfra.camControls.enableRotate = allowOrbitInSketchMode.current
}

previousAllowOrbitInSketchMode.current = allowOrbitInSketchMode.current
}, [allowOrbitInSketchMode])
}, [allowOrbitInSketchMode.current])

// Allow using the delete key to delete solids
useHotkeys(['backspace', 'delete', 'del'], () => {
Expand Down
16 changes: 14 additions & 2 deletions src/components/SettingsAuthProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ import {
loadAndValidateSettings,
} from 'lib/settings/settingsUtils'
import { reportRejection } from 'lib/trap'
import { getAppSettingsFilePath } from 'lib/desktop'
import {
getAppSettingsFilePath,
isPathAProjectSettingsFile,
isPathASettingsFile,
} from 'lib/desktop'
import { isDesktop } from 'lib/isDesktop'
import { useFileSystemWatcher } from 'hooks/useFileSystemWatcher'
import { codeManager } from 'lib/singletons'
Expand Down Expand Up @@ -226,7 +230,15 @@ export const SettingsAuthProviderBase = ({
}, [])

useFileSystemWatcher(
async (eventType: string) => {
async (eventType: string, path: string) => {
const exitEarly = !(
isPathASettingsFile(path) || isPathAProjectSettingsFile(path)
)
if (exitEarly) {
// The file is not a settings file, exit early!
return
}

// If there is a projectPath but it no longer exists it means
// it was exterally removed. If we let the code past this condition
// execute it will recreate the directory due to code in
Expand Down
13 changes: 13 additions & 0 deletions src/lib/desktop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
TELEMETRY_FILE_NAME,
TELEMETRY_RAW_FILE_NAME,
TOKEN_FILE_NAME,
FILE_EXT,
} from './constants'
import { DeepPartial } from './types'
import { ProjectConfiguration } from 'wasm-lib/kcl/bindings/ProjectConfiguration'
Expand Down Expand Up @@ -625,3 +626,15 @@ export const getUser = async (
}
return Promise.reject(new Error('unreachable'))
}

export const isPathAKCLFile = (path: string): boolean => {
return path.endsWith(FILE_EXT)
}

export const isPathASettingsFile = (path: string): boolean => {
return path.endsWith(SETTINGS_FILE_NAME)
}

export const isPathAProjectSettingsFile = (path: string): boolean => {
return path.endsWith(PROJECT_SETTINGS_FILE_NAME)
}
Loading