feat: show all themes and premium icon if not entitled (#854)

This commit is contained in:
Aman Harwara
2022-02-08 20:25:12 +05:30
committed by GitHub
parent 7f5f0d9d17
commit 139853a491
7 changed files with 405 additions and 340 deletions

View File

@@ -1,10 +1,10 @@
import { WebApplication } from '@/ui_models/application';
import { FeatureStatus, FeatureIdentifier } from '@standardnotes/snjs';
import { FunctionComponent } from 'preact';
import { useCallback, useState } from 'preact/hooks';
import { useCallback } from 'preact/hooks';
import { JSXInternal } from 'preact/src/jsx';
import { Icon } from '../Icon';
import { PremiumFeaturesModal } from '../PremiumFeaturesModal';
import { usePremiumModal } from '../Premium';
import { Switch } from '../Switch';
type Props = {
@@ -20,7 +20,7 @@ export const FocusModeSwitch: FunctionComponent<Props> = ({
onClose,
isEnabled,
}) => {
const [showUpgradeModal, setShowUpgradeModal] = useState(false);
const premiumModal = usePremiumModal();
const isEntitled =
application.getFeatureStatus(FeatureIdentifier.FocusMode) ===
FeatureStatus.Entitled;
@@ -33,10 +33,10 @@ export const FocusModeSwitch: FunctionComponent<Props> = ({
onToggle(!isEnabled);
onClose();
} else {
setShowUpgradeModal(true);
premiumModal.activate('Focused Writing');
}
},
[isEntitled, isEnabled, onToggle, setShowUpgradeModal, onClose]
[isEntitled, onToggle, isEnabled, onClose, premiumModal]
);
return (
@@ -57,11 +57,6 @@ export const FocusModeSwitch: FunctionComponent<Props> = ({
</div>
)}
</button>
<PremiumFeaturesModal
showModal={showUpgradeModal}
featureName="Focus Mode"
onClose={() => setShowUpgradeModal(false)}
/>
</>
);
};