Skip to content

Commit c65276c

Browse files
wangyingmyZhangDong
authored andcommitted
add filemessage download
1 parent 3cccc89 commit c65276c

File tree

7 files changed

+45
-79
lines changed

7 files changed

+45
-79
lines changed

demo/src/components/blacklist/BlacklistModal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class BlacklistModal extends React.Component {
1818
const items = blacklist.names.map((name, index) => {
1919
return (
2020
<p key={name} style={{ height: 30 }}>
21-
{name}
21+
{blacklist.byName[name]}
2222
<i
2323
style={{
2424
cursor: 'pointer', 'margin-right': '16px'

demo/src/components/chat/ChatMessage.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,9 @@ export default class ChatMessage extends Component {
148148
}
149149

150150
}
151-
151+
handleClick = (e)=>{
152+
e.stopPropagation();
153+
}
152154

153155
render() {
154156
const { bySelf, from, time, body, status, toJid, fromNick, id } = this.props
@@ -235,9 +237,9 @@ export default class ChatMessage extends Component {
235237
</p>
236238
</div>
237239
<div className="ant-col-12">
238-
{/* <a href={body.url} download={body.filename}>
240+
{!bySelf && <a href={body.url} download={body.filename} onClick={this.handleClick}>
239241
{I18n.t('download')}
240-
</a> */}
242+
</a>}
241243
</div>
242244
</div>
243245
</div>

demo/src/redux/BlacklistRedux.js

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,52 +14,42 @@ const { Types, Creators } = createActions({
1414
getBlacklist: () => {
1515
return (dispatch, getState) => {
1616
WebIM.conn.getBlocklist().then(res=>{
17-
dispatch(Creators.updateBlacklist(res.data))
17+
res.data && dispatch(Creators.updateBlacklist(res.data))
1818
})
1919
}
2020
},
2121
// add to black list
2222
doAddBlacklist: id => {
2323
return (dispatch, getState) => {
2424
dispatch(CommonActions.fetching())
25+
try{
26+
WebIM.conn.addUsersToBlocklist({name:id});
27+
let blacklist = getState().entities.blacklist.byName.asMutable()
28+
let index = blacklist.findIndex(i=>blacklist[i]==id)
29+
if(index>-1) return
30+
blacklist.push(id);
31+
dispatch(Creators.updateBlacklist(blacklist))
32+
}catch(e){
2533

26-
let blacklist = getState().entities.blacklist.byName.asMutable()
27-
let roster = getState().entities.roster.byName
28-
if (blacklist[id]) return
29-
blacklist[id] = roster[id]
30-
WebIM.conn.addToBlackList({
31-
// list: blacklist,
32-
// type: "jid",
33-
name: id,
34-
success: function () {
35-
// TODO: add to black list directly , shouldn't re-pull
36-
dispatch(CommonActions.fetched())
37-
},
38-
error: function () {
39-
dispatch(CommonActions.fetched())
40-
}
41-
})
34+
}finally{
35+
dispatch(CommonActions.fetched())
36+
}
4237
}
4338
},
4439
// delete from blacklist
4540
doRemoveBlacklist: id => {
4641
return (dispatch, getState) => {
4742
dispatch(CommonActions.fetching())
48-
49-
let blacklist = getState().entities.blacklist.byName.asMutable()
50-
delete blacklist[id]
51-
WebIM.conn.removeFromBlackList({
52-
// list: blacklist,
53-
// type: "jid",
54-
name: id,
55-
success: function () {
56-
// TODO: delete from black list directly , shouldn't re-pull
57-
dispatch(CommonActions.fetched())
58-
},
59-
error: function () {
60-
dispatch(CommonActions.fetched())
61-
}
62-
})
43+
try{
44+
let blacklist = getState().entities.blacklist.byName.asMutable()
45+
WebIM.conn.removeUserFromBlackList({name:blacklist[id]})
46+
blacklist.splice(id,1)
47+
dispatch(Creators.updateBlacklist(blacklist))
48+
dispatch(CommonActions.fetched())
49+
// delete blacklist[id]
50+
}catch(e){
51+
dispatch(CommonActions.fetched())
52+
}
6353
}
6454
}
6555
})

demo/src/redux/RosterRedux.js

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,32 +48,20 @@ const { Types, Creators } = createActions({
4848
return (dispatch, getState) => {
4949
//loading
5050
dispatch(CommonActions.fetching())
51-
WebIM.conn.deleteContact({
52-
to: id,
53-
success: function() {
54-
//loading end
55-
dispatch(CommonActions.fetched())
56-
dispatch(Creators.getContacts())
57-
58-
// WebIM.conn.unsubscribed({
59-
// to: id
60-
// })
61-
},
62-
error: function() {
63-
//TODO ERROR
64-
dispatch(CommonActions.fetched())
65-
}
66-
})
51+
try{
52+
WebIM.conn.deleteContact(id)
53+
dispatch(CommonActions.fetched())
54+
dispatch(Creators.getContacts())
55+
}catch(e){
56+
dispatch(CommonActions.fetched())
57+
}
6758
}
6859
},
6960
// add contact
7061
addContact: id => {
7162
return (dispatch, getState) => {
7263
const u = getState().login.username
73-
WebIM.conn.addContact({
74-
to: id,
75-
message: u + I18n.t('request')
76-
})
64+
WebIM.conn.addContact(id,u + I18n.t('request'))
7765
}
7866
},
7967

demo/src/redux/SubscribeRedux.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ const { Types, Creators } = createActions({
1616
return (dispatch, getState) => {
1717
dispatch(Creators.removeSubscribe(name))
1818

19-
WebIM.conn.acceptContactInvite({
20-
to: name,
21-
message: '[resp:true]'
22-
})
19+
WebIM.conn.acceptContactInvite(name)
2320
}
2421
},
2522

@@ -28,10 +25,7 @@ const { Types, Creators } = createActions({
2825
return (dispatch, getState) => {
2926
dispatch(Creators.removeSubscribe(name))
3027

31-
WebIM.conn.declineContactInvite({
32-
to: name,
33-
message: new Date().toLocaleString()
34-
})
28+
WebIM.conn.declineContactInvite(name)
3529
}
3630
}
3731
})

simpleDemo/easmeob-im/friend.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,12 @@ $(function () {
1010
})
1111
//添加好友
1212
$("#addRoster").click(function () {
13-
WebIM.conn.addContact({
14-
to: toID,
15-
message: '加个好友呗!'
16-
});
13+
WebIM.conn.addContact(toID,u + '加个好友呗!')
1714
$('toName').val('');
1815
})
1916
//删除好友
2017
$('#removeRoster').click(function () {
21-
WebIM.conn.deleteContact({
22-
to: toID
23-
});
18+
WebIM.conn.deleteContact(toID)
2419
$('#toName').val('');
2520
})
2621
//获取黑名单列表

simpleDemo/utils/initWeb.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,14 @@ WebIM.conn.listen({
110110
var truthBeTold = window.confirm((message.from + "申请添加您为好友:"));
111111
if (truthBeTold) {
112112
// 同意对方添加好友
113-
WebIM.conn.acceptContactInvite({
114-
to: message.from,
115-
message: "[resp:true]"
116-
});
113+
WebIM.conn.acceptContactInvite(message.from)
114+
117115
console.log("同意添加好友");
118116
} else {
119117
// 拒绝对方添加好友
120-
WebIM.conn.declineContactInvite({
121-
to: message.from,
122-
message: "rejectAddFriend" // 拒绝添加好友回复信息
123-
});
118+
WebIM.conn.declineContactInvite(
119+
message.from // 拒绝添加好友回复信息
120+
);
124121
console.log("拒绝添加好友");
125122
}
126123
break;

0 commit comments

Comments
 (0)