Skip to content
This repository was archived by the owner on Nov 12, 2019. It is now read-only.

Commit d08cbfa

Browse files
committed
fix a bug of collection
1 parent 92c9503 commit d08cbfa

File tree

7 files changed

+25
-5
lines changed

7 files changed

+25
-5
lines changed

js/actions/modifySettings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function changeAutoFetch(value, flag=true, emitter=false) {
4242
dao.saveAutoFetchHomeData(value);
4343
}
4444

45-
if(emitter) // for only sending notification once
45+
if(emitter) // only send notification once
4646
RCTDeviceEventEmitter.emit('fetch', value);
4747

4848
if(value){

js/components/ListViewForCollection.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import WebViewPage from '../containers/WebViewPage';
1313
import { SwipeListView } from 'react-native-swipe-list-view';
1414
import {store} from '../store/index';
1515
import {unStarData} from '../actions/handleCollectionData';
16+
import RCTDeviceEventEmitter from 'RCTDeviceEventEmitter';
1617

1718
class ListViewForCollection extends Component{
1819
static propTypes = {
@@ -112,7 +113,7 @@ class ListViewForCollection extends Component{
112113

113114
_itemRemoveOnPress(rowData){
114115
store.dispatch(unStarData(rowData));
115-
this.forceUpdate(); //must refresh dom
116+
RCTDeviceEventEmitter.emit('refresh'); //must refresh dom
116117
}
117118

118119
_handleCreateTime(time){

js/components/ListViewForGirls.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class ListViewForGirls extends Component{
6060
source={{uri: this.state.imageUrl}}/>
6161
</View>
6262
:
63-
<ActivityIndicator size="large"/>
63+
<ActivityIndicator size="large" color={this.props.tabIconColor}/>
6464
}
6565
</View>
6666
</Modal>

js/containers/CollectionTab/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {View, Text, ScrollView} from 'react-native';
99
import theme from '../../constants/theme';
1010
import NavigationBar from '../../components/NavigationBar';
1111
import ListViewForCollection from '../../components/ListViewForCollection';
12+
import RCTDeviceEventEmitter from 'RCTDeviceEventEmitter';
1213

1314
class CollectionFragment extends Component{
1415
constructor(props){
@@ -34,6 +35,18 @@ class CollectionFragment extends Component{
3435
</View>
3536
);
3637
}
38+
39+
componentDidMount(){
40+
RCTDeviceEventEmitter.addListener('refresh', this._refreshWholeDOM.bind(this));
41+
}
42+
43+
componentWillUnmount(){
44+
RCTDeviceEventEmitter.removeListener('refresh', this._refreshWholeDOM.bind(this));
45+
}
46+
47+
_refreshWholeDOM(){
48+
this.forceUpdate();
49+
}
3750
}
3851

3952
const mapStateToProps = (state) => {

js/containers/DiscoveryTab/GirlsPage.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ class GirlsPage extends BackPageComponent{
8484
}
8585

8686
_fethchData(){
87-
this.props.actions.fetchData('福利/10/1');
87+
this.props.actions.fetchData('福利/20/1');
8888
}
8989

9090
_listViewOnEndReached(){
9191
if(!this.props.isRenderFooter) {
92-
this.props.actions.fetchMoreData('福利/10/'+this.props.pageNumber);
92+
this.props.actions.fetchMoreData('福利/20/'+this.props.pageNumber);
9393
}
9494
}
9595

js/containers/HomeTab/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ class HomeFragment extends Component{
9595
this.props.actions.fetchDataIfNeed(getCurrentDate());
9696
}
9797

98+
/**
99+
* the speed of render is faster than that of getting setting value.
100+
* this is for when gets the setting value, home page decides whether to refresh the content.
101+
*/
98102
componentDidMount(){
99103
RCTDeviceEventEmitter.addListener('fetch', this._handleEventEmitter.bind(this));
100104
}

js/containers/WebViewPage.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {bindActionCreators} from 'redux';
1515
import * as Actions from '../actions/handleCollectionData';
1616
import Toast from 'react-native-root-toast';
1717
import ShareUtil from '../utils/ShareUtil';
18+
import RCTDeviceEventEmitter from 'RCTDeviceEventEmitter';
1819

1920
class WebViewPage extends BackPageComponent{
2021
constructor(props){
@@ -204,6 +205,7 @@ class WebViewPage extends BackPageComponent{
204205
share.share(this.props.rowData.desc, this.props.rowData.url);
205206
}else if(id === 7){
206207
this.props.actions.unStarData(this.props.rowData);
208+
RCTDeviceEventEmitter.emit('refresh');
207209
}else if(id === 8){
208210
this.props.actions.starData(this.props.rowData);
209211
}else if(id === 9){

0 commit comments

Comments
 (0)