Merge pull request #2656 from tomobre/fix/warn-settings-link-previews

fix: on cancel link preview toggle, toggle stays off
pull/2729/head
Audric Ackermann 2 years ago committed by GitHub
commit a5cc25c058
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -12,19 +12,25 @@ import { TypingBubble } from '../../conversation/TypingBubble';
import { SessionSettingButtonItem, SessionToggleWithDescription } from '../SessionSettingListItem';
import { displayPasswordModal } from '../SessionSettings';
async function toggleLinkPreviews() {
const newValue = !window.getSettingValue(SettingsKey.settingsLinkPreview);
await window.setSettingValue(SettingsKey.settingsLinkPreview, newValue);
if (!newValue) {
await Data.createOrUpdateItem({ id: hasLinkPreviewPopupBeenDisplayed, value: false });
} else {
async function toggleLinkPreviews(forceUpdate: () => void) {
const isToggleOn = Boolean(window.getSettingValue(SettingsKey.settingsLinkPreview));
if (!isToggleOn) {
window.inboxStore?.dispatch(
updateConfirmModal({
title: window.i18n('linkPreviewsTitle'),
message: window.i18n('linkPreviewsConfirmMessage'),
okTheme: SessionButtonColor.Danger,
onClickOk: async () => {
const newValue = !isToggleOn;
await window.setSettingValue(SettingsKey.settingsLinkPreview, newValue);
forceUpdate();
},
})
);
} else {
await window.setSettingValue(SettingsKey.settingsLinkPreview, false);
await Data.createOrUpdateItem({ id: hasLinkPreviewPopupBeenDisplayed, value: false });
forceUpdate();
}
}
@ -70,8 +76,7 @@ export const SettingsCategoryPrivacy = (props: {
/>
<SessionToggleWithDescription
onClickToggle={async () => {
await toggleLinkPreviews();
forceUpdate();
await toggleLinkPreviews(forceUpdate);
}}
title={window.i18n('linkPreviewsTitle')}
description={window.i18n('linkPreviewDescription')}

Loading…
Cancel
Save