-
Notifications
You must be signed in to change notification settings - Fork 34
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 static geolocation #317
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
packages/vscode-extension/src/webview/views/DeviceLocationView.tsx
Outdated
Show resolved
Hide resolved
packages/vscode-extension/src/webview/views/DeviceLocationView.tsx
Outdated
Show resolved
Hide resolved
packages/vscode-extension/src/webview/views/DeviceLocationView.tsx
Outdated
Show resolved
Hide resolved
packages/vscode-extension/src/webview/views/DeviceLocationView.tsx
Outdated
Show resolved
Hide resolved
packages/vscode-extension/src/webview/views/DeviceLocationView.tsx
Outdated
Show resolved
Hide resolved
packages/vscode-extension/src/webview/views/DeviceLocationView.tsx
Outdated
Show resolved
Hide resolved
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 discussed this over call but posting high level comments such that they don't get lost:
- let's accept single line input for coords and allow different formatting (use some js libfor parsing). It is convinient to be able to paste the coords from somewhere instead of interacting with four separate controls
- don't put form controls below "save" button, the enable/disable switch should be first actually
- we don't need save, let's just save on change assuming the provided coords are valid
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.
Leaving some minor comments in code to fix before merging
@@ -27,3 +27,25 @@ export function throttle<T extends (...args: any[]) => any>( | |||
recentArgs = args; | |||
} as T; | |||
} | |||
|
|||
export function throttleWithTrailing<T extends (...args: any[]) => 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.
how is this different than "throttle"? Maybe add some comment here? Also from reading the code it appears like you can actually use the existing method, no?
….tsx Co-authored-by: Kacper Kapuściak <39658211+kacperkapusciak@users.noreply.github.com>
94cf834
to
9970683
Compare
if (settings.location.isDisabled) { | ||
await exec("xcrun", [ | ||
"simctl", | ||
"--set", | ||
deviceSetLocation, | ||
"location", | ||
this.deviceUDID, | ||
"clear", | ||
]); | ||
} else { | ||
await exec("xcrun", [ | ||
"simctl", | ||
"--set", | ||
deviceSetLocation, | ||
"location", | ||
this.deviceUDID, | ||
"set", |
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.
Nit:
await exec("xcrun", [
"simctl",
"--set",
deviceSetLocation,
"location",
this.deviceUDID,
settings.location.isDisabled ? "clear" : "set",
]);
latitude: 50.048653, | ||
longitude: 19.965474, |
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.
Won't block on this but I still think we shouldn't default to any location.
text-align: center; | ||
height: 42px; | ||
align-self: right; | ||
/* margin-left: 5px; */ |
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.
Commented out.
const { project, deviceSettings } = useProject(); | ||
const inputRef = useRef<HTMLInputElement>(null); | ||
|
||
const updateProjectSettingWithThrottle = throttleWithTrailing( |
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.
Can't we use blur events instead of throttling change events?
const convertDDToDMS = (D: number, lng: boolean) => { | ||
return { | ||
dir: D < 0 ? (lng ? "W" : "S") : lng ? "E" : "N", | ||
deg: 0 | (D < 0 ? (D = -D) : D), | ||
min: String(0 | (((D += 1e-9) % 1) * 60)).padStart(2, "0"), | ||
sec: String(Math.floor((0 | (((D * 60) % 1) * 6000)) / 100)).padStart(2, "0"), | ||
}; | ||
}; |
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.
Can you drop a comment what DD and DMS is? Assuming the code is copied from somewhere, would be nice to have a source URL.
<label className="latitude"> | ||
<div className="picker"> | ||
<input | ||
ref={inputRef} |
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.
I wonder if it isn't easier to make it controlled input.
try { | ||
position = new CoordinateParser(newCoordinate); | ||
setIsCoordinateValid(true); | ||
} catch (e) { | ||
setIsCoordinateValid(false); | ||
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.
I don't particularly like it. What do you think about some small helper function to return lat, long?
If it returns nice error, we can also try to pass it to user.
function parseCoords(raw: string) {
try {
const { getLatitude, getLongitude } = new CoordinateParser(newCoordinate);
return { latitude: getLatitude(), longitude: getLongitude() };
} catch (_e) {}
return undefined;
}
In #317 new fields have been added to device settings. However, since we persist device settings, the changes are not compatible with the old data that might've been stored there. To prevent this we are adding a versioning of device settings key (will increment version with future changes). This PR also changes the defaults to use disabled location, especially that we need to have some coordinates specified, it'd be weird to have everyone using IDE pointing to the same geo location.
This PR adds an ability to set static device location.
added functionality:
Screen.Recording.2024-06-06.at.16.02.55.mov
Screen.Recording.2024-06-06.at.16.05.48.mov
Fixes: #330