22 * Copyright 2004-present Facebook. All Rights Reserved.
33 *
44 * @providesModule CameraRollView
5+ * @flow
56 */
67'use strict' ;
78
@@ -53,7 +54,7 @@ var propTypes = {
5354var CameraRollView = React . createClass ( {
5455 propTypes : propTypes ,
5556
56- getDefaultProps : function ( ) {
57+ getDefaultProps : function ( ) : Object {
5758 return {
5859 groupTypes : 'SavedPhotos' ,
5960 batchSize : 5 ,
@@ -75,9 +76,9 @@ var CameraRollView = React.createClass({
7576 var ds = new ListView . DataSource ( { rowHasChanged : this . _rowHasChanged } ) ;
7677
7778 return {
78- assets : [ ] ,
79+ assets : ( [ ] : Array < Image > ) ,
7980 groupTypes : this . props . groupTypes ,
80- lastCursor : null ,
81+ lastCursor : ( null : ? string ) ,
8182 noMore : false ,
8283 loadingMore : false ,
8384 dataSource : ds ,
@@ -99,21 +100,21 @@ var CameraRollView = React.createClass({
99100 this . fetch ( ) ;
100101 } ,
101102
102- componentWillReceiveProps : function ( nextProps ) {
103+ componentWillReceiveProps : function ( nextProps : { groupTypes ?: string } ) {
103104 if ( this . props . groupTypes !== nextProps . groupTypes ) {
104105 this . fetch ( true ) ;
105106 }
106107 } ,
107108
108- _fetch : function ( clear ) {
109+ _fetch : function ( clear ?: boolean ) {
109110 if ( clear ) {
110111 this . setState ( this . getInitialState ( ) , this . fetch ) ;
111112 return ;
112113 }
113114
114- var fetchParams = {
115+ var fetchParams : Object = {
115116 first : this . props . batchSize ,
116- groupTypes : this . props . groupTypes ,
117+ groupTypes : this . props . groupTypes
117118 } ;
118119 if ( this . state . lastCursor ) {
119120 fetchParams . after = this . state . lastCursor ;
@@ -126,7 +127,7 @@ var CameraRollView = React.createClass({
126127 * Fetches more images from the camera roll. If clear is set to true, it will
127128 * set the component to its initial state and re-fetch the images.
128129 */
129- fetch : function ( clear ) {
130+ fetch : function ( clear ?: boolean ) {
130131 if ( ! this . state . loadingMore ) {
131132 this . setState ( { loadingMore : true } , ( ) => { this . _fetch ( clear ) ; } ) ;
132133 }
@@ -144,7 +145,7 @@ var CameraRollView = React.createClass({
144145 ) ;
145146 } ,
146147
147- _rowHasChanged : function ( r1 , r2 ) {
148+ _rowHasChanged : function ( r1 : Array < Image > , r2 : Array < Image > ) : boolean {
148149 if ( r1 . length !== r2 . length ) {
149150 return true ;
150151 }
@@ -166,7 +167,7 @@ var CameraRollView = React.createClass({
166167 } ,
167168
168169 // rowData is an array of images
169- _renderRow : function ( rowData , sectionID , rowID ) {
170+ _renderRow : function ( rowData : Array < Image > , sectionID : string , rowID : string ) {
170171 var images = rowData . map ( ( image ) => {
171172 if ( image === null ) {
172173 return null ;
@@ -181,9 +182,9 @@ var CameraRollView = React.createClass({
181182 ) ;
182183 } ,
183184
184- _appendAssets : function ( data ) {
185+ _appendAssets : function ( data : Object ) {
185186 var assets = data . edges ;
186- var newState = { loadingMore : false } ;
187+ var newState : Object = { loadingMore : false } ;
187188
188189 if ( ! data . page_info . has_next_page ) {
189190 newState . noMore = true ;
0 commit comments