signal-desktop/ts/components/conversation/media-gallery/MediaGallery.md

36 lines
888 B
Markdown
Raw Normal View History

2018-04-12 20:23:26 +00:00
```jsx
const YEAR_MS = 1 * 12 * 30 * 24 * 60 * 60 * 1000;
const tokens = ['foo', 'bar', 'baz', 'qux', 'quux'];
const fileExtensions = ['docx', 'pdf', 'txt', 'mp3', 'wmv', 'tiff'];
const createRandomMessage = (props) => {
const now = Date.now();
const fileName =
`${_.sample(tokens)}${_.sample(tokens)}.${_.sample(fileExtensions)}`;
return {
id: _.random(now).toString(),
received_at: _.random(now - YEAR_MS, now),
attachments: [{
data: null,
2018-04-13 00:56:05 +00:00
fileName,
size: _.random(1000, 1000 * 1000 * 50),
2018-04-12 20:23:26 +00:00
}],
// TODO: Revisit
2018-04-13 00:56:05 +00:00
objectURL: `https://placekitten.com/${_.random(50, 150)}/${_.random(50, 150)}`,
2018-04-12 20:23:26 +00:00
...props,
};
};
const startTime = Date.now();
const messages = _.sortBy(
2018-04-13 00:56:05 +00:00
_.range(25).map(createRandomMessage),
2018-04-12 20:23:26 +00:00
message => -message.received_at
);
<MediaGallery
2018-04-13 00:56:05 +00:00
i18n={window.i18n}
media={messages}
documents={messages}
2018-04-12 20:23:26 +00:00
/>
```