From e49e0c3e6ebb2a2dd886343153bbde31fc38c6a0 Mon Sep 17 00:00:00 2001 From: "s.p.e.c.t.r.e" Date: Tue, 4 Mar 2025 18:53:25 -0300 Subject: [PATCH 01/20] username-display-on-settings Displays username on account settings tab, --- .../src/pages/settings/settings-account.tsx | 510 +++++++++--------- 1 file changed, 255 insertions(+), 255 deletions(-) diff --git a/src/renderer/src/pages/settings/settings-account.tsx b/src/renderer/src/pages/settings/settings-account.tsx index 9cf35541..213ab830 100644 --- a/src/renderer/src/pages/settings/settings-account.tsx +++ b/src/renderer/src/pages/settings/settings-account.tsx @@ -1,255 +1,255 @@ -import { Avatar, Button, SelectField } from "@renderer/components"; -import { Controller, useForm } from "react-hook-form"; -import { useTranslation } from "react-i18next"; -import { useDate, useToast, useUserDetails } from "@renderer/hooks"; -import { useCallback, useContext, useEffect, useState } from "react"; -import { - CloudIcon, - KeyIcon, - MailIcon, - XCircleFillIcon, -} from "@primer/octicons-react"; -import { settingsContext } from "@renderer/context"; -import { AuthPage } from "@shared"; -import "./settings-account.scss"; - -interface FormValues { - profileVisibility: "PUBLIC" | "FRIENDS" | "PRIVATE"; -} - -export function SettingsAccount() { - const { t } = useTranslation("settings"); - - const [isUnblocking, setIsUnblocking] = useState(false); - - const { showSuccessToast } = useToast(); - - const { blockedUsers, fetchBlockedUsers } = useContext(settingsContext); - - const { formatDate } = useDate(); - - const { - control, - formState: { isSubmitting }, - setValue, - handleSubmit, - } = useForm(); - - const { - userDetails, - hasActiveSubscription, - patchUser, - fetchUserDetails, - updateUserDetails, - unblockUser, - } = useUserDetails(); - - useEffect(() => { - if (userDetails?.profileVisibility) { - setValue("profileVisibility", userDetails.profileVisibility); - } - }, [userDetails, setValue]); - - useEffect(() => { - const unsubscribe = window.electron.onAccountUpdated(() => { - fetchUserDetails().then((response) => { - if (response) { - updateUserDetails(response); - } - }); - showSuccessToast(t("account_data_updated_successfully")); - }); - - return () => { - unsubscribe(); - }; - }, [fetchUserDetails, updateUserDetails, t, showSuccessToast]); - - const visibilityOptions = [ - { value: "PUBLIC", label: t("public") }, - { value: "FRIENDS", label: t("friends_only") }, - { value: "PRIVATE", label: t("private") }, - ]; - - const onSubmit = async (values: FormValues) => { - await patchUser(values); - showSuccessToast(t("changes_saved")); - }; - - const handleUnblockClick = useCallback( - (id: string) => { - setIsUnblocking(true); - - unblockUser(id) - .then(() => { - fetchBlockedUsers(); - showSuccessToast(t("user_unblocked")); - }) - .finally(() => { - setIsUnblocking(false); - }); - }, - [unblockUser, fetchBlockedUsers, t, showSuccessToast] - ); - - const getHydraCloudSectionContent = () => { - const hasSubscribedBefore = Boolean(userDetails?.subscription?.expiresAt); - const isRenewalActive = userDetails?.subscription?.status === "active"; - - if (!hasSubscribedBefore) { - return { - description: {t("no_subscription")}, - callToAction: t("become_subscriber"), - }; - } - - if (hasActiveSubscription) { - return { - description: isRenewalActive ? ( - <> - - {t("subscription_renews_on", { - date: formatDate(userDetails.subscription!.expiresAt!), - })} - - {t("bill_sent_until")} - - ) : ( - <> - {t("subscription_renew_cancelled")} - - {t("subscription_active_until", { - date: formatDate(userDetails!.subscription!.expiresAt!), - })} - - - ), - callToAction: t("manage_subscription"), - }; - } - - return { - description: ( - - {t("subscription_expired_at", { - date: formatDate(userDetails!.subscription!.expiresAt!), - })} - - ), - callToAction: t("renew_subscription"), - }; - }; - - if (!userDetails) return null; - - return ( -
- { - const handleChange = ( - event: React.ChangeEvent - ) => { - field.onChange(event); - handleSubmit(onSubmit)(); - }; - - return ( -
- ({ - key: visiblity.value, - value: visiblity.value, - label: visiblity.label, - }))} - disabled={isSubmitting} - /> - - {t("profile_visibility_description")} -
- ); - }} - /> - -
-

