Skip to content

Commit

Permalink
request contact list fail is ok
Browse files Browse the repository at this point in the history
  • Loading branch information
MrXiaoM committed Jan 19, 2024
1 parent 3efe7e0 commit a1e9d27
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ internal class BotWrapper private constructor(
loginInfo = impl.getLoginInfo().data
}
suspend fun updateContacts() {
friendsInternal.update(impl.getFriendList().data.map {
friendsInternal.update(impl.getFriendList().data?.map {
FriendWrapper(this, it)
}) { impl = it.impl }
groupsInternal.update(impl.getGroupList().data.map {
groupsInternal.update(impl.getGroupList().data?.map {
GroupWrapper(this, it)
}) { impl = it.impl }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ internal class GroupWrapper(
@JvmBlockingBridge
override suspend fun updateGroupMemberList(): ContactList<MemberWrapper> {
return (membersInternal ?: ContactList()).apply {
val data = botWrapper.impl.getGroupMemberList(id).data ?: return@apply
update(data.map {
val data = botWrapper.impl.getGroupMemberList(id).data
update(data?.map {
MemberWrapper(botWrapper, this@GroupWrapper, it)
}) { setImpl(it.impl) }
membersInternal = this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ import top.mrxiaom.overflow.internal.contact.data.FolderWrapper
* @param updater this 是旧的,it 是新的,应当把新的内容放进旧的
*/
internal inline fun <reified T : Contact> ContactList<T>.update(
list: List<T>,
list: List<T>?,
updater: T.(T) -> Unit
) {
if (list == null) return
// 删除旧的
delegate.removeIf { old -> list.none { old.id == it.id } }
// 更新旧的
Expand Down

0 comments on commit a1e9d27

Please sign in to comment.