mirror of
https://github.com/danog/telegram-tt.git
synced 2025-01-22 05:11:55 +01:00
Calendar: Fix inconsistent time (#1328)
This commit is contained in:
parent
fdf4235383
commit
3004c27130
@ -5,6 +5,7 @@ import React, {
|
||||
import buildClassName from '../../util/buildClassName';
|
||||
import { formatTime, formatDateToString } from '../../util/dateFormat';
|
||||
import useLang, { LangFn } from '../../hooks/useLang';
|
||||
import usePrevious from '../../hooks/usePrevious';
|
||||
|
||||
import Modal from '../ui/Modal';
|
||||
import Button from '../ui/Button';
|
||||
@ -52,6 +53,7 @@ const CalendarModal: FC<OwnProps> = ({
|
||||
const now = new Date();
|
||||
const defaultSelectedDate = useMemo(() => (selectedAt ? new Date(selectedAt) : new Date()), [selectedAt]);
|
||||
const maxDate = maxAt ? new Date(maxAt) : undefined;
|
||||
const prevIsOpen = usePrevious(isOpen);
|
||||
|
||||
const [selectedDate, setSelectedDate] = useState<Date>(defaultSelectedDate);
|
||||
const [selectedHours, setSelectedHours] = useState<string>(
|
||||
@ -66,10 +68,10 @@ const CalendarModal: FC<OwnProps> = ({
|
||||
const currentDate = selectedDate.getDate();
|
||||
|
||||
useEffect(() => {
|
||||
if (isOpen) {
|
||||
if (!prevIsOpen && isOpen) {
|
||||
setSelectedDate(defaultSelectedDate);
|
||||
}
|
||||
}, [isOpen, defaultSelectedDate]);
|
||||
}, [isOpen, defaultSelectedDate, prevIsOpen]);
|
||||
|
||||
const shouldDisableNextMonth = (isPastMode && currentYear >= now.getFullYear() && currentMonth >= now.getMonth())
|
||||
|| (maxDate && currentYear >= maxDate.getFullYear() && currentMonth >= maxDate.getMonth());
|
||||
|
@ -60,6 +60,7 @@ const READABLE_ERROR_MESSAGES: Record<string, string> = {
|
||||
INVITE_HASH_INVALID: 'The invite hash is invalid',
|
||||
CHANNELS_TOO_MUCH: 'You have joined too many channels/supergroups',
|
||||
USER_ALREADY_PARTICIPANT: 'You already in the group',
|
||||
SCHEDULE_DATE_INVALID: 'Invalid schedule date provided',
|
||||
};
|
||||
|
||||
export default function getReadableErrorText(error: ApiError) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user