Skip to content
This repository has been archived by the owner on Oct 11, 2022. It is now read-only.

Commit

Permalink
Merge pull request #5072 from withspectrum/fallback-to-thread-link
Browse files Browse the repository at this point in the history
Fallback to thread link in attachment
  • Loading branch information
brianlovin authored May 2, 2019
2 parents e10c472 + d0ec639 commit 6802681
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/components/message/threadAttachment/attachment.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @flow
import React from 'react';
import { Link } from 'react-router-dom';
import type { Props } from './';
import compose from 'recompose/compose';
import { Loading } from 'src/components/loading';
Expand All @@ -12,7 +13,7 @@ import getThreadLink from 'src/helpers/get-thread-link';

class Attachment extends React.Component<Props> {
render() {
const { data, currentUser } = this.props;
const { data, currentUser, id } = this.props;
const { thread, loading, error } = data;

if (loading)
Expand All @@ -23,9 +24,11 @@ class Attachment extends React.Component<Props> {
</Container>
</div>
);
if (error) return null;

if (!thread) return null;
if (error || !thread)
return (
<Link to={`/thread/${id}`}>https://spectrum.chat/thread/{id}</Link>
);

return (
<div className="attachment-container">
Expand Down
5 changes: 3 additions & 2 deletions src/components/message/threadAttachment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ import Attachment from './attachment';
export type Props = {
currentUser: UserInfoType,
message: MessageInfoType,
id: string,
data: {
thread: GetThreadType,
loading: boolean,
error: ?string,
},
};

const Query = ({ data, message, ...rest }: Props) => (
<Attachment message={message} data={data} />
const Query = ({ data, message, id, ...rest }: Props) => (
<Attachment message={message} id={id} data={data} />
);

const ThreadAttachment = compose(getThreadById)(Query);
Expand Down

0 comments on commit 6802681

Please sign in to comment.