Somehow removed this window.close code

Bring it back + focus() for opener window
This commit is contained in:
Lim Chee Aun 2022-12-16 13:54:17 +08:00
parent ec0b76901a
commit e09e1f16cd

View file

@ -52,6 +52,16 @@ function App() {
: 'Compose', : 'Compose',
); );
useEffect(() => {
if (uiState === 'closed') {
try {
// Focus parent window
window.opener.focus();
} catch (e) {}
window.close();
}
}, [uiState]);
if (uiState === 'closed') { if (uiState === 'closed') {
return ( return (
<div class="box"> <div class="box">
@ -79,11 +89,13 @@ function App() {
onClose={(results) => { onClose={(results) => {
const { newStatus, fn = () => {} } = results || {}; const { newStatus, fn = () => {} } = results || {};
try { try {
console.log('onClose', newStatus, fn);
if (newStatus) { if (newStatus) {
window.opener.__STATES__.reloadStatusPage++; window.opener.__STATES__.reloadStatusPage++;
} }
fn(); fn();
setUIState('closed'); setUIState('closed');
window.close();
} catch (e) {} } catch (e) {}
}} }}
/> />