Created
May 2, 2019 10:18
-
-
Save siman/d0e035065fc4dd8738a2dcfcb39cd5e4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { StreamApp, NotificationDropdown, FlatFeed, LikeButton, Activity, CommentField, CommentList } from 'react-activity-feed'; | |
import 'react-activity-feed/dist/index.css'; | |
const customDoFeedRequest = (client, feedGroup, userId, options) => { | |
const feed = client.feed(feedGroup, userId); | |
const feedPromise = feed.get(options); | |
feedPromise.then((res) => { | |
console.log('doFeedRequest: Promise:', res.results); | |
res.results.forEach((activity) => { | |
if (activity) { | |
activity.object = 'Hacked: Replaced in a custom doFeedRequest'; | |
} | |
}); | |
return res; | |
}) | |
console.log('doFeedRequest:', feedPromise); | |
return feedPromise; | |
} | |
class App extends React.Component { | |
render () { | |
return ( | |
<StreamApp | |
apiKey="rssn9mmqe6tz" | |
appId="51547" | |
token="eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidXNlci1vbmUifQ.Wc6O-J5o-nFGmnkzQ8cKCoALnAIvA8-xD-8X7weHHPQ" | |
> | |
<NotificationDropdown notify doFeedRequest={customDoFeedRequest} /> | |
<FlatFeed | |
options={{reactions: { recent: true } }} | |
doFeedRequest={customDoFeedRequest} | |
notify | |
Activity={(props) => { | |
// props.activity.object = 'Hello foreign ID: ' + props.activity.foreign_id; | |
return <Activity {...props} | |
Footer={() => { | |
console.log(props); | |
return ( | |
<div style={ {padding: '8px 16px'} }> | |
<LikeButton {...props} /> | |
<CommentField | |
activity={props.activity} | |
onAddReaction={props.onAddReaction} /> | |
<CommentList activityId={props.activity.id} /> | |
</div> | |
)}} | |
/> | |
}} | |
/> | |
</StreamApp> | |
); | |
} | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment