Skip to content

Commit f7612dd

Browse files
committed
fixes for review
1 parent e51db47 commit f7612dd

File tree

15 files changed

+39
-79
lines changed

15 files changed

+39
-79
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{}
1+
{}

mobile/ReactNativeTutorial/__tests__/bundles/comments/components/__snapshots__/Index.js.snap

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ exports[`Index renders correctly when loaded 1`] = `
3232
renderRow={[Function]}
3333
scrollEventThrottle={50}
3434
scrollRenderAheadDistance={1000}
35-
stickyHeaderIndices={Array []}
36-
style={Object {}}>
35+
stickyHeaderIndices={Array []}>
3736
<View
3837
style={
3938
Object {
@@ -64,7 +63,7 @@ exports[`Index renders correctly when loaded 1`] = `
6463
"textAlign": "center",
6564
}
6665
}>
67-
Justin
66+
Alexey
6867
</Text>
6968
<Text
7069
accessible={true}
@@ -77,7 +76,7 @@ exports[`Index renders correctly when loaded 1`] = `
7776
"marginHorizontal": 10,
7877
}
7978
}>
80-
Another random comment
79+
Just some random comment
8180
</Text>
8281
</View>
8382
<View
@@ -110,7 +109,7 @@ exports[`Index renders correctly when loaded 1`] = `
110109
"textAlign": "center",
111110
}
112111
}>
113-
Alexey
112+
Justin
114113
</Text>
115114
<Text
116115
accessible={true}
@@ -123,7 +122,7 @@ exports[`Index renders correctly when loaded 1`] = `
123122
"marginHorizontal": 10,
124123
}
125124
}>
126-
Just some random comment
125+
Another random comment
127126
</Text>
128127
</View>
129128
</ScrollView>
@@ -138,9 +137,8 @@ exports[`Index renders correctly when loaded 1`] = `
138137
"justifyContent": "center",
139138
}
140139
}>
141-
<TouchableHighlight
142-
activeOpacity={0.85}
143-
onPress={[Function]}
140+
<View
141+
onPress={undefined}
144142
style={
145143
Array [
146144
Object {
@@ -192,7 +190,7 @@ exports[`Index renders correctly when loaded 1`] = `
192190
}>
193191
194192
</Text>
195-
</TouchableHighlight>
193+
</View>
196194
</View>
197195
</View>
198196
`;
@@ -231,8 +229,7 @@ exports[`Index renders correctly when loading 1`] = `
231229
renderRow={[Function]}
232230
scrollEventThrottle={50}
233231
scrollRenderAheadDistance={1000}
234-
stickyHeaderIndices={Array []}
235-
style={Object {}} />
232+
stickyHeaderIndices={Array []} />
236233
<View
237234
style={
238235
Object {
@@ -244,9 +241,8 @@ exports[`Index renders correctly when loading 1`] = `
244241
"justifyContent": "center",
245242
}
246243
}>
247-
<TouchableHighlight
248-
activeOpacity={0.85}
249-
onPress={[Function]}
244+
<View
245+
onPress={undefined}
250246
style={
251247
Array [
252248
Object {
@@ -298,7 +294,7 @@ exports[`Index renders correctly when loading 1`] = `
298294
}>
299295
300296
</Text>
301-
</TouchableHighlight>
297+
</View>
302298
</View>
303299
</View>
304300
`;

mobile/ReactNativeTutorial/__tests__/bundles/comments/effects/__snapshots__/createComment.js.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ exports[`createComment creates a comment in the store and sends request to api 1
22
Array [
33
Object {
44
"entities": Object {
5-
"temp0": Object {
5+
"temp:0": Object {
66
"author": "Alexey",
7-
"id": "temp0",
7+
"id": "temp:0",
88
"text": "Random comment",
99
},
1010
},
@@ -19,15 +19,15 @@ Array [
1919
"args": Array [
2020
Object {
2121
"author": "Alexey",
22-
"id": "temp0",
22+
"id": "temp:0",
2323
"text": "Random comment",
2424
},
2525
],
2626
"name": "postComment",
2727
"type": "CALL",
2828
},
2929
Object {
30-
"id": "temp0",
30+
"id": "temp:0",
3131
"type": "COMMENTS_STORE:REMOVE",
3232
},
3333
Object {

mobile/ReactNativeTutorial/__tests__/bundles/comments/effects/__snapshots__/fetch.js.snap

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@ Array [
99
"name": "fetchComments",
1010
"type": "CALL",
1111
},
12-
Object {
13-
"args": Array [
14-
[Error: Invalid Json],
15-
],
16-
"name": "bound log",
17-
"type": "CALL",
18-
},
1912
Object {
2013
"args": Array [
2114
"Error",

mobile/ReactNativeTutorial/app/api/index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import _ from 'lodash/fp';
2-
import { normalize, Schema, arrayOf } from 'normalizr';
2+
import { normalize } from 'normalizr';
3+
import { commentSchema, commentsSchema } from './schemas';
34

45
// You can use localhost for development, but only on iOS. Android emulator is considered
56
// a standalone machine with it's own localhost. Workaround is to specify the actual
@@ -27,13 +28,11 @@ const postRequest = async (url, payload) => apiRequest(url, 'POST', payload);
2728
export const fetchComments = async () => {
2829
const response = await getRequest('comments.json');
2930
const camelizedResponse = _.mapKeys(_.camelCase, response);
30-
const commentSchema = new Schema('comments');
31-
return normalize(camelizedResponse, { comments: arrayOf(commentSchema) });
31+
return normalize(camelizedResponse, { comments: commentsSchema });
3232
};
3333

3434
export const postComment = async (payload) => {
3535
const response = await postRequest('comments.json', { comment: payload });
3636
const camelizedResponse = _.mapKeys(_.camelCase, response);
37-
const commentSchema = new Schema('comments');
3837
return normalize(camelizedResponse, commentSchema);
3938
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { Schema, arrayOf } from 'normalizr';
2+
3+
export const commentSchema = new Schema('comments');
4+
export const commentsSchema = arrayOf(commentSchema);

mobile/ReactNativeTutorial/app/bundles/comments/components/Index/Footer/Footer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const Footer = () => (
1313
reverse
1414
name="add"
1515
color="#f50"
16-
onPress={() => Actions.commentsAdd()}
16+
onPress={Actions.commentsAdd}
1717
/>
1818
</View>
1919
);

mobile/ReactNativeTutorial/app/bundles/comments/components/Index/List/List.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,17 @@
11
// @flow
22
import React from 'react';
33
import { ListView, RefreshControl } from 'react-native';
4-
import _ from 'lodash/fp';
54
import type { IndexPropsType } from '../../../containers/Index';
65
import Item from './Item/Item';
76

8-
import styles from './ListStyle';
9-
107
type PropsType = IndexPropsType;
118

129
const List = (props: PropsType) => {
13-
const data = _.compose(
14-
_.reverse,
15-
_.sortBy(_.get('id')),
16-
_.values
17-
)(props.comments);
1810
const dataSource = new ListView.DataSource({ rowHasChanged: (r1: any, r2: any) => r1 !== r2 })
19-
.cloneWithRows(data);
11+
.cloneWithRows(props.comments || []);
2012
return (
2113
<ListView
2214
enableEmptySections
23-
style={styles.container}
2415
dataSource={dataSource}
2516
renderRow={(item: any) => <Item {...item} />}
2617
refreshControl={

mobile/ReactNativeTutorial/app/bundles/comments/components/Index/List/ListStyle.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

mobile/ReactNativeTutorial/app/reducers/commentFormReducer.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ export const initialState = fromJS({
99

1010
const update = (state, action) => state.merge(action.payload);
1111

12-
export default (state, action) => {
13-
if (!state) {
14-
return initialState;
15-
}
16-
12+
export default (state = initialState, action) => {
1713
switch (action.type) {
1814
case UPDATE:
1915
return update(state, action);

0 commit comments

Comments
 (0)