Skip to content

Commit

Permalink
Checklist UI Update
Browse files Browse the repository at this point in the history
  • Loading branch information
hardik-pratap-singh committed Sep 12, 2024
1 parent 1e4109e commit f12d29e
Showing 1 changed file with 6 additions and 40 deletions.
46 changes: 6 additions & 40 deletions browser-extension/plugin/src/ui-components/pages/Preferences.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ export function Preferences() {
};
}, [user]);

async function handleSlurReplacement(enableSlurReplacement) {
async function handleSlurReplacementAndSlurMetadata(enableSlurReplacement, enableSlurMetadata) {
try {
// setEnableSlurMetadata(false);


const confirmed = window.confirm(
'This action requires a page reload. Do you want to continue?'
Expand Down Expand Up @@ -123,44 +123,15 @@ export function Preferences() {
}
}

async function handleSlurMetadata(enableSlurMetadata) {
try {
// setEnableSlurReplacement(false)

const confirmed = window.confirm(
'This action requires a page reload. Do you want to continue?'
);
if (confirmed) {
const tabsCurrent = await userBrowserTabs.query({
active: true,
currentWindow: true
});
const tabId = tabsCurrent[0].id;

await setPreferenceData({
...localPreferences,
enableSlurMetadata,
enableSlurReplacement
});

userBrowserTabs.sendMessage(tabId, {
type: 'ULI_ENABLE_SLUR_METADATA',
payload: enableSlurMetadata
});
userBrowserTabs.reload(tabId);
}
} catch (error) {
console.log(error);
}
}

async function changeEnableSlurReplacementOption(checked) {
console.log(checked);
if(checked === true) setEnableSlurMetadata(false);
setEnableSlurReplacement(checked);
}

async function changeEnableSlurMetadataOption(checked) {
console.log(checked);
if(checked === true) setEnableSlurReplacement(false);
setEnableSlurMetadata(checked);
}

Expand Down Expand Up @@ -190,14 +161,9 @@ export function Preferences() {
const enableSlurMetadataChanged =
enableSlurMetadata !== preferenceInLS.enableSlurMetadata;

if (enableSlurReplacementChanged) {
if (enableSlurReplacementChanged || enableSlurMetadataChanged) {
console.log('enable val changed', enableSlurReplacementChanged);
await handleSlurReplacement(enableSlurReplacement);
}

if(enableSlurMetadataChanged){
console.log('enable val changed', enableSlurMetadataChanged);
await handleSlurMetadata(enableSlurMetadata);
await handleSlurReplacementAndSlurMetadata(enableSlurReplacement, enableSlurMetadata);
}

showNotification({
Expand Down

0 comments on commit f12d29e

Please sign in to comment.