Merge branch 'fix-input-field-error-not-shown' into uncategorised

This commit is contained in:
Abhinav 2023-02-02 13:28:42 +05:30
commit e64f1c9ad7
3 changed files with 37 additions and 22 deletions

View file

@ -15,7 +15,8 @@ export default function EmailShare({ collection }) {
const collectionShare: SingleInputFormProps['callback'] = async (
email,
setFieldError
setFieldError,
resetForm
) => {
try {
const user: User = getData(LS_KEYS.USER);
@ -28,6 +29,7 @@ export default function EmailShare({ collection }) {
} else {
await shareCollection(collection, email);
await galleryContext.syncWithRemote(false, true);
resetForm();
}
} catch (e) {
const errorMessage = handleSharingErrors(e);

View file

@ -400,6 +400,7 @@ function PhotoViewer(props: Iprops) {
};
const updateItems = (items = []) => {
try {
if (photoSwipe) {
if (items.length === 0) {
photoSwipe.close();
@ -408,21 +409,31 @@ function PhotoViewer(props: Iprops) {
items.forEach((item) => {
photoSwipe.items.push(item);
});
photoSwipe.invalidateCurrItems();
if (isOpen) {
photoSwipe.updateSize(true);
if (photoSwipe.getCurrentIndex() >= photoSwipe.items.length) {
if (
photoSwipe.getCurrentIndex() >= photoSwipe.items.length
) {
photoSwipe.goTo(0);
}
}
}
} catch (e) {
logError(e, 'updateItems failed');
}
};
const refreshPhotoswipe = () => {
try {
photoSwipe.invalidateCurrItems();
if (isOpen) {
photoSwipe.updateSize(true);
}
} catch (e) {
logError(e, 'refreshPhotoswipe failed');
}
};
const checkExifAvailable = async (file: EnteFile) => {

View file

@ -1,6 +1,6 @@
import React, { useMemo, useState } from 'react';
import constants from 'utils/strings/constants';
import { Formik, FormikHelpers } from 'formik';
import { Formik, FormikHelpers, FormikState } from 'formik';
import * as Yup from 'yup';
import SubmitButton from './SubmitButton';
import TextField from '@mui/material/TextField';
@ -14,7 +14,8 @@ interface formValues {
export interface SingleInputFormProps {
callback: (
inputValue: string,
setFieldError: (errorMessage: string) => void
setFieldError: (errorMessage: string) => void,
resetForm: (nextState?: Partial<FormikState<formValues>>) => void
) => Promise<void>;
fieldType: 'text' | 'email' | 'password';
placeholder: string;
@ -43,10 +44,11 @@ export default function SingleInputForm(props: SingleInputFormProps) {
{ setFieldError, resetForm }: FormikHelpers<formValues>
) => {
SetLoading(true);
await props.callback(values.inputValue, (message) =>
setFieldError('inputValue', message)
await props.callback(
values.inputValue,
(message) => setFieldError('inputValue', message),
resetForm
);
resetForm();
SetLoading(false);
};