{t("current_email")}

-

{userDetails?.email ?? t("no_email_account")}

- -
- - - -
-
- -
-

Hydra Cloud

-
- {getHydraCloudSectionContent().description} -
- - -
- -
-

{t("blocked_users")}

- - {blockedUsers.length > 0 ? ( -
    - {blockedUsers.map((user) => { - return ( -
  • -
    - - {user.displayName} -
    - - -
  • - ); - })} -
- ) : ( - {t("no_users_blocked")} - )} -
- - ); -} +import { Avatar, Button, SelectField } from "@renderer/components"; +import { Controller, useForm } from "react-hook-form"; +import { useTranslation } from "react-i18next"; +import { useDate, useToast, useUserDetails } from "@renderer/hooks"; +import { useCallback, useContext, useEffect, useState } from "react"; +import { + CloudIcon, + KeyIcon, + MailIcon, + XCircleFillIcon, +} from "@primer/octicons-react"; +import { settingsContext } from "@renderer/context"; +import { AuthPage } from "@shared"; +import "./settings-account.scss"; + +interface FormValues { + profileVisibility: "PUBLIC" | "FRIENDS" | "PRIVATE"; +} + +export function SettingsAccount() { + const { t } = useTranslation("settings"); + + const [isUnblocking, setIsUnblocking] = useState(false); + + const { showSuccessToast } = useToast(); + + const { blockedUsers, fetchBlockedUsers } = useContext(settingsContext); + + const { formatDate } = useDate(); + + const { + control, + formState: { isSubmitting }, + setValue, + handleSubmit, + } = useForm(); + + const { + userDetails, + hasActiveSubscription, + patchUser, + fetchUserDetails, + updateUserDetails, + unblockUser, + } = useUserDetails(); + + useEffect(() => { + if (userDetails?.profileVisibility) { + setValue("profileVisibility", userDetails.profileVisibility); + } + }, [userDetails, setValue]); + + useEffect(() => { + const unsubscribe = window.electron.onAccountUpdated(() => { + fetchUserDetails().then((response) => { + if (response) { + updateUserDetails(response); + } + }); + showSuccessToast(t("account_data_updated_successfully")); + }); + + return () => { + unsubscribe(); + }; + }, [fetchUserDetails, updateUserDetails, t, showSuccessToast]); + + const visibilityOptions = [ + { value: "PUBLIC", label: t("public") }, + { value: "FRIENDS", label: t("friends_only") }, + { value: "PRIVATE", label: t("private") }, + ]; + + const onSubmit = async (values: FormValues) => { + await patchUser(values); + showSuccessToast(t("changes_saved")); + }; + + const handleUnblockClick = useCallback( + (id: string) => { + setIsUnblocking(true); + + unblockUser(id) + .then(() => { + fetchBlockedUsers(); + showSuccessToast(t("user_unblocked")); + }) + .finally(() => { + setIsUnblocking(false); + }); + }, + [unblockUser, fetchBlockedUsers, t, showSuccessToast] + ); + + const getHydraCloudSectionContent = () => { + const hasSubscribedBefore = Boolean(userDetails?.subscription?.expiresAt); + const isRenewalActive = userDetails?.subscription?.status === "active"; + + if (!hasSubscribedBefore) { + return { + description: {t("no_subscription")}, + callToAction: t("become_subscriber"), + }; + } + + if (hasActiveSubscription) { + return { + description: isRenewalActive ? ( + <> + + {t("subscription_renews_on", { + date: formatDate(userDetails.subscription!.expiresAt!), + })} + + {t("bill_sent_until")} + + ) : ( + <> + {t("subscription_renew_cancelled")} + + {t("subscription_active_until", { + date: formatDate(userDetails!.subscription!.expiresAt!), + })} + + + ), + callToAction: t("manage_subscription"), + }; + } + + return { + description: ( + + {t("subscription_expired_at", { + date: formatDate(userDetails!.subscription!.expiresAt!), + })} + + ), + callToAction: t("renew_subscription"), + }; + }; + + if (!userDetails) return null; + + return ( +
+ { + const handleChange = ( + event: React.ChangeEvent + ) => { + field.onChange(event); + handleSubmit(onSubmit)(); + }; + + return ( +
+ ({ + key: visiblity.value, + value: visiblity.value, + label: visiblity.label, + }))} + disabled={isSubmitting} + /> + + {t("profile_visibility_description")} +
+ ); + }} + /> + +
+

