Skip to content

Instantly share code, notes, and snippets.

@siman
Created May 2, 2019 10:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save siman/d0e035065fc4dd8738a2dcfcb39cd5e4 to your computer and use it in GitHub Desktop.
Save siman/d0e035065fc4dd8738a2dcfcb39cd5e4 to your computer and use it in GitHub Desktop.
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