From 528e4d345f90b283b00e8eee8ff7b5149da6cef4 Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Thu, 24 Sep 2020 16:48:23 -0500 Subject: [PATCH] interface: added oembeds and drag and drop back --- pkg/interface/src/views/apps/links/app.js | 1 + .../apps/links/components/lib/link-preview.js | 28 +- .../apps/links/components/lib/link-submit.js | 126 -------- .../apps/links/components/lib/link-submit.tsx | 302 ++++++++++++++++++ .../apps/links/components/link-detail.js | 4 +- .../views/apps/links/components/link-list.js | 5 +- 6 files changed, 332 insertions(+), 134 deletions(-) delete mode 100644 pkg/interface/src/views/apps/links/components/lib/link-submit.js create mode 100644 pkg/interface/src/views/apps/links/components/lib/link-submit.tsx diff --git a/pkg/interface/src/views/apps/links/app.js b/pkg/interface/src/views/apps/links/app.js index 962ea1ac56..d6f9cad68d 100644 --- a/pkg/interface/src/views/apps/links/app.js +++ b/pkg/interface/src/views/apps/links/app.js @@ -160,6 +160,7 @@ export default class LinksApp extends Component { { const showNickname = props.nickname && !props.hideNicknames; const nameClass = showNickname ? 'inter' : 'mono'; - const author = props.post.author; + const title = props.post.contents[0].text; + const url = props.post.contents[1].url; + const hostname = URLparser.exec(url) ? URLparser.exec(url)[4] : null; + const timeSent = moment.unix(props.post['time-sent'] / 1000).format('hh:mm a'); - const title = props.post.contents[0].text; - const url = props.post.contents[1].url; - + const embed = ( + + ); return (
+
{embed}
{ rel="noopener noreferrer">

{title}

- {url} ↗ + {hostname} ↗
diff --git a/pkg/interface/src/views/apps/links/components/lib/link-submit.js b/pkg/interface/src/views/apps/links/components/lib/link-submit.js deleted file mode 100644 index e76756d0e3..0000000000 --- a/pkg/interface/src/views/apps/links/components/lib/link-submit.js +++ /dev/null @@ -1,126 +0,0 @@ -import React, { Component } from 'react'; -import { Spinner } from '~/views/components/Spinner'; -import { createPost } from '~/logic/api/graph'; - - -export class LinkSubmit extends Component { - constructor() { - super(); - this.state = { - linkValue: '', - linkTitle: '', - submitFocus: false, - disabled: false - }; - this.setLinkValue = this.setLinkValue.bind(this); - this.setLinkTitle = this.setLinkTitle.bind(this); - } - - onClickPost() { - const link = this.state.linkValue; - const title = this.state.linkTitle - ? this.state.linkTitle - : this.state.linkValue; - - const parentIndex = this.props.parentIndex || ''; - let post = createPost([ - { text: title }, - { url: link } - ], parentIndex); - - this.setState({ disabled: true }, () => { - this.props.api.graph.addPost( - `~${this.props.ship}`, - this.props.name, - post - ).then((r) => { - this.setState({ - disabled: false, - linkValue: '', - linkTitle: '', - }); - }); - }); - } - - setLinkValue(event) { - this.setState({ linkValue: event.target.value }); - } - - setLinkTitle(event) { - this.setState({ linkTitle: event.target.value }); - } - - render() { - const activeClasses = (!this.state.disabled) ? 'green2 pointer' : 'gray2'; - - const focus = (this.state.submitFocus) - ? 'b--black b--white-d' - : 'b--gray4 b--gray2-d'; - - return ( -
-