feat: enable email backups for everyone
This commit is contained in:
@@ -8,13 +8,7 @@ import Dropdown from '@/Components/Dropdown/Dropdown'
|
|||||||
import { DropdownItem } from '@/Components/Dropdown/DropdownItem'
|
import { DropdownItem } from '@/Components/Dropdown/DropdownItem'
|
||||||
import Switch from '@/Components/Switch/Switch'
|
import Switch from '@/Components/Switch/Switch'
|
||||||
import HorizontalSeparator from '@/Components/Shared/HorizontalSeparator'
|
import HorizontalSeparator from '@/Components/Shared/HorizontalSeparator'
|
||||||
import {
|
import { EmailBackupFrequency, MuteFailedBackupsEmailsOption, SettingName } from '@standardnotes/snjs'
|
||||||
FeatureStatus,
|
|
||||||
FeatureIdentifier,
|
|
||||||
EmailBackupFrequency,
|
|
||||||
MuteFailedBackupsEmailsOption,
|
|
||||||
SettingName,
|
|
||||||
} from '@standardnotes/snjs'
|
|
||||||
import PreferencesGroup from '../../PreferencesComponents/PreferencesGroup'
|
import PreferencesGroup from '../../PreferencesComponents/PreferencesGroup'
|
||||||
import PreferencesSegment from '../../PreferencesComponents/PreferencesSegment'
|
import PreferencesSegment from '../../PreferencesComponents/PreferencesSegment'
|
||||||
|
|
||||||
@@ -27,7 +21,6 @@ const EmailBackups = ({ application }: Props) => {
|
|||||||
const [emailFrequency, setEmailFrequency] = useState<EmailBackupFrequency>(EmailBackupFrequency.Disabled)
|
const [emailFrequency, setEmailFrequency] = useState<EmailBackupFrequency>(EmailBackupFrequency.Disabled)
|
||||||
const [emailFrequencyOptions, setEmailFrequencyOptions] = useState<DropdownItem[]>([])
|
const [emailFrequencyOptions, setEmailFrequencyOptions] = useState<DropdownItem[]>([])
|
||||||
const [isFailedBackupEmailMuted, setIsFailedBackupEmailMuted] = useState(true)
|
const [isFailedBackupEmailMuted, setIsFailedBackupEmailMuted] = useState(true)
|
||||||
const [isEntitledToEmailBackups, setIsEntitledToEmailBackups] = useState(false)
|
|
||||||
|
|
||||||
const loadEmailFrequencySetting = useCallback(async () => {
|
const loadEmailFrequencySetting = useCallback(async () => {
|
||||||
if (!application.getUser()) {
|
if (!application.getUser()) {
|
||||||
@@ -59,9 +52,6 @@ const EmailBackups = ({ application }: Props) => {
|
|||||||
}, [application])
|
}, [application])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const emailBackupsFeatureStatus = application.features.getFeatureStatus(FeatureIdentifier.DailyEmailBackup)
|
|
||||||
setIsEntitledToEmailBackups(emailBackupsFeatureStatus === FeatureStatus.Entitled)
|
|
||||||
|
|
||||||
const frequencyOptions = []
|
const frequencyOptions = []
|
||||||
for (const frequency in EmailBackupFrequency) {
|
for (const frequency in EmailBackupFrequency) {
|
||||||
const frequencyValue = EmailBackupFrequency[frequency as keyof typeof EmailBackupFrequency]
|
const frequencyValue = EmailBackupFrequency[frequency as keyof typeof EmailBackupFrequency]
|
||||||
@@ -96,9 +86,6 @@ const EmailBackups = ({ application }: Props) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const toggleMuteFailedBackupEmails = async () => {
|
const toggleMuteFailedBackupEmails = async () => {
|
||||||
if (!isEntitledToEmailBackups) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const previousValue = isFailedBackupEmailMuted
|
const previousValue = isFailedBackupEmailMuted
|
||||||
setIsFailedBackupEmailMuted(!isFailedBackupEmailMuted)
|
setIsFailedBackupEmailMuted(!isFailedBackupEmailMuted)
|
||||||
|
|
||||||
@@ -109,9 +96,6 @@ const EmailBackups = ({ application }: Props) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleEmailFrequencyChange = (item: string) => {
|
const handleEmailFrequencyChange = (item: string) => {
|
||||||
if (!isEntitledToEmailBackups) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
updateEmailFrequency(item as EmailBackupFrequency).catch(console.error)
|
updateEmailFrequency(item as EmailBackupFrequency).catch(console.error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,20 +103,7 @@ const EmailBackups = ({ application }: Props) => {
|
|||||||
<PreferencesGroup>
|
<PreferencesGroup>
|
||||||
<PreferencesSegment>
|
<PreferencesSegment>
|
||||||
<Title>Email Backups</Title>
|
<Title>Email Backups</Title>
|
||||||
{!isEntitledToEmailBackups && (
|
<div>
|
||||||
<>
|
|
||||||
<Text>
|
|
||||||
A <span className={'font-bold'}>Plus</span> or <span className={'font-bold'}>Pro</span> subscription plan
|
|
||||||
is required to enable Email Backups.{' '}
|
|
||||||
<a target="_blank" href="https://standardnotes.com/features">
|
|
||||||
Learn more
|
|
||||||
</a>
|
|
||||||
.
|
|
||||||
</Text>
|
|
||||||
<HorizontalSeparator classes="my-4" />
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
<div className={isEntitledToEmailBackups ? '' : 'faded cursor-default pointer-events-none'}>
|
|
||||||
{!isDesktopApplication() && (
|
{!isDesktopApplication() && (
|
||||||
<Text className="mb-3">
|
<Text className="mb-3">
|
||||||
Daily encrypted email backups of your entire data set delivered directly to your inbox.
|
Daily encrypted email backups of your entire data set delivered directly to your inbox.
|
||||||
@@ -150,7 +121,6 @@ const EmailBackups = ({ application }: Props) => {
|
|||||||
items={emailFrequencyOptions}
|
items={emailFrequencyOptions}
|
||||||
value={emailFrequency}
|
value={emailFrequency}
|
||||||
onChange={handleEmailFrequencyChange}
|
onChange={handleEmailFrequencyChange}
|
||||||
disabled={!isEntitledToEmailBackups}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -163,11 +133,7 @@ const EmailBackups = ({ application }: Props) => {
|
|||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
<div className={'sk-spinner info small'} />
|
<div className={'sk-spinner info small'} />
|
||||||
) : (
|
) : (
|
||||||
<Switch
|
<Switch onChange={toggleMuteFailedBackupEmails} checked={!isFailedBackupEmailMuted} />
|
||||||
onChange={toggleMuteFailedBackupEmails}
|
|
||||||
checked={!isFailedBackupEmailMuted}
|
|
||||||
disabled={!isEntitledToEmailBackups}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user