[Perf] Calendar Modal: Small optimizations
This commit is contained in:
parent
77cdea4f75
commit
a231adc664
@ -130,6 +130,10 @@ const CalendarModal: FC<OwnProps> = ({
|
|||||||
buildCalendarGrid(currentYear, currentMonth)
|
buildCalendarGrid(currentYear, currentMonth)
|
||||||
), [currentMonth, currentYear]);
|
), [currentMonth, currentYear]);
|
||||||
|
|
||||||
|
const submitLabel = useMemo(() => {
|
||||||
|
return submitButtonLabel || formatSubmitLabel(lang, selectedDate);
|
||||||
|
}, [lang, selectedDate, submitButtonLabel]);
|
||||||
|
|
||||||
function handlePrevMonth() {
|
function handlePrevMonth() {
|
||||||
setCurrentMonthAndYear((d) => {
|
setCurrentMonthAndYear((d) => {
|
||||||
const dateCopy = new Date(d);
|
const dateCopy = new Date(d);
|
||||||
@ -312,7 +316,7 @@ const CalendarModal: FC<OwnProps> = ({
|
|||||||
|
|
||||||
<div className="footer">
|
<div className="footer">
|
||||||
<Button onClick={handleSubmit}>
|
<Button onClick={handleSubmit}>
|
||||||
{submitButtonLabel || formatSubmitLabel(lang, selectedDate)}
|
{submitLabel}
|
||||||
</Button>
|
</Button>
|
||||||
{secondButtonLabel && (
|
{secondButtonLabel && (
|
||||||
<Button onClick={onSecondButtonClick} isText>
|
<Button onClick={onSecondButtonClick} isText>
|
||||||
|
|||||||
@ -29,6 +29,7 @@ import ReportMessageModal from '../../common/ReportMessageModal';
|
|||||||
import PinMessageModal from '../../common/PinMessageModal';
|
import PinMessageModal from '../../common/PinMessageModal';
|
||||||
import MessageContextMenu from './MessageContextMenu';
|
import MessageContextMenu from './MessageContextMenu';
|
||||||
import CalendarModal from '../../common/CalendarModal';
|
import CalendarModal from '../../common/CalendarModal';
|
||||||
|
import buildClassName from '../../../util/buildClassName';
|
||||||
|
|
||||||
const START_SIZE = 2 * REM;
|
const START_SIZE = 2 * REM;
|
||||||
|
|
||||||
@ -322,7 +323,7 @@ const ContextMenuContainer: FC<OwnProps & StateProps> = ({
|
|||||||
scheduledMaxDate.setFullYear(scheduledMaxDate.getFullYear() + 1);
|
scheduledMaxDate.setFullYear(scheduledMaxDate.getFullYear() + 1);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={['ContextMenuContainer', transitionClassNames].join(' ')}>
|
<div className={buildClassName('ContextMenuContainer', transitionClassNames)}>
|
||||||
<MessageContextMenu
|
<MessageContextMenu
|
||||||
availableReactions={availableReactions}
|
availableReactions={availableReactions}
|
||||||
message={message}
|
message={message}
|
||||||
@ -388,15 +389,17 @@ const ContextMenuContainer: FC<OwnProps & StateProps> = ({
|
|||||||
chatId={message.chatId}
|
chatId={message.chatId}
|
||||||
onClose={closePinModal}
|
onClose={closePinModal}
|
||||||
/>
|
/>
|
||||||
<CalendarModal
|
{canReschedule && (
|
||||||
isOpen={isCalendarOpen}
|
<CalendarModal
|
||||||
withTimePicker
|
isOpen={isCalendarOpen}
|
||||||
selectedAt={message.date * 1000}
|
withTimePicker
|
||||||
maxAt={getDayStartAt(scheduledMaxDate)}
|
selectedAt={message.date * 1000}
|
||||||
isFutureMode
|
maxAt={getDayStartAt(scheduledMaxDate)}
|
||||||
onClose={handleCloseCalendar}
|
isFutureMode
|
||||||
onSubmit={handleRescheduleMessage}
|
onClose={handleCloseCalendar}
|
||||||
/>
|
onSubmit={handleRescheduleMessage}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -16,9 +16,9 @@ import { getServerTime } from '../../../util/serverTime';
|
|||||||
import Checkbox from '../../ui/Checkbox';
|
import Checkbox from '../../ui/Checkbox';
|
||||||
import InputText from '../../ui/InputText';
|
import InputText from '../../ui/InputText';
|
||||||
import RadioGroup from '../../ui/RadioGroup';
|
import RadioGroup from '../../ui/RadioGroup';
|
||||||
import CalendarModalAsync from '../../common/CalendarModal.async';
|
|
||||||
import Button from '../../ui/Button';
|
import Button from '../../ui/Button';
|
||||||
import FloatingActionButton from '../../ui/FloatingActionButton';
|
import FloatingActionButton from '../../ui/FloatingActionButton';
|
||||||
|
import CalendarModal from '../../common/CalendarModal';
|
||||||
|
|
||||||
const DEFAULT_USAGE_LIMITS = [1, 10, 100];
|
const DEFAULT_USAGE_LIMITS = [1, 10, 100];
|
||||||
const DEFAULT_EXPIRE_DATE = {
|
const DEFAULT_EXPIRE_DATE = {
|
||||||
@ -243,7 +243,7 @@ const ManageInvite: FC<OwnProps & StateProps> = ({
|
|||||||
<i className="icon-check" />
|
<i className="icon-check" />
|
||||||
</FloatingActionButton>
|
</FloatingActionButton>
|
||||||
</div>
|
</div>
|
||||||
<CalendarModalAsync
|
<CalendarModal
|
||||||
isOpen={isCalendarOpened}
|
isOpen={isCalendarOpened}
|
||||||
isFutureMode
|
isFutureMode
|
||||||
withTimePicker
|
withTimePicker
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user