Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

[Artist] Paginate past shows #16

Open
2 tasks
alloy opened this issue Apr 29, 2016 · 1 comment
Open
2 tasks

[Artist] Paginate past shows #16

alloy opened this issue Apr 29, 2016 · 1 comment
Milestone

Comments

@alloy
Copy link
Contributor

alloy commented Apr 29, 2016

  • Add Object Identification support to metaphysics
  • Add support to React Native to have ListView invoke its onEndReached callback when a ListView is wrapped in another ScrollView.
@alloy alloy added the Artist label Apr 29, 2016
@alloy alloy added this to the Post v1 milestone Apr 29, 2016
@alloy
Copy link
Contributor Author

alloy commented Apr 29, 2016

Then something like the following should be enough to add pagination:

diff --git a/lib/components/artist/shows/past_shows.js b/lib/components/artist/shows/past_shows.js
index 6ea1fcf..8e15262 100644
--- a/lib/components/artist/shows/past_shows.js
+++ b/lib/components/artist/shows/past_shows.js
@@ -10,10 +10,14 @@ import SerifText from '../../text/serif'
 import OpaqueImageView from '../../opaque_image_view'
 import ShowMetadata from './show_metadata'

+const PageSize = 10;

 class PastShows extends React.Component {
   constructor(props) {
     super(props);
+
+    this.fetchNextPage = this.fetchNextPage.bind(this);
+
     this.state = {
       dataSource: new ListView.DataSource({
         rowHasChanged:(row1, row2) => row1 !== row2,
@@ -21,12 +25,19 @@ class PastShows extends React.Component {
     };
   }

+  fetchNextPage() {
+    this.props.relay.setVariables({
+      size: this.props.relay.size + PageSize,
+    });
+  }
+
   render() {
     return (
       <ListView
         dataSource={this.state.dataSource}
         renderRow={this.renderShow}
         renderSeparator={(sectionID, rowID) => <View key={`${sectionID}-${rowID}`} style={styles.separator} />}
+        onEndReached={this.fetchNextPage}
       />
     )
   }
@@ -60,10 +71,13 @@ var styles = StyleSheet.create({
 });

 export default Relay.createContainer(PastShows, {
+  initialVariables: {
+    size: PageSize
+  },
   fragments: {
     artist: () => Relay.QL`
       fragment on Artist {
-        partner_shows(status: "closed") {
+        partner_shows(status: "closed", size: $size) {
           meta_image {
             cropped(width: 75, height: 75) {
               url

@sarahscott sarahscott added the D:2 label Aug 11, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants