From a05f19996fc9fa3436e476267648e4aef950d859 Mon Sep 17 00:00:00 2001 From: Max Stoiber Date: Thu, 2 May 2019 14:55:03 +0200 Subject: [PATCH 1/2] Fallback to thread link in attachment --- src/components/message/threadAttachment/attachment.js | 5 ++--- src/components/message/threadAttachment/index.js | 5 +++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/message/threadAttachment/attachment.js b/src/components/message/threadAttachment/attachment.js index 39a0a39722..042b17561b 100644 --- a/src/components/message/threadAttachment/attachment.js +++ b/src/components/message/threadAttachment/attachment.js @@ -12,7 +12,7 @@ import getThreadLink from 'src/helpers/get-thread-link'; class Attachment extends React.Component { render() { - const { data, currentUser } = this.props; + const { data, currentUser, id } = this.props; const { thread, loading, error } = data; if (loading) @@ -23,9 +23,8 @@ class Attachment extends React.Component { ); - if (error) return null; - if (!thread) return null; + if (error || !thread) return `https://spectrum.chat/thread/${id}`; return (
diff --git a/src/components/message/threadAttachment/index.js b/src/components/message/threadAttachment/index.js index aa3eb07456..7cce761c1f 100644 --- a/src/components/message/threadAttachment/index.js +++ b/src/components/message/threadAttachment/index.js @@ -12,6 +12,7 @@ import Attachment from './attachment'; export type Props = { currentUser: UserInfoType, message: MessageInfoType, + id: string, data: { thread: GetThreadType, loading: boolean, @@ -19,8 +20,8 @@ export type Props = { }, }; -const Query = ({ data, message, ...rest }: Props) => ( - +const Query = ({ data, message, id, ...rest }: Props) => ( + ); const ThreadAttachment = compose(getThreadById)(Query); From d0ec6394e9c1bde29e1218fa4ac5499b4daa41ea Mon Sep 17 00:00:00 2001 From: Max Stoiber Date: Thu, 2 May 2019 15:04:07 +0200 Subject: [PATCH 2/2] Link fallback thread links --- src/components/message/threadAttachment/attachment.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/message/threadAttachment/attachment.js b/src/components/message/threadAttachment/attachment.js index 042b17561b..8dae27ab57 100644 --- a/src/components/message/threadAttachment/attachment.js +++ b/src/components/message/threadAttachment/attachment.js @@ -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'; @@ -24,7 +25,10 @@ class Attachment extends React.Component {
); - if (error || !thread) return `https://spectrum.chat/thread/${id}`; + if (error || !thread) + return ( + https://spectrum.chat/thread/{id} + ); return (