From af7f2d4d5ef8a9ba31b6914b5ca66f557cdd07f1 Mon Sep 17 00:00:00 2001 From: Rokt33r Date: Sun, 13 Dec 2015 19:28:53 +0900 Subject: [PATCH] =?UTF-8?q?ARTICLE=5FSHARE=20=E3=82=A4=E3=83=99=E3=83=B3?= =?UTF-8?q?=E3=83=88=E8=BF=BD=E8=B7=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HomePage/ArticleDetail/ShareButton.js | 29 ++++++++++++------- lib/activityRecord.js | 1 + 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/browser/main/HomePage/ArticleDetail/ShareButton.js b/browser/main/HomePage/ArticleDetail/ShareButton.js index 04e36d27..b65b70f2 100644 --- a/browser/main/HomePage/ArticleDetail/ShareButton.js +++ b/browser/main/HomePage/ArticleDetail/ShareButton.js @@ -2,6 +2,7 @@ import React, { PropTypes } from 'react' import ReactDOM from 'react-dom' import api from 'boost/api' import clientKey from 'boost/clientKey' +import activityRecord from 'boost/activityRecord' const clipboard = require('electron').clipboard function getDefault () { @@ -11,7 +12,8 @@ function getDefault () { // Fetched url url: null, // for tooltip Copy -> Copied! - copied: false + copied: false, + failed: false } } @@ -70,14 +72,21 @@ export default class ShareButton extends React.Component { clientKey: clientKey.get(), writerName: user.name }) - api.shareWithPublicURL(input) - .then(res => { - let url = res.body.url - this.setState({url: url}) - }) - .catch(err => { - console.log(err) - }) + this.setState({ + isSharing: true, + failed: false + }, () => { + api.shareWithPublicURL(input) + .then(res => { + let url = res.body.url + this.setState({url: url, isSharing: false}) + activityRecord.emit('ARTICLE_SHARE') + }) + .catch(err => { + console.log(err) + this.setState({isSharing: false, failed: true}) + }) + }) } handleCopyURLClick () { @@ -109,7 +118,7 @@ export default class ShareButton extends React.Component { onClick={e => this.shareWithPublicURLHandler(e)} ref='sharePublicURL' disabled={this.state.isSharing}> - {!this.state.isSharing ? 'Share with public URL' : 'Sharing...'} + {this.state.failed ? 'Failed : Click to Try again' : !this.state.isSharing ? 'Share with public URL' : 'Sharing...'} ) : (
diff --git a/lib/activityRecord.js b/lib/activityRecord.js index 821ab7e6..abf368b4 100644 --- a/lib/activityRecord.js +++ b/lib/activityRecord.js @@ -98,6 +98,7 @@ export function emit (type, data = {}) { case 'FINDER_OPEN': case 'FINDER_COPY': case 'MAIN_DETAIL_COPY': + case 'ARTICLE_SHARE': todayRecord[type] = todayRecord[type] == null ? 1 : todayRecord[type] + 1