{t("current_email")}

+

{userDetails?.email ?? t("no_email_account")}

+

Nome de usuário:

+

{userDetails?.username}

+
+ + + +
+
+
+

Hydra Cloud

+
+ {getHydraCloudSectionContent().description} +
+ + +
+ +
+

{t("blocked_users")}

+ + {blockedUsers.length > 0 ? ( +
    + {blockedUsers.map((user) => { + return ( +
  • +
    + + {user.displayName} +
    + + +
  • + ); + })} +
+ ) : ( + {t("no_users_blocked")} + )} +
+ + ); +} From 75cb93208762c152970ba1e041c9409ea1a71fde Mon Sep 17 00:00:00 2001 From: "s.p.e.c.t.r.e" Date: Tue, 4 Mar 2025 19:01:53 -0300 Subject: [PATCH 02/20] Update src/renderer/src/pages/settings/settings-account.tsx Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --- src/renderer/src/pages/settings/settings-account.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/src/pages/settings/settings-account.tsx b/src/renderer/src/pages/settings/settings-account.tsx index 213ab830..641a6772 100644 --- a/src/renderer/src/pages/settings/settings-account.tsx +++ b/src/renderer/src/pages/settings/settings-account.tsx @@ -178,7 +178,7 @@ export function SettingsAccount() {

{t("current_email")}

{userDetails?.email ?? t("no_email_account")}

-

Nome de usuário:

+

{t("username")}

{userDetails?.username}

- - -
-
-
-

Hydra Cloud

-
- {getHydraCloudSectionContent().description} -
- - -
- -
-

{t("blocked_users")}

- - {blockedUsers.length > 0 ? ( -
    - {blockedUsers.map((user) => { - return ( -
  • -
    - - {user.displayName} -
    - - -
  • - ); - })} -
- ) : ( - {t("no_users_blocked")} - )} -
- - ); -} From f41f6a0f00a9f0c861a9708fc0d4d3d801ced5e6 Mon Sep 17 00:00:00 2001 From: "s.p.e.c.t.r.e" Date: Tue, 4 Mar 2025 19:57:31 -0300 Subject: [PATCH 04/20] username-display-on-account-settings --- .../src/pages/settings/settings-account.tsx | 255 ++++++++++++++++++ 1 file changed, 255 insertions(+) create mode 100644 src/renderer/src/pages/settings/settings-account.tsx diff --git a/src/renderer/src/pages/settings/settings-account.tsx b/src/renderer/src/pages/settings/settings-account.tsx new file mode 100644 index 00000000..49e8bc4d --- /dev/null +++ b/src/renderer/src/pages/settings/settings-account.tsx @@ -0,0 +1,255 @@ +import { Avatar, Button, SelectField } from "@renderer/components"; +import { Controller, useForm } from "react-hook-form"; +import { useTranslation } from "react-i18next"; +import { useDate, useToast, useUserDetails } from "@renderer/hooks"; +import { useCallback, useContext, useEffect, useState } from "react"; +import { + CloudIcon, + KeyIcon, + MailIcon, + XCircleFillIcon, +} from "@primer/octicons-react"; +import { settingsContext } from "@renderer/context"; +import { AuthPage } from "@shared"; +import "./settings-account.scss"; + +interface FormValues { + profileVisibility: "PUBLIC" | "FRIENDS" | "PRIVATE"; +} + +export function SettingsAccount() { + const { t } = useTranslation("settings"); + + const [isUnblocking, setIsUnblocking] = useState(false); + + const { showSuccessToast } = useToast(); + + const { blockedUsers, fetchBlockedUsers } = useContext(settingsContext); + + const { formatDate } = useDate(); + + const { + control, + formState: { isSubmitting }, + setValue, + handleSubmit, + } = useForm(); + + const { + userDetails, + hasActiveSubscription, + patchUser, + fetchUserDetails, + updateUserDetails, + unblockUser, + } = useUserDetails(); + + useEffect(() => { + if (userDetails?.profileVisibility) { + setValue("profileVisibility", userDetails.profileVisibility); + } + }, [userDetails, setValue]); + + useEffect(() => { + const unsubscribe = window.electron.onAccountUpdated(() => { + fetchUserDetails().then((response) => { + if (response) { + updateUserDetails(response); + } + }); + showSuccessToast(t("account_data_updated_successfully")); + }); + + return () => { + unsubscribe(); + }; + }, [fetchUserDetails, updateUserDetails, t, showSuccessToast]); + + const visibilityOptions = [ + { value: "PUBLIC", label: t("public") }, + { value: "FRIENDS", label: t("friends_only") }, + { value: "PRIVATE", label: t("private") }, + ]; + + const onSubmit = async (values: FormValues) => { + await patchUser(values); + showSuccessToast(t("changes_saved")); + }; + + const handleUnblockClick = useCallback( + (id: string) => { + setIsUnblocking(true); + + unblockUser(id) + .then(() => { + fetchBlockedUsers(); + showSuccessToast(t("user_unblocked")); + }) + .finally(() => { + setIsUnblocking(false); + }); + }, + [unblockUser, fetchBlockedUsers, t, showSuccessToast] + ); + + const getHydraCloudSectionContent = () => { + const hasSubscribedBefore = Boolean(userDetails?.subscription?.expiresAt); + const isRenewalActive = userDetails?.subscription?.status === "active"; + + if (!hasSubscribedBefore) { + return { + description: {t("no_subscription")}, + callToAction: t("become_subscriber"), + }; + } + + if (hasActiveSubscription) { + return { + description: isRenewalActive ? ( + <> + + {t("subscription_renews_on", { + date: formatDate(userDetails.subscription!.expiresAt!), + })} + + {t("bill_sent_until")} + + ) : ( + <> + {t("subscription_renew_cancelled")} + + {t("subscription_active_until", { + date: formatDate(userDetails!.subscription!.expiresAt!), + })} + + + ), + callToAction: t("manage_subscription"), + }; + } + + return { + description: ( + + {t("subscription_expired_at", { + date: formatDate(userDetails!.subscription!.expiresAt!), + })} + + ), + callToAction: t("renew_subscription"), + }; + }; + + if (!userDetails) return null; + + return ( +
+ { + const handleChange = ( + event: React.ChangeEvent + ) => { + field.onChange(event); + handleSubmit(onSubmit)(); + }; + + return ( +
+ ({ + key: visiblity.value, + value: visiblity.value, + label: visiblity.label, + }))} + disabled={isSubmitting} + /> + + {t("profile_visibility_description")} +
+ ); + }} + /> + +
+

{t("current_email")}

+

{userDetails?.email ?? t("no_email_account")}

+

{t("username")}

+

{userDetails?.username}

+
+ + + +
+
+
+

Hydra Cloud

+
+ {getHydraCloudSectionContent().description} +
+ + +
+ +
+

{t("blocked_users")}

+ + {blockedUsers.length > 0 ? ( +
    + {blockedUsers.map((user) => { + return ( +
  • +
    + + {user.displayName} +
    + + +
  • + ); + })} +
+ ) : ( + {t("no_users_blocked")} + )} +
+ + ); +} From 49a467ff468bbc804d2a7a3efe3abe56dbfbd749 Mon Sep 17 00:00:00 2001 From: "s.p.e.c.t.r.e" Date: Tue, 4 Mar 2025 19:58:50 -0300 Subject: [PATCH 05/20] Update translation.json --- src/locales/en/translation.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json index f1e85019..2a75ec64 100644 --- a/src/locales/en/translation.json +++ b/src/locales/en/translation.json @@ -231,6 +231,7 @@ "options": "Manage" }, "settings": { + "username": "Username:", "downloads_path": "Downloads path", "change": "Update", "notifications": "Notifications", From f2b7d30c008a5b123a22255eddeca585d22ec36a Mon Sep 17 00:00:00 2001 From: "s.p.e.c.t.r.e" Date: Tue, 4 Mar 2025 19:59:40 -0300 Subject: [PATCH 06/20] Update translation.json --- src/locales/es/translation.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/locales/es/translation.json b/src/locales/es/translation.json index 27e18f34..12717d34 100644 --- a/src/locales/es/translation.json +++ b/src/locales/es/translation.json @@ -225,6 +225,7 @@ "options": "Gestionar" }, "settings": { + "username": "Nombre de usuário", "downloads_path": "Ruta de descarga", "change": "Cambiar", "notifications": "Notificaciones", From 7092720a900ebefff1c23baddc2cbc18ebf3d90a Mon Sep 17 00:00:00 2001 From: "s.p.e.c.t.r.e" Date: Tue, 4 Mar 2025 20:00:50 -0300 Subject: [PATCH 07/20] Update translation.json --- src/locales/pt-BR/translation.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/locales/pt-BR/translation.json b/src/locales/pt-BR/translation.json index 0cefd188..c2ae8dd0 100644 --- a/src/locales/pt-BR/translation.json +++ b/src/locales/pt-BR/translation.json @@ -221,6 +221,7 @@ "options": "Gerenciar" }, "settings": { + "username": "Nome de usuário:", "downloads_path": "Diretório dos downloads", "change": "Explorar...", "notifications": "Notificações", From 6a8d15b421b27945dbd83c9db97105af183978e4 Mon Sep 17 00:00:00 2001 From: "s.p.e.c.t.r.e" Date: Tue, 4 Mar 2025 20:01:29 -0300 Subject: [PATCH 08/20] Update translation.json --- src/locales/ru/translation.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/locales/ru/translation.json b/src/locales/ru/translation.json index c2aa40ce..e7ac14cf 100644 --- a/src/locales/ru/translation.json +++ b/src/locales/ru/translation.json @@ -229,6 +229,7 @@ "options": "Управлять" }, "settings": { + "username": "Имя пользователя:", "downloads_path": "Путь загрузок", "change": "Изменить", "notifications": "Уведомления", From 401dd13b85ebcd2f2897054bfe21181c53c68081 Mon Sep 17 00:00:00 2001 From: Eight Date: Tue, 4 Mar 2025 20:22:32 -0300 Subject: [PATCH 09/20] Update src/locales/es/translation.json Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --- src/locales/es/translation.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/locales/es/translation.json b/src/locales/es/translation.json index 12717d34..c463a94a 100644 --- a/src/locales/es/translation.json +++ b/src/locales/es/translation.json @@ -225,7 +225,7 @@ "options": "Gestionar" }, "settings": { - "username": "Nombre de usuário", + "username": "Nombre de usuario", "downloads_path": "Ruta de descarga", "change": "Cambiar", "notifications": "Notificaciones", From 1b55c3f8a0fbdc00ae60416c4584987fd07f0b3a Mon Sep 17 00:00:00 2001 From: Eight Date: Tue, 4 Mar 2025 20:23:33 -0300 Subject: [PATCH 10/20] Update src/renderer/src/pages/settings/settings-account.tsx Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --- src/renderer/src/pages/settings/settings-account.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/src/pages/settings/settings-account.tsx b/src/renderer/src/pages/settings/settings-account.tsx index 49e8bc4d..edb5a645 100644 --- a/src/renderer/src/pages/settings/settings-account.tsx +++ b/src/renderer/src/pages/settings/settings-account.tsx @@ -161,7 +161,7 @@ export function SettingsAccount() { label={t("profile_visibility")} value={field.value} onChange={handleChange} - options={visibilityOptions.map((visiblity) => ({ + options={visibilityOptions.map((visibility) => ({ key: visiblity.value, value: visiblity.value, label: visiblity.label, From 839a38ebfff6caab528c34c53d3bc420eddeaead Mon Sep 17 00:00:00 2001 From: "s.p.e.c.t.r.e" Date: Tue, 4 Mar 2025 21:01:57 -0300 Subject: [PATCH 11/20] Update settings-account.tsx --- src/renderer/src/pages/settings/settings-account.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/src/pages/settings/settings-account.tsx b/src/renderer/src/pages/settings/settings-account.tsx index edb5a645..cc74fff1 100644 --- a/src/renderer/src/pages/settings/settings-account.tsx +++ b/src/renderer/src/pages/settings/settings-account.tsx @@ -178,7 +178,7 @@ export function SettingsAccount() {

{t("current_email")}

{userDetails?.email ?? t("no_email_account")}

-

{t("username")}

+

{t("username")}:

{userDetails?.username}