From 7827a35de9155653ad01c29ec807eb33b0bc1c38 Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Mon, 4 Mar 2024 11:06:51 +0500 Subject: [PATCH] web: show error if there's no internet on updating profile --- .../settings/components/user-profile.tsx | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/apps/web/src/dialogs/settings/components/user-profile.tsx b/apps/web/src/dialogs/settings/components/user-profile.tsx index 61977a447..08dc21c29 100644 --- a/apps/web/src/dialogs/settings/components/user-profile.tsx +++ b/apps/web/src/dialogs/settings/components/user-profile.tsx @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -import { Button, Flex, Image, Text } from "@theme-ui/components"; +import { Flex, Image, Text } from "@theme-ui/components"; import { Edit, User } from "../../../components/icons"; import { useStore as useUserStore } from "../../../stores/user-store"; import { getObjectIdTimestamp } from "@notesnook/core/dist/utils/object-id"; @@ -26,7 +26,6 @@ import { SUBSCRIPTION_STATUS } from "../../../common/constants"; import dayjs from "dayjs"; import { useMemo } from "react"; import { - showEditProfileDialog, showEditProfilePictureDialog, showPromptDialog } from "../../../common/dialog-controller"; @@ -160,10 +159,10 @@ export function UserProfile() { {remainingDays > 0 && (isPro || isProCancelled) ? `PRO` : remainingDays > 0 && isTrial - ? "TRIAL" - : isBeta - ? "BETA TESTER" - : "BASIC"} + ? "TRIAL" + : isBeta + ? "BETA TESTER" + : "BASIC"} @@ -179,11 +178,15 @@ export function UserProfile() { "Your profile data is 100% end-to-end encrypted.", defaultValue: profile?.fullName }); - useUserStore.setState({ - profile: { ...profile, fullName: fullName || undefined } - }); - await db.user.setProfile({ fullName: fullName || undefined }); - showToast("success", "Full name updated!"); + try { + await db.user.setProfile({ fullName: fullName || undefined }); + useUserStore.setState({ + profile: { ...profile, fullName: fullName || undefined } + }); + showToast("success", "Full name updated!"); + } catch (e) { + showToast("error", (e as Error).message); + } }} />