|
|
@@ -27,10 +27,13 @@ import com.adealink.weparty.module.account.AccountModule
|
|
|
import com.adealink.weparty.module.account.util.isUidValid
|
|
|
import com.adealink.weparty.module.network.data.ServerCode
|
|
|
import com.adealink.weparty.module.profile.Profile
|
|
|
+import com.adealink.weparty.module.profile.data.AddRemarkAndDescReq
|
|
|
+import com.adealink.weparty.module.profile.data.BatchGetRemarkReq
|
|
|
import com.adealink.weparty.module.profile.data.CheckLadyPrivilegeRes
|
|
|
import com.adealink.weparty.module.profile.data.LadyPrivilegeRewardNotify
|
|
|
import com.adealink.weparty.module.profile.data.LadyPrivilegeRewardReason
|
|
|
import com.adealink.weparty.module.profile.data.LadyPrivilegeRewardType
|
|
|
+import com.adealink.weparty.module.profile.data.QUERY_NOTE_PAGE_SIZE
|
|
|
import com.adealink.weparty.module.profile.data.RegionUserRes
|
|
|
import com.adealink.weparty.module.profile.data.RelationshipType
|
|
|
import com.adealink.weparty.module.profile.data.UserConfigType
|
|
|
@@ -548,29 +551,48 @@ class ProfileManager : BaseFrame<IProfileListener>(), IProfileManager {
|
|
|
launch {
|
|
|
val mUid = getMyUid()
|
|
|
userNoteNameMap.clear()
|
|
|
+ // 先从本地数据库加载已有的数据(如果有)
|
|
|
noteNameDao.queryNoteName(mUid)?.forEach {
|
|
|
userNoteNameMap[it.peerUid] = it.noteName
|
|
|
}
|
|
|
notifyAllUserNoteNameChanged(userNoteNameMap)
|
|
|
- when (val rlt = profileHttpService.getRelationShipInfoListByUid()) {
|
|
|
- is Rlt.Failed -> {
|
|
|
|
|
|
- }
|
|
|
+ var offset = 0
|
|
|
+ val limit = QUERY_NOTE_PAGE_SIZE
|
|
|
+ var hasMore = true
|
|
|
|
|
|
- is Rlt.Success -> {
|
|
|
- val data = rlt.data.data ?: return@launch
|
|
|
- data.forEach {
|
|
|
- userNoteNameMap[it.peerUid] = it.extraConfig.note
|
|
|
- noteNameDao.insertNoteName(
|
|
|
- NoteNameEntity(
|
|
|
- "${mUid}_${it.peerUid}",
|
|
|
- mUid,
|
|
|
- it.peerUid,
|
|
|
- it.extraConfig.note
|
|
|
- )
|
|
|
- )
|
|
|
+ while (hasMore) {
|
|
|
+ when (val rlt = profileHttpService.queryUserRemark(BatchGetRemarkReq(offset, limit))) {
|
|
|
+ is Rlt.Failed -> {
|
|
|
+ hasMore = false
|
|
|
+ }
|
|
|
+ is Rlt.Success -> {
|
|
|
+ // 如果返回的数据为空,说明没有更多数据
|
|
|
+ val uid2RemarkMap = rlt.data.data?.uid2RemarkMap ?: emptyMap()
|
|
|
+ if (uid2RemarkMap.isEmpty()) {
|
|
|
+ hasMore = false
|
|
|
+ } else {
|
|
|
+ uid2RemarkMap.forEach { (peerUid, note) ->
|
|
|
+ userNoteNameMap[peerUid] = note
|
|
|
+ noteNameDao.insertNoteName(
|
|
|
+ NoteNameEntity(
|
|
|
+ "${mUid}_${peerUid}",
|
|
|
+ mUid,
|
|
|
+ peerUid,
|
|
|
+ note
|
|
|
+ )
|
|
|
+ )
|
|
|
+ }
|
|
|
+ notifyAllUserNoteNameChanged(userNoteNameMap)
|
|
|
+
|
|
|
+ // 如果当前页数量不足 limit,则说明已经全部加载完
|
|
|
+ if (uid2RemarkMap.size < limit) {
|
|
|
+ hasMore = false
|
|
|
+ } else {
|
|
|
+ offset += limit
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- notifyAllUserNoteNameChanged(userNoteNameMap)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -581,10 +603,9 @@ class ProfileManager : BaseFrame<IProfileListener>(), IProfileManager {
|
|
|
}
|
|
|
|
|
|
override suspend fun updateUserNoteName(uid: Long, note: String): Rlt<Any> {
|
|
|
- val buildBatchGetUserRelationShipReq =
|
|
|
- UserRelationShipReq(RelationshipType.NOTE_NAME.type, uid, note)
|
|
|
+ val updateReq = AddRemarkAndDescReq(remark = note, peerUid = uid)
|
|
|
return when (val rlt =
|
|
|
- profileHttpService.buildRelationShip(buildBatchGetUserRelationShipReq)) {
|
|
|
+ profileHttpService.addUserRemark(updateReq)) {
|
|
|
is Rlt.Failed -> {
|
|
|
rlt
|
|
|
}
|
|
|
@@ -612,6 +633,10 @@ class ProfileManager : BaseFrame<IProfileListener>(), IProfileManager {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ override suspend fun updateUserDesc(uid: Long, desc: String): Rlt<Any> {
|
|
|
+ return profileHttpService.addUserRemark(AddRemarkAndDescReq(desc = desc, peerUid = uid))
|
|
|
+ }
|
|
|
+
|
|
|
private fun notifyAllUserNoteNameChanged(notifyMap: Map<Long, String>) {
|
|
|
dispatch {
|
|
|
it.onAllUserNoteNameChanged(notifyMap)
|