修复一些未处理异常,切换到测试服务器
This commit is contained in:
@@ -80,9 +80,9 @@ class AgentPagingSource(
|
||||
authorId = authorId
|
||||
)
|
||||
LoadResult.Page(
|
||||
data = users.list,
|
||||
data = users?.list ?: listOf(),
|
||||
prevKey = if (currentPage == 1) null else currentPage - 1,
|
||||
nextKey = if (users.list.isEmpty()) null else users.page + 1
|
||||
nextKey = if (users?.list?.isNotEmpty() == true) users.page + 1 else null
|
||||
)
|
||||
} catch (exception: IOException) {
|
||||
return LoadResult.Error(exception)
|
||||
@@ -102,7 +102,7 @@ class AgentRemoteDataSource(
|
||||
suspend fun getAgent(
|
||||
pageNumber: Int,
|
||||
authorId: Int? = null
|
||||
): ListContainer<AgentEntity> {
|
||||
): ListContainer<AgentEntity>? {
|
||||
return agentService.getAgent(
|
||||
pageNumber = pageNumber,
|
||||
authorId = authorId
|
||||
@@ -117,7 +117,7 @@ class AgentServiceImpl() : AgentService {
|
||||
pageNumber: Int,
|
||||
pageSize: Int,
|
||||
authorId: Int?
|
||||
): ListContainer<AgentEntity> {
|
||||
): ListContainer<AgentEntity>? {
|
||||
return agentBackend.getAgent(
|
||||
pageNumber = pageNumber,
|
||||
authorId = authorId
|
||||
@@ -130,7 +130,7 @@ class AgentBackend {
|
||||
suspend fun getAgent(
|
||||
pageNumber: Int,
|
||||
authorId: Int? = null
|
||||
): ListContainer<AgentEntity> {
|
||||
): ListContainer<AgentEntity>? {
|
||||
// 如果是游客模式且获取我的Agent(authorId为null),返回空列表
|
||||
if (authorId == null && AppStore.isGuest) {
|
||||
return ListContainer(
|
||||
@@ -154,7 +154,7 @@ class AgentBackend {
|
||||
)
|
||||
}
|
||||
|
||||
val body = resp.body() ?: throw ServiceException("Failed to get agents")
|
||||
val body = resp.body() ?: return null
|
||||
|
||||
// 处理不同的返回类型
|
||||
return if (authorId != null) {
|
||||
|
||||
Reference in New Issue
Block a user