Skip to content

Commit af7f2d4

Browse files
committed
ARTICLE_SHARE イベント追跡
1 parent 3bd5d6b commit af7f2d4

2 files changed

Lines changed: 20 additions & 10 deletions

File tree

browser/main/HomePage/ArticleDetail/ShareButton.js

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { PropTypes } from 'react'
22
import ReactDOM from 'react-dom'
33
import api from 'boost/api'
44
import clientKey from 'boost/clientKey'
5+
import activityRecord from 'boost/activityRecord'
56
const clipboard = require('electron').clipboard
67

78
function getDefault () {
@@ -11,7 +12,8 @@ function getDefault () {
1112
// Fetched url
1213
url: null,
1314
// for tooltip Copy -> Copied!
14-
copied: false
15+
copied: false,
16+
failed: false
1517
}
1618
}
1719

@@ -70,14 +72,21 @@ export default class ShareButton extends React.Component {
7072
clientKey: clientKey.get(),
7173
writerName: user.name
7274
})
73-
api.shareWithPublicURL(input)
74-
.then(res => {
75-
let url = res.body.url
76-
this.setState({url: url})
77-
})
78-
.catch(err => {
79-
console.log(err)
80-
})
75+
this.setState({
76+
isSharing: true,
77+
failed: false
78+
}, () => {
79+
api.shareWithPublicURL(input)
80+
.then(res => {
81+
let url = res.body.url
82+
this.setState({url: url, isSharing: false})
83+
activityRecord.emit('ARTICLE_SHARE')
84+
})
85+
.catch(err => {
86+
console.log(err)
87+
this.setState({isSharing: false, failed: true})
88+
})
89+
})
8190
}
8291

8392
handleCopyURLClick () {
@@ -109,7 +118,7 @@ export default class ShareButton extends React.Component {
109118
onClick={e => this.shareWithPublicURLHandler(e)}
110119
ref='sharePublicURL'
111120
disabled={this.state.isSharing}>
112-
<i className='fa fa-fw fa-external-link'/> {!this.state.isSharing ? 'Share with public URL' : 'Sharing...'}
121+
<i className='fa fa-fw fa-external-link'/> {this.state.failed ? 'Failed : Click to Try again' : !this.state.isSharing ? 'Share with public URL' : 'Sharing...'}
113122
</button>
114123
) : (
115124
<div className='ShareButton-url'>

lib/activityRecord.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export function emit (type, data = {}) {
9898
case 'FINDER_OPEN':
9999
case 'FINDER_COPY':
100100
case 'MAIN_DETAIL_COPY':
101+
case 'ARTICLE_SHARE':
101102
todayRecord[type] = todayRecord[type] == null
102103
? 1
103104
: todayRecord[type] + 1

0 commit comments

Comments
 (0)