fix: close the options window after clicking save

This commit is contained in:
Rohid
2024-08-17 16:09:06 +06:00
parent bcb4155593
commit e6605cb9e3

View File

@@ -1,5 +1,3 @@
import { Toast } from 'bootstrap';
import classNames from 'classnames';
import React, { useEffect, useRef, useState } from 'react'; import React, { useEffect, useRef, useState } from 'react';
import config, { SuccessOrFailType } from '../config/config'; import config, { SuccessOrFailType } from '../config/config';
import apiKeyInvalid from '../utils/apiKey'; import apiKeyInvalid from '../utils/apiKey';
@@ -38,8 +36,6 @@ export default function Options(): JSX.Element {
whitelist: '', whitelist: '',
}); });
const liveToastRef = useRef(null);
const loggingStyleRef = useRef(null); const loggingStyleRef = useRef(null);
const restoreSettings = async (): Promise<void> => { const restoreSettings = async (): Promise<void> => {
@@ -131,9 +127,8 @@ export default function Options(): JSX.Element {
trackSocialMedia, trackSocialMedia,
whitelist, whitelist,
}); });
// eslint-disable-next-line
Toast.getOrCreateInstance(liveToastRef?.current ?? '')?.show();
await logUserIn(state.apiKey); await logUserIn(state.apiKey);
window.close();
}; };
const updateBlacklistState = (sites: string) => { const updateBlacklistState = (sites: string) => {
@@ -363,30 +358,6 @@ export default function Options(): JSX.Element {
</button> </button>
</div> </div>
</div> </div>
<div className="toast-container position-fixed bottom-0 end-0 p-3">
<div
className={classNames(
'toast align-items-center justify-content-between alert',
`alert-${state.alertType}`,
)}
role="alert"
aria-live="assertive"
aria-atomic="true"
id="liveToast"
ref={liveToastRef}
data-bs-delay="3000"
>
<div className="fs-5">{state.alertText}</div>
<div data-bs-theme="dark">
<button
type="button"
className="btn-close m-0"
data-bs-dismiss="toast"
aria-label="Close"
></button>
</div>
</div>
</div>
</form> </form>
</div> </div>
</div> </div>