Do not use window reload

Summary: Let's keep it simple, do not reload. Just show/hide the right content.

Reviewed By: antonk52

Differential Revision: D49377316

fbshipit-source-id: 9b2a47374da3e72f17e2d55c9290960b703fd43e
This commit is contained in:
Lorenzo Blasa
2023-09-18 12:03:09 -07:00
committed by Facebook GitHub Bot
parent 2fd8003fd8
commit f1c88a464b
3 changed files with 30 additions and 15 deletions

View File

@@ -143,12 +143,17 @@
window.location.reload();
});
function showNoConnection(reload) {
function toggleUI(main) {
const root = document.getElementById('root');
root.remove();
const troubleshoot = document.getElementById('troubleshoot');
troubleshoot.style.display = 'flex';
if (main) {
root.style.display = 'block';
troubleshoot.style.display = 'none';
} else {
root.style.display = 'none';
troubleshoot.style.display = 'flex';
}
}
const params = new URL(location.href).searchParams;
@@ -208,8 +213,14 @@
box.textContent = text;
}
}
window.flipperShowMessage = showMessage;
window.flipperShowNoConnection = showNoConnection;
window.flipperShowNoConnection = () => {
toggleUI(false);
};
window.flipperHideMessage = () => {
toggleUI(true);
}
// load correct theme (n.b. this doesn't handle system value specifically, will assume light in such cases)
try {

View File

@@ -153,12 +153,17 @@
window.location.reload();
});
function showNoConnection() {
function toggleUI(main) {
const root = document.getElementById('root');
root.remove();
const troubleshoot = document.getElementById('troubleshoot');
troubleshoot.style.display = 'flex';
if (main) {
root.style.display = 'block';
troubleshoot.style.display = 'none';
} else {
root.style.display = 'none';
troubleshoot.style.display = 'flex';
}
}
function showMessage(text) {
@@ -178,10 +183,14 @@
}
}
window.flipperShowMessage = showMessage;
window.flipperShowNoConnection = showNoConnection;
window.flipperShowNoConnection = () => {
toggleUI(false);
};
window.flipperHideMessage = () => {
const box = document.querySelector('.__infinity-dev-box-error');
box.setAttribute('hidden', true);
toggleUI(true);
}
const closeButton = document.createElement('button');