Skip to content

Commit

Permalink
fix: bugsnag errors
Browse files Browse the repository at this point in the history
  • Loading branch information
abose committed Jan 23, 2025
1 parent 723bbd4 commit 6be9f27
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/extensionsIntegrated/Phoenix/new-project.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,24 @@ define(function (require, exports, module) {
createProjectDialogueObj,
downloadCancelled = false;

function _focusContentWindow() {
let attempts = 0;
const maxAttempts = 10; // 10 * 100ms = 1 second total scan time
const intervalId = setInterval(() => {
const frame = document.getElementById("newProjectFrame");
if (frame && frame.contentWindow) {
frame.contentWindow.focus();
clearInterval(intervalId);
}

attempts++;
if (attempts >= maxAttempts) {
clearInterval(intervalId);
console.warn("Could not find or focus on newProjectFrame");
}
}, 100);
}

function _showNewProjectDialogue() {
if(window.testEnvironment){
return;
Expand All @@ -68,9 +86,7 @@ define(function (require, exports, module) {
};
let dialogueContents = Mustache.render(newProjectTemplate, templateVars);
newProjectDialogueObj = Dialogs.showModalDialogUsingTemplate(dialogueContents, true);
setTimeout(()=>{
document.getElementById("newProjectFrame").contentWindow.focus();
}, 100);
_focusContentWindow();
Metrics.countEvent(Metrics.EVENT_TYPE.NEW_PROJECT, "dialogue", "open");
}

Expand Down
4 changes: 4 additions & 0 deletions src/file/FileUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,10 @@ define(function (require, exports, module) {
* @return {string} Path of containing folder (including trailing "/"); or "" if path was the root
*/
function getParentPath(fullPath) {
// Guard clause: ensure fullPath is a non-empty string
if (typeof fullPath !== "string" || !fullPath) {
return "";
}
if (fullPath === "/") {
return "";
}
Expand Down

0 comments on commit 6be9f27

Please sign in to comment.