This commit is contained in:
Simplxs 2024-01-18 20:04:53 +08:00
parent 0fb88e3e44
commit 81be383b5f
No known key found for this signature in database
GPG Key ID: E23537FF14DD6507

View File

@ -179,7 +179,7 @@ internal object GroupSvc: BaseSvc() {
var troopList = service.allTroopList var troopList = service.allTroopList
if(refresh || !service.isTroopCacheInited || troopList == null) { if(refresh || !service.isTroopCacheInited || troopList == null) {
if(!requestGroupList(service)) { if(!requestGroupInfo(service)) {
return Result.failure(Exception("获取群列表失败")) return Result.failure(Exception("获取群列表失败"))
} else { } else {
troopList = service.allTroopList troopList = service.allTroopList
@ -192,17 +192,10 @@ internal object GroupSvc: BaseSvc() {
val service = app val service = app
.getRuntimeService(ITroopInfoService::class.java, "all") .getRuntimeService(ITroopInfoService::class.java, "all")
var groupInfo = getGroupInfo(groupId) val groupInfo = getGroupInfo(groupId)
return if(refresh || !service.isTroopCacheInited || groupInfo.troopuin.isNullOrBlank()) { return if(refresh || !service.isTroopCacheInited || groupInfo.troopuin.isNullOrBlank()) {
requestGroupList(service, groupId.toLong()).onFailure { requestGroupInfo(service, groupId.toLong())
groupInfo = service.findTroopInfo(groupId)
if (groupInfo.troopuin.isNullOrBlank()) {
Result.failure(it)
} else {
Result.success(groupInfo)
}
}
} else { } else {
Result.success(groupInfo) Result.success(groupInfo)
} }
@ -567,7 +560,7 @@ internal object GroupSvc: BaseSvc() {
} }
} }
private suspend fun requestGroupList( private suspend fun requestGroupInfo(
service: ITroopInfoService service: ITroopInfoService
): Boolean { ): Boolean {
refreshTroopList() refreshTroopList()
@ -660,9 +653,9 @@ internal object GroupSvc: BaseSvc() {
METHOD_REQ_MEMBER_INFO_V2.invoke(businessHandler, groupId.toString(), groupUin2GroupCode(groupId).toString(), arrayListOf(memberUin.toString())) METHOD_REQ_MEMBER_INFO_V2.invoke(businessHandler, groupId.toString(), groupUin2GroupCode(groupId).toString(), arrayListOf(memberUin.toString()))
} }
private suspend fun requestGroupList(dataService: ITroopInfoService, uin: Long): Result<TroopInfo> { private suspend fun requestGroupInfo(dataService: ITroopInfoService, uin: Long): Result<TroopInfo> {
val strUin = uin.toString() val strUin = uin.toString()
val list = withTimeoutOrNull(5000) { val info = withTimeoutOrNull(5000) {
var troopInfo: TroopInfo? var troopInfo: TroopInfo?
do { do {
troopInfo = dataService.getTroopInfo(strUin) troopInfo = dataService.getTroopInfo(strUin)
@ -670,8 +663,8 @@ internal object GroupSvc: BaseSvc() {
} while (troopInfo == null || troopInfo.troopuin.isNullOrBlank()) } while (troopInfo == null || troopInfo.troopuin.isNullOrBlank())
return@withTimeoutOrNull troopInfo return@withTimeoutOrNull troopInfo
} }
return if (list != null) { return if (info != null) {
Result.success(list) Result.success(info)
} else { } else {
Result.failure(Exception("获取群列表失败")) Result.failure(Exception("获取群列表失败"))
} }