mobile: add marketing consent settings

This commit is contained in:
ammarahm-ed
2023-06-05 17:58:40 +05:00
committed by Abdullah Atta
parent 40cb6ae8bf
commit e251c6f71c
2 changed files with 22 additions and 2 deletions

View File

@@ -289,12 +289,12 @@ const _SectionItem = ({ item }: { item: SettingSection }) => {
</View>
</View>
{item.type === "switch" && item.property && (
{item.type === "switch" && (
<ToggleSwitch
isOn={
item.getter
? item.getter(item.property || current)
: settings[item.property]
: settings[item?.property as never]
}
onColor={colors.accent}
offColor={colors.icon}

View File

@@ -636,6 +636,26 @@ export const settingsGroups: SettingSection[] = [
"Contribute towards a better Notesnook. All tracking information is anonymous.",
property: "telemetry"
},
{
id: "marketing-emails",
type: "switch",
name: "Marketing emails",
description:
"We will send you occasional promotional offers & product updates on your email (sent once every month).",
modifer: async () => {
try {
await db.user?.changeMarketingConsent(
!useUserStore.getState().user?.marketingConsent
);
useUserStore.getState().setUser(await db.user?.fetchUser());
} catch (e) {
ToastEvent.error(e as Error);
}
},
getter: (current: any) => current?.marketingConsent,
useHook: () => useUserStore((state) => state.user),
hidden: (current) => !current
},
{
id: "cors-bypass",
type: "input",