mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-06-12 23:47:29 +01:00
Prettier run
This commit is contained in:
+20
-16
@@ -296,10 +296,10 @@ export default class Explorer {
|
|||||||
const detectVSCode = () => {
|
const detectVSCode = () => {
|
||||||
return new Promise<boolean>((resolve) => {
|
return new Promise<boolean>((resolve) => {
|
||||||
// Create hidden iframe to detect protocol handler
|
// Create hidden iframe to detect protocol handler
|
||||||
const iframe = document.createElement('iframe');
|
const iframe = document.createElement("iframe");
|
||||||
iframe.style.display = 'none';
|
iframe.style.display = "none";
|
||||||
document.body.appendChild(iframe);
|
document.body.appendChild(iframe);
|
||||||
|
|
||||||
// Set timeout to handle case where protocol isn't supported
|
// Set timeout to handle case where protocol isn't supported
|
||||||
const timeoutId = setTimeout(() => {
|
const timeoutId = setTimeout(() => {
|
||||||
// Clean up iframe
|
// Clean up iframe
|
||||||
@@ -309,20 +309,24 @@ export default class Explorer {
|
|||||||
// Could not open VS Code within timeout period
|
// Could not open VS Code within timeout period
|
||||||
resolve(false);
|
resolve(false);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
// Try to navigate to VS Code protocol
|
// Try to navigate to VS Code protocol
|
||||||
try {
|
try {
|
||||||
// Listen for blur event which might indicate app was launched
|
// Listen for blur event which might indicate app was launched
|
||||||
window.addEventListener('blur', function onBlur() {
|
window.addEventListener(
|
||||||
clearTimeout(timeoutId);
|
"blur",
|
||||||
window.removeEventListener('blur', onBlur);
|
function onBlur() {
|
||||||
if (document.body.contains(iframe)) {
|
clearTimeout(timeoutId);
|
||||||
document.body.removeChild(iframe);
|
window.removeEventListener("blur", onBlur);
|
||||||
}
|
if (document.body.contains(iframe)) {
|
||||||
// Window lost focus, likely because VS Code opened
|
document.body.removeChild(iframe);
|
||||||
resolve(true);
|
}
|
||||||
}, { once: true });
|
// Window lost focus, likely because VS Code opened
|
||||||
|
resolve(true);
|
||||||
|
},
|
||||||
|
{ once: true },
|
||||||
|
);
|
||||||
|
|
||||||
// Navigate iframe to the VSCode URL
|
// Navigate iframe to the VSCode URL
|
||||||
iframe.src = vscodeUrl;
|
iframe.src = vscodeUrl;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -334,7 +338,7 @@ export default class Explorer {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Try to open VS Code directly first
|
// Try to open VS Code directly first
|
||||||
detectVSCode().then((isVSCodeInstalled) => {
|
detectVSCode().then((isVSCodeInstalled) => {
|
||||||
if (isVSCodeInstalled) {
|
if (isVSCodeInstalled) {
|
||||||
@@ -352,7 +356,7 @@ export default class Explorer {
|
|||||||
showVSCodeDialog();
|
showVSCodeDialog();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Helper function to show the VS Code dialog
|
// Helper function to show the VS Code dialog
|
||||||
const showVSCodeDialog = () => {
|
const showVSCodeDialog = () => {
|
||||||
const openVSCodeDialogProps: DialogProps = {
|
const openVSCodeDialogProps: DialogProps = {
|
||||||
|
|||||||
Reference in New Issue
Block a user