Outbound link previews
This commit is contained in:
parent
bb3ab816dd
commit
313faab774
25 changed files with 2136 additions and 641 deletions
|
@ -5,7 +5,6 @@ import Measure from 'react-measure';
|
|||
import { drop, groupBy, orderBy, take } from 'lodash';
|
||||
import { ContextMenu, ContextMenuTrigger, MenuItem } from 'react-contextmenu';
|
||||
import { Manager, Popper, Reference } from 'react-popper';
|
||||
import moment, { Moment } from 'moment';
|
||||
|
||||
import { Avatar } from '../Avatar';
|
||||
import { Spinner } from '../Spinner';
|
||||
|
@ -23,6 +22,7 @@ import {
|
|||
} from './ReactionViewer';
|
||||
import { Props as ReactionPickerProps, ReactionPicker } from './ReactionPicker';
|
||||
import { Emoji } from '../emoji/Emoji';
|
||||
import { LinkPreviewDate } from './LinkPreviewDate';
|
||||
|
||||
import {
|
||||
AttachmentType,
|
||||
|
@ -51,10 +51,8 @@ interface Trigger {
|
|||
|
||||
// Same as MIN_WIDTH in ImageGrid.tsx
|
||||
const MINIMUM_LINK_PREVIEW_IMAGE_WIDTH = 200;
|
||||
const MINIMUM_LINK_PREVIEW_DATE = new Date(1990, 0, 1).valueOf();
|
||||
const STICKER_SIZE = 200;
|
||||
const SELECTED_TIMEOUT = 1000;
|
||||
const ONE_DAY = 24 * 60 * 60 * 1000;
|
||||
|
||||
interface LinkPreviewType {
|
||||
title: string;
|
||||
|
@ -804,14 +802,7 @@ export class Message extends React.PureComponent<Props, State> {
|
|||
width &&
|
||||
width >= MINIMUM_LINK_PREVIEW_IMAGE_WIDTH;
|
||||
|
||||
// Don't show old dates or dates too far in the future. This is predicated on the
|
||||
// idea that showing an invalid dates is worse than hiding valid ones.
|
||||
const maximumLinkPreviewDate = Date.now() + ONE_DAY;
|
||||
const isDateValid: boolean =
|
||||
typeof first.date === 'number' &&
|
||||
first.date > MINIMUM_LINK_PREVIEW_DATE &&
|
||||
first.date < maximumLinkPreviewDate;
|
||||
const dateMoment: Moment | null = isDateValid ? moment(first.date) : null;
|
||||
const linkPreviewDate = first.date || null;
|
||||
|
||||
return (
|
||||
<button
|
||||
|
@ -892,14 +883,10 @@ export class Message extends React.PureComponent<Props, State> {
|
|||
<div className="module-message__link-preview__location">
|
||||
{first.domain}
|
||||
</div>
|
||||
{dateMoment && (
|
||||
<time
|
||||
className="module-message__link-preview__date"
|
||||
dateTime={dateMoment.toISOString()}
|
||||
>
|
||||
{dateMoment.format('ll')}
|
||||
</time>
|
||||
)}
|
||||
<LinkPreviewDate
|
||||
date={linkPreviewDate}
|
||||
className="module-message__link-preview__date"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue