π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Swap
Manav Rathi61eb7c0e996d
diff --git a/web/apps/photos/src/components/Collections/AlbumCastDialog.tsx b/web/apps/photos/src/components/Collections/AlbumCastDialog.tsxindex 36a4d953cc..9feab319b5 100644--- a/web/apps/photos/src/components/Collections/AlbumCastDialog.tsx+++ b/web/apps/photos/src/components/Collections/AlbumCastDialog.tsx@@ -2,6 +2,11 @@ import { Link, Stack, Typography } from "@mui/material";import { TitledMiniDialog } from "ente-base/components/MiniDialog";import { ActivityIndicator } from "ente-base/components/mui/ActivityIndicator";import { FocusVisibleButton } from "ente-base/components/mui/FocusVisibleButton";+import {+ SingleInputForm,+ type SingleInputFormProps,+} from "ente-base/components/SingleInputForm";+import type { ModalVisibilityProps } from "ente-base/components/utils/modal";import log from "ente-base/log";import type { Collection } from "ente-media/collection";import { useSettingsSnapshot } from "ente-new/photos/components/utils/use-snapshot";@@ -11,21 +16,14 @@ import {unknownDeviceCodeErrorMessage,} from "ente-new/photos/services/cast";import { loadCast } from "ente-new/photos/utils/chromecast-sender";-import SingleInputForm, {- type SingleInputFormProps,-} from "ente-shared/components/SingleInputForm";import { t } from "i18next";-import { useEffect, useState } from "react";+import { useCallback, useEffect, useState } from "react";import { Trans } from "react-i18next";-interface AlbumCastDialogProps {- /** If `true`, the dialog is shown. */- open: boolean;- /** Callback fired when the dialog wants to be closed. */- onClose: () => void;+type AlbumCastDialogProps = ModalVisibilityProps & {/** The collection that we want to cast. */collection: Collection;-}+};/*** A dialog that shows various options that the user has for casting an album.@@ -56,25 +54,25 @@ export const AlbumCastDialog: React.FC<AlbumCastDialogProps> = ({setBrowserCanCast(typeof window["chrome"] != "undefined");}, []);- const onSubmit: SingleInputFormProps["callback"] = async (- value,- setFieldError,- ) => {- try {- await publishCastPayload(value.trim(), collection);- onClose();- } catch (e) {- log.error("Failed to cast", e);- if (- e instanceof Error &&- e.message == unknownDeviceCodeErrorMessage- ) {- setFieldError(t("tv_not_found"));- } else {- setFieldError(t("generic_error_retry"));+ const onSubmit: SingleInputFormProps["onSubmit"] = useCallback(+ async (value, showError) => {+ try {+ await publishCastPayload(value.trim(), collection);+ onClose();+ } catch (e) {+ log.error("Failed to cast", e);+ if (+ e instanceof Error &&+ e.message == unknownDeviceCodeErrorMessage+ ) {+ showError(t("tv_not_found"));+ } else {+ throw e;+ }}- }- };+ },+ [onClose, collection],+ );useEffect(() => {if (view == "auto") {@@ -195,12 +193,11 @@ export const AlbumCastDialog: React.FC<AlbumCastDialogProps> = ({</Typography></Stack><SingleInputForm- callback={onSubmit}- fieldType="text"- realLabel={t("code")}- realPlaceholder={"123456"}- buttonText={t("pair_device_to_tv")}- submitButtonProps={{ sx: { mt: 1, mb: 2 } }}+ label={t("code")}+ placeholder={"123456"}+ submitButtonTitle={t("pair_device_to_tv")}+ submitButtonColor="accent"+ onSubmit={onSubmit}/><FocusVisibleButtonvariant="text"diff --git a/web/packages/base/components/SingleInputForm.tsx b/web/packages/base/components/SingleInputForm.tsxindex 00c04f4935..3592156d27 100644--- a/web/packages/base/components/SingleInputForm.tsx+++ b/web/packages/base/components/SingleInputForm.tsx@@ -1,4 +1,9 @@-import { Stack, TextField, type TextFieldProps } from "@mui/material";+import {+ Stack,+ TextField,+ type ButtonProps,+ type TextFieldProps,+} from "@mui/material";import { FocusVisibleButton } from "ente-base/components/mui/FocusVisibleButton";import { LoadingButton } from "ente-base/components/mui/LoadingButton";import log from "ente-base/log";@@ -20,6 +25,12 @@ export type SingleInputFormProps = Pick<* Title for the submit button.*/submitButtonTitle: string;+ /**+ * Color of the submit button.+ *+ * Default: "primary".+ */+ submitButtonColor?: ButtonProps["color"];/*** Cancellation handler.*@@ -74,6 +85,7 @@ export type SingleInputFormProps = Pick<export const SingleInputForm: React.FC<SingleInputFormProps> = ({initialValue,submitButtonTitle,+ submitButtonColor,onCancel,onSubmit,...rest@@ -101,9 +113,9 @@ export const SingleInputForm: React.FC<SingleInputFormProps> = ({const submitButton = (<LoadingButtonfullWidth- color="primary"type="submit"loading={formik.isSubmitting}+ color={submitButtonColor ?? "primary"}>{submitButtonTitle}</LoadingButton>