This repository has been archived by the owner on May 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from HalfdogStudio/linux
reviewed by reverland
- Loading branch information
Showing
5 changed files
with
133 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,27 @@ | ||
'use strict' | ||
|
||
function cacheContact(modContactList, obj) { | ||
for (var o of modContactList) { | ||
if (o.UserName.startsWith('@@')) { // 群组 | ||
modContactList.forEach(o=>{ | ||
if (o.UserName.startsWith('@@')) { // 群组直接替换了 | ||
// console.log('群缓存更新', o.NickName) | ||
obj.groupContact[o.UserName] = { | ||
nickName: o.NickName, | ||
memberList: o.MemberList, | ||
} | ||
} else { // 用户 | ||
// 查找与替换 | ||
var length = obj.memberList.length | ||
let find = false; | ||
for (let i = 0; i < length; i++) { | ||
let user = obj.memberList[i]; | ||
if (user['UserName'] == o.UserName) { | ||
obj.memberList[i] = o; | ||
find = true; | ||
break; | ||
} | ||
} | ||
// 如果没有找到 | ||
if (!find) { | ||
// 如果不在缓存中 | ||
var index = obj.memberList.findIndex(user=> user['UserName'] == o.UserName); | ||
if (index < 0) { | ||
// console.log('用户缓存推入', o.NickName) | ||
obj.memberList.push(o); | ||
} else { | ||
// console.log('用户缓存替换', o.NickName) | ||
obj.memberList[index] = o; | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
|
||
|
||
|
||
module.exports.cacheContact = cacheContact; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,5 +24,8 @@ | |
"dependencies": { | ||
"request": "^2.67.0", | ||
"segment": "^0.1.3" | ||
}, | ||
"devDependencies": { | ||
"mocha": "^2.3.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters