A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
feat: open directly to approp slide in buy dialog
thecodrraa8bcda3c204
diff --git a/apps/web/src/app.js b/apps/web/src/app.jsindex 2139d1b7a..d3ad809a7 100644--- a/apps/web/src/app.js+++ b/apps/web/src/app.js@@ -84,7 +84,7 @@ function App() {if (isUserPremium()) {return { type, result: true };} else {- await showBuyDialog();+ await showBuyDialog(type);return { type, result: false };}});diff --git a/apps/web/src/components/accent-item/index.js b/apps/web/src/components/accent-item/index.jsindex ceaa439e4..0e09004e6 100644--- a/apps/web/src/components/accent-item/index.js+++ b/apps/web/src/components/accent-item/index.js@@ -17,7 +17,7 @@ function AccentItem(props) {onClick={async () => {if (isUserPremium()) setAccent(code);else {- await showBuyDialog();+ await showBuyDialog("customize");}}}key={label}diff --git a/apps/web/src/components/dialogs/buydialog.js b/apps/web/src/components/dialogs/buydialog.jsindex 8d8c01359..329ee33d0 100644--- a/apps/web/src/components/dialogs/buydialog.js+++ b/apps/web/src/components/dialogs/buydialog.js@@ -16,7 +16,21 @@ import { ReactComponent as Vault } from "../../assets/vault.svg";import "react-responsive-carousel/lib/styles/carousel.min.css"; // requires a loaderimport { Carousel } from "react-responsive-carousel";import { changeSvgTheme } from "../../utils/css";+import { CHECK_IDS } from "notes-core/common";+const itemIdToIndex = {+ sync: 0,+ editor: 3,+ backups: 5,+ customize: 6,+ discord: 7,+ [CHECK_IDS.noteExport]: 4,+ [CHECK_IDS.noteColor]: 1,+ [CHECK_IDS.noteTag]: 1,+ [CHECK_IDS.notebookAdd]: 1,+ [CHECK_IDS.vaultAdd]: 2,+ [CHECK_IDS.backupEncrypt]: 5,+};const premiumDetails = [{title: "Automatic syncing",@@ -89,24 +103,31 @@ const premiumDetails = [];function BuyDialog(props) {+ const { initialIndex } = props;const isLoggedIn = useUserStore((store) => store.isLoggedIn);const user = useUserStore((store) => store.user);const accent = useThemeStore((store) => store.accent);- useEffect(() => {- changeSvgTheme(accent);- }, [accent]);- const [slideIndex, setSlideIndex] = useState(0);return (- <Dialog isOpen={true} showClose onClose={props.onCancel} scrollable>+ <Dialog+ isOpen={true}+ showClose+ onClose={props.onCancel}+ scrollable+ onOpen={() => changeSvgTheme(accent)}+ ><Flex flexDirection="column" flex={1}><Carousel+ infiniteLoopautoPlayshowStatus={false}swipeableemulateTouchshowArrowsuseKeyboardArrows+ interval={5000}+ stopOnHover+ selectedItem={initialIndex}showThumbs={false}showIndicators={false}renderArrowNext={(click, hasNext) => (@@ -212,6 +233,11 @@ function BuyDialog(props) {);}-export function showBuyDialog() {- return showDialog((perform) => <BuyDialog onCancel={() => perform(false)} />);+export function showBuyDialog(initialItemId) {+ return showDialog((perform) => (+ <BuyDialog+ initialIndex={itemIdToIndex[initialItemId]}+ onCancel={() => perform(false)}+ />+ ));}diff --git a/apps/web/src/components/dialogs/dialog.js b/apps/web/src/components/dialogs/dialog.jsindex 8600efe35..4dd6e8ba8 100644--- a/apps/web/src/components/dialogs/dialog.js+++ b/apps/web/src/components/dialogs/dialog.js@@ -31,6 +31,7 @@ function Dialog(props) {props.onClose();}};+ if (props.onOpen) props.onOpen();}}style={{content: {diff --git a/apps/web/src/components/editor/tinymce.js b/apps/web/src/components/editor/tinymce.jsindex 4f818b6a9..791e15426 100644--- a/apps/web/src/components/editor/tinymce.js+++ b/apps/web/src/components/editor/tinymce.js@@ -196,12 +196,12 @@ function TinyMCE(props) {onBeforeExecCommand={async (command) => {if (premiumCommands.some(- (cmd) => command.command === cmd && !command.value.paste+ (cmd) => command.command === cmd && !command?.value?.paste) &&!isUserPremium()) {command.preventDefault();- await showBuyDialog();+ await showBuyDialog("editor");return;}}}diff --git a/apps/web/src/views/settings.js b/apps/web/src/views/settings.jsindex 720b1345a..c8a9842d9 100644--- a/apps/web/src/views/settings.js+++ b/apps/web/src/views/settings.js@@ -27,6 +27,7 @@ import { showPasswordDialog } from "../components/dialogs/passworddialog";import { hashNavigate } from "../navigation";import useVersion from "../utils/useVersion";import http from "notes-core/utils/http";+import { CHECK_IDS } from "notes-core/common";function importBackup() {return new Promise((resolve, reject) => {@@ -253,7 +254,7 @@ function Settings(props) {title="Follow system theme"onTip="Switch app theme according to system"offTip="Keep app theme independent"- premium+ premium="customize"onToggled={toggleFollowSystemTheme}isToggled={followSystemTheme}/>@@ -318,7 +319,7 @@ function Settings(props) {onTip="All backups will be encrypted"offTip="Backups will not be encrypted"onToggled={toggleEncryptBackups}- premium+ premium={CHECK_IDS.backupEncrypt}isToggled={encryptBackups}/>@@ -326,6 +327,7 @@ function Settings(props) {title="Backup reminders"tip="Remind me to backup my data"options={["Never", "Daily", "Weekly", "Monthly"]}+ premium="backups"selectedOption={backupReminderOffset}onSelectionChanged={(_option, index) =>setBackupReminderOffset(index)@@ -413,7 +415,7 @@ function ToggleItem(props) {onClick={async () => {if (isUserPremium() || !premium) onToggled();else {- await showBuyDialog();+ await showBuyDialog(premium);}}}py={2}@@ -442,6 +444,7 @@ function OptionsItem(props) {selectedOption,onSelectionChanged,onlyIf,+ premium,} = props;if (onlyIf === false) return null;@@ -474,7 +477,13 @@ function OptionsItem(props) {variant="subBody"p={2}py={1}- onClick={() => onSelectionChanged(option, index)}+ onClick={async () => {+ if (isUserPremium() || !premium)+ onSelectionChanged(option, index);+ else {+ await showBuyDialog(premium);+ }+ }}sx={{":hover": { color: selectedOption === index ? "static" : "text" },}}