feat: privacy prefs (#935)
* chore: move all components into Components dir with pascal case * feat: privacy prefs * chore: upgrade deps
This commit is contained in:
@@ -13,7 +13,11 @@ import {
|
||||
Text,
|
||||
Title,
|
||||
} from '../../components';
|
||||
import { EmailBackupFrequency, SettingName } from '@standardnotes/settings';
|
||||
import {
|
||||
EmailBackupFrequency,
|
||||
MuteFailedBackupsEmailsOption,
|
||||
SettingName,
|
||||
} from '@standardnotes/settings';
|
||||
import { Dropdown, DropdownItem } from '@/components/Dropdown';
|
||||
import { Switch } from '@/components/Switch';
|
||||
import { HorizontalSeparator } from '@/components/Shared/HorizontalSeparator';
|
||||
@@ -44,14 +48,19 @@ export const EmailBackups = observer(({ application }: Props) => {
|
||||
setIsLoading(true);
|
||||
|
||||
try {
|
||||
const userSettings = await application.listSettings();
|
||||
const userSettings = await application.settings.listSettings();
|
||||
setEmailFrequency(
|
||||
(userSettings.EMAIL_BACKUP_FREQUENCY ||
|
||||
EmailBackupFrequency.Disabled) as EmailBackupFrequency
|
||||
userSettings.getSettingValue<EmailBackupFrequency>(
|
||||
SettingName.EmailBackupFrequency,
|
||||
EmailBackupFrequency.Disabled
|
||||
)
|
||||
);
|
||||
setIsFailedBackupEmailMuted(
|
||||
convertStringifiedBooleanToBoolean(
|
||||
userSettings[SettingName.MuteFailedBackupsEmails] as string
|
||||
userSettings.getSettingValue<MuteFailedBackupsEmailsOption>(
|
||||
SettingName.MuteFailedBackupsEmails,
|
||||
MuteFailedBackupsEmailsOption.NotMuted
|
||||
)
|
||||
)
|
||||
);
|
||||
} catch (error) {
|
||||
@@ -75,7 +84,10 @@ export const EmailBackups = observer(({ application }: Props) => {
|
||||
EmailBackupFrequency[frequency as keyof typeof EmailBackupFrequency];
|
||||
frequencyOptions.push({
|
||||
value: frequencyValue,
|
||||
label: application.getEmailBackupFrequencyOptionLabel(frequencyValue),
|
||||
label:
|
||||
application.settings.getEmailBackupFrequencyOptionLabel(
|
||||
frequencyValue
|
||||
),
|
||||
});
|
||||
}
|
||||
setEmailFrequencyOptions(frequencyOptions);
|
||||
@@ -88,7 +100,7 @@ export const EmailBackups = observer(({ application }: Props) => {
|
||||
payload: string
|
||||
): Promise<boolean> => {
|
||||
try {
|
||||
await application.updateSetting(settingName, payload);
|
||||
await application.settings.updateSetting(settingName, payload, false);
|
||||
return true;
|
||||
} catch (e) {
|
||||
application.alertService.alert(STRING_FAILED_TO_UPDATE_USER_SETTING);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import React from 'react';
|
||||
import { useCallback, useEffect, useState } from 'preact/hooks';
|
||||
import { ButtonType, SettingName } from '@standardnotes/snjs';
|
||||
import {
|
||||
@@ -27,7 +26,9 @@ export const CloudBackupProvider: FunctionComponent<Props> = ({
|
||||
}) => {
|
||||
const [authBegan, setAuthBegan] = useState(false);
|
||||
const [successfullyInstalled, setSuccessfullyInstalled] = useState(false);
|
||||
const [backupFrequency, setBackupFrequency] = useState<string | null>(null);
|
||||
const [backupFrequency, setBackupFrequency] = useState<string | undefined>(
|
||||
undefined
|
||||
);
|
||||
const [confirmation, setConfirmation] = useState('');
|
||||
|
||||
const disable = async (event: Event) => {
|
||||
@@ -42,10 +43,10 @@ export const CloudBackupProvider: FunctionComponent<Props> = ({
|
||||
'Cancel'
|
||||
);
|
||||
if (shouldDisable) {
|
||||
await application.deleteSetting(backupFrequencySettingName);
|
||||
await application.deleteSetting(backupTokenSettingName);
|
||||
await application.settings.deleteSetting(backupFrequencySettingName);
|
||||
await application.settings.deleteSetting(backupTokenSettingName);
|
||||
|
||||
setBackupFrequency(null);
|
||||
setBackupFrequency(undefined);
|
||||
}
|
||||
} catch (error) {
|
||||
application.alertService.alert(error as string);
|
||||
@@ -66,7 +67,7 @@ export const CloudBackupProvider: FunctionComponent<Props> = ({
|
||||
const performBackupNow = async () => {
|
||||
// A backup is performed anytime the setting is updated with the integration token, so just update it here
|
||||
try {
|
||||
await application.updateSetting(
|
||||
await application.settings.updateSetting(
|
||||
backupFrequencySettingName,
|
||||
backupFrequency as string
|
||||
);
|
||||
@@ -134,11 +135,11 @@ export const CloudBackupProvider: FunctionComponent<Props> = ({
|
||||
if (!cloudProviderToken) {
|
||||
throw new Error();
|
||||
}
|
||||
await application.updateSetting(
|
||||
await application.settings.updateSetting(
|
||||
backupTokenSettingName,
|
||||
cloudProviderToken
|
||||
);
|
||||
await application.updateSetting(
|
||||
await application.settings.updateSetting(
|
||||
backupFrequencySettingName,
|
||||
defaultBackupFrequency
|
||||
);
|
||||
@@ -166,7 +167,9 @@ export const CloudBackupProvider: FunctionComponent<Props> = ({
|
||||
if (!application.getUser()) {
|
||||
return;
|
||||
}
|
||||
const frequency = await application.getSetting(backupFrequencySettingName);
|
||||
const frequency = await application.settings.getSetting(
|
||||
backupFrequencySettingName
|
||||
);
|
||||
setBackupFrequency(frequency);
|
||||
}, [application, backupFrequencySettingName]);
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import React from 'react';
|
||||
import { CloudBackupProvider } from './CloudBackupProvider';
|
||||
import { useCallback, useEffect, useState } from 'preact/hooks';
|
||||
import { WebApplication } from '@/ui_models/application';
|
||||
@@ -13,21 +12,19 @@ import { HorizontalSeparator } from '@/components/Shared/HorizontalSeparator';
|
||||
import { FeatureIdentifier } from '@standardnotes/features';
|
||||
import { FeatureStatus } from '@standardnotes/snjs';
|
||||
import { FunctionComponent } from 'preact';
|
||||
import { CloudProvider, SettingName } from '@standardnotes/settings';
|
||||
import {
|
||||
CloudProvider,
|
||||
MuteFailedCloudBackupsEmailsOption,
|
||||
SettingName,
|
||||
} from '@standardnotes/settings';
|
||||
import { Switch } from '@/components/Switch';
|
||||
import { convertStringifiedBooleanToBoolean } from '@/utils';
|
||||
import { STRING_FAILED_TO_UPDATE_USER_SETTING } from '@/strings';
|
||||
|
||||
const providerData = [
|
||||
{
|
||||
name: CloudProvider.Dropbox,
|
||||
},
|
||||
{
|
||||
name: CloudProvider.Google,
|
||||
},
|
||||
{
|
||||
name: CloudProvider.OneDrive,
|
||||
},
|
||||
{ name: CloudProvider.Dropbox },
|
||||
{ name: CloudProvider.Google },
|
||||
{ name: CloudProvider.OneDrive },
|
||||
];
|
||||
|
||||
type Props = {
|
||||
@@ -51,10 +48,13 @@ export const CloudLink: FunctionComponent<Props> = ({ application }) => {
|
||||
setIsLoading(true);
|
||||
|
||||
try {
|
||||
const userSettings = await application.listSettings();
|
||||
const userSettings = await application.settings.listSettings();
|
||||
setIsFailedCloudBackupEmailMuted(
|
||||
convertStringifiedBooleanToBoolean(
|
||||
userSettings[SettingName.MuteFailedCloudBackupsEmails] as string
|
||||
userSettings.getSettingValue(
|
||||
SettingName.MuteFailedCloudBackupsEmails,
|
||||
MuteFailedCloudBackupsEmailsOption.NotMuted
|
||||
)
|
||||
)
|
||||
);
|
||||
} catch (error) {
|
||||
@@ -89,7 +89,7 @@ export const CloudLink: FunctionComponent<Props> = ({ application }) => {
|
||||
payload: string
|
||||
): Promise<boolean> => {
|
||||
try {
|
||||
await application.updateSetting(settingName, payload);
|
||||
await application.settings.updateSetting(settingName, payload);
|
||||
return true;
|
||||
} catch (e) {
|
||||
application.alertService.alert(STRING_FAILED_TO_UPDATE_USER_SETTING);
|
||||
|
||||
Reference in New Issue
Block a user