Skip to content

Commit 00762e6

Browse files
author
caiyg
committed
修复点击会话bug以及添加好友bug
1 parent 82105d6 commit 00762e6

File tree

7 files changed

+53
-10
lines changed

7 files changed

+53
-10
lines changed

ReactJChat.iml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module external.linked.project.id="ReactJChat" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="false">
4+
<output url="file://$MODULE_DIR$/build" />
5+
<output-test url="file://$MODULE_DIR$/build" />
6+
<exclude-output />
7+
<content url="file://$MODULE_DIR$">
8+
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
9+
<excludeFolder url="file://$MODULE_DIR$/build" />
10+
</content>
11+
<orderEntry type="inheritedJdk" />
12+
<orderEntry type="sourceFolder" forTests="false" />
13+
</component>
14+
</module>

android/app/app.iml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@
9393
<orderEntry type="library" exported="" name="stetho-okhttp-1.2.0" level="project" />
9494
<orderEntry type="library" exported="" name="gson-2.6.2" level="project" />
9595
<orderEntry type="library" exported="" name="okhttp-2.5.0" level="project" />
96-
<orderEntry type="library" exported="" name="jsr305-3.0.0" level="project" />
9796
<orderEntry type="library" exported="" name="stetho-1.2.0" level="project" />
97+
<orderEntry type="library" exported="" name="jsr305-3.0.0" level="project" />
9898
<orderEntry type="library" exported="" name="jackson-core-2.2.3" level="project" />
9999
<orderEntry type="library" exported="" name="fbcore-0.8.1" level="project" />
100100
<orderEntry type="library" exported="" name="commons-cli-1.2" level="project" />

react-native-android/actions/ActionTypes.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
export const INITIAL_CONVERSATION_LIST = 'INITIAL_CONVERSATION_LIST';
44
export const LOAD_CONVERSATIONS = 'LOAD_CONVERSATIONS';
55
export const SELECT_CONVERSATION = 'SELECT_CONVERSATION';
6-
export const ADD_CONVERSATION = 'ADD_CONVERSATION';
6+
export const ADDING_FRIEND = "ADDING_FRIEND";
7+
export const ADD_FRIEND_SUCCESS = "ADD_FRIEND_SUCCESS";
78
export const DELETE_CONVERSATION = 'DELETE_CONVERSATION';
89
export const LOAD_ERROR = 'LOAD_ERROR';

react-native-android/actions/conversationList.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,16 @@ export function loadConversations() {
2424
})
2525
});
2626
}
27+
}
28+
29+
export function addFriend(username) {
30+
return dispatch => {
31+
type: types.ADDING_FRIEND,
32+
JMessageHelper.addFriend(username, (result) => {
33+
dispatch ({
34+
type: types.ADD_FRIEND_SUCCESS,
35+
conversation: JSON.parse(result)
36+
});
37+
})
38+
}
2739
}

react-native-android/containers/conv_fragment.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,19 @@ export default class Conv extends Component {
209209
}
210210

211211
addFriend() {
212-
213-
JMessageHelper.addFriend(this.state.friendId, (result) => {
212+
const { addFriend } = this.props.actions;
213+
addFriend(this.state.friendId);
214+
const { fetching } = this.props.state;
215+
if (!fetching) {
214216
this.dismissAddFriendDialog();
215-
var newDs = JSON.parse(result);
216-
this.setState({ dataSource: this.getDataSource([newDs, ..._convList]) });
217-
_convList = [newDs, ..._convList];
218-
});
217+
}
218+
219+
// JMessageHelper.addFriend(this.state.friendId, (result) => {
220+
// this.dismissAddFriendDialog();
221+
// var newDs = JSON.parse(result);
222+
// this.setState({ dataSource: this.getDataSource([newDs, ..._convList]) });
223+
// _convList = [newDs, ..._convList];
224+
// });
219225
}
220226

221227
showAddFriendDialog() {
@@ -249,6 +255,7 @@ export default class Conv extends Component {
249255

250256
render() {
251257
const { conversationList } = this.props.state;
258+
_convList = conversationList.convList;
252259
console.log('conversationList: ' + conversationList);
253260
var content = conversationList.dataSource.length === 0 ?
254261
<View style = { styles.container }>

react-native-android/containers/main_activity.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export default class MainActivity extends Component {
9595
};
9696

9797
this.onSelectMenu = this.onSelectMenu.bind(this);
98+
this.onPageSelected = this.onPageSelected.bind(this);
9899
}
99100

100101
onPageSelected(e) {

react-native-android/reducers/conversationList.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,23 @@ export default function conversationList(state, action) {
3737
dataSource,
3838
fetching: false
3939
}
40-
case types.ADD_CONVERSATION:
40+
case types.ADDING_FRIEND:
41+
return {
42+
...state,
43+
...action,
44+
fetching: true
45+
}
46+
break;
47+
case types.ADD_FRIEND_SUCCESS:
4148
var convList = [...state.convList];
4249
convList.unshift(action.conversation);
4350
dataSource = state.dataSource.cloneWithRows(convList);
4451
return {
4552
...state,
4653
...action,
4754
convList,
48-
dataSource
55+
dataSource,
56+
fetching: false
4957
}
5058
case types.DELETE_CONVERSATION:
5159
var selected = action.selected;

0 commit comments

Comments
 (0)