Fixed an issue where "Quit App" confirmation modal in desktop app is not respecting "Confirm on close or refresh?". #7890

This commit is contained in:
Aditya Toshniwal
2024-09-18 16:43:57 +05:30
parent 23ea201325
commit 100f59f78b
6 changed files with 37 additions and 7 deletions

View File

@@ -26,6 +26,7 @@ import { DefaultButton, PgIconButton, PrimaryButton } from '../../../../static/j
import BaseUISchema from 'sources/SchemaView/base_schema.ui';
import { getBinaryPathSchema } from '../../../../browser/server_groups/servers/static/js/binary_path.ui';
import usePreferences from '../store';
import { getBrowser } from '../../../../static/js/utils';
const StyledBox = styled(Box)(({theme}) => ({
@@ -110,6 +111,16 @@ class PreferencesSchema extends BaseUISchema {
}
}
async function reloadPgAdmin() {
let {name: browser} = getBrowser();
if(browser == 'Electron') {
await window.electronUI.log('test');
await window.electronUI.reloadApp();
} else {
location.reload();
}
}
function RightPanel({ schema, refreshKey, ...props }) {
const schemaViewRef = React.useRef(null);
@@ -583,7 +594,7 @@ export default function PreferencesComponent({ ...props }) {
gettext('A page refresh is required to apply the theme. Do you wish to refresh the page now?'),
function () {
/* If user clicks Yes */
location.reload();
reloadPgAdmin();
return true;
},
function () { props.closeModal();},
@@ -630,7 +641,7 @@ export default function PreferencesComponent({ ...props }) {
onclick: () => {
resetPrefsToDefault(false);
closeModal();
}
}
}
];
}
@@ -643,7 +654,7 @@ export default function PreferencesComponent({ ...props }) {
method: 'DELETE'
}).then(()=>{
if (refresh){
location.reload();
reloadPgAdmin();
return true;
}
preferencesStore.cache();