Improve cold start performance

This commit is contained in:
Josh Perez 2021-03-04 16:44:57 -05:00 committed by Josh Perez
parent c73e35b1b6
commit d82ce07942
39 changed files with 911 additions and 628 deletions

View file

@ -40,7 +40,8 @@ story.add('Image and Video', () => {
message: {
attachments: [],
id: 'image-msg',
received_at: Date.now(),
received_at: 1,
received_at_ms: Date.now(),
},
objectURL: '/fixtures/tina-rolf-269345-unsplash.jpg',
},
@ -55,7 +56,8 @@ story.add('Image and Video', () => {
message: {
attachments: [],
id: 'video-msg',
received_at: Date.now(),
received_at: 2,
received_at_ms: Date.now(),
},
objectURL: '/fixtures/pixabay-Soap-Bubble-7141.mp4',
},
@ -79,7 +81,8 @@ story.add('Missing Media', () => {
message: {
attachments: [],
id: 'image-msg',
received_at: Date.now(),
received_at: 3,
received_at_ms: Date.now(),
},
objectURL: undefined,
},

View file

@ -52,7 +52,8 @@ const createRandomFile = (
contentType,
message: {
id: random(now).toString(),
received_at: random(startTime, startTime + timeWindow),
received_at: Math.floor(Math.random() * 10),
received_at_ms: random(startTime, startTime + timeWindow),
attachments: [],
},
attachment: {

View file

@ -9,6 +9,7 @@ import { MediaGridItem } from './MediaGridItem';
import { MediaItemType } from '../../LightboxGallery';
import { missingCaseError } from '../../../util/missingCaseError';
import { LocalizerType } from '../../../types/Util';
import { getMessageTimestamp } from '../../../util/getMessageTimestamp';
export type Props = {
i18n: LocalizerType;
@ -58,7 +59,7 @@ export class AttachmentSection extends React.Component<Props> {
fileSize={attachment.size}
shouldShowSeparator={shouldShowSeparator}
onClick={onClick}
timestamp={message.received_at}
timestamp={getMessageTimestamp(message)}
/>
);
default:

View file

@ -12,6 +12,7 @@ import { groupMediaItemsByDate } from './groupMediaItemsByDate';
import { ItemClickEvent } from './types/ItemClickEvent';
import { missingCaseError } from '../../../util/missingCaseError';
import { LocalizerType } from '../../../types/Util';
import { getMessageTimestamp } from '../../../util/getMessageTimestamp';
import { MediaItemType } from '../../LightboxGallery';
@ -145,7 +146,7 @@ export class MediaGallery extends React.Component<Props, State> {
const sections = groupMediaItemsByDate(now, mediaItems).map(section => {
const first = section.mediaItems[0];
const { message } = first;
const date = moment(message.received_at);
const date = moment(getMessageTimestamp(message));
const header =
section.type === 'yearMonth'
? date.format(MONTH_FORMAT)

View file

@ -5,6 +5,7 @@ import moment from 'moment';
import { compact, groupBy, sortBy } from 'lodash';
import { MediaItemType } from '../../LightboxGallery';
import { getMessageTimestamp } from '../../../util/getMessageTimestamp';
// import { missingCaseError } from '../../../util/missingCaseError';
@ -120,7 +121,7 @@ const withSection = (referenceDateTime: moment.Moment) => (
const thisMonth = moment(referenceDateTime).startOf('month');
const { message } = mediaItem;
const mediaItemReceivedDate = moment.utc(message.received_at);
const mediaItemReceivedDate = moment.utc(getMessageTimestamp(message));
if (mediaItemReceivedDate.isAfter(today)) {
return {
order: 0,

View file

@ -9,4 +9,6 @@ export type Message = {
// Assuming this is for the API
// eslint-disable-next-line camelcase
received_at: number;
// eslint-disable-next-line camelcase
received_at_ms: number;
};