feat: 屏蔽直播贴

This commit is contained in:
HuanCheng65 2023-07-24 22:51:17 +08:00
parent 518d99f707
commit fad8571a4c
No known key found for this signature in database
GPG Key ID: 5EC9DD60A32C7360
4 changed files with 38 additions and 4 deletions

View File

@ -37,7 +37,7 @@ object FrsPageRepository {
threadInfo.copy(author = userList.find { it.id == threadInfo.authorId })
}
.filter { !App.INSTANCE.appPreferences.blockVideo || it.videoInfo == null }
.filter { it.threadTypes != 3072 } // 去他妈的直播
.filter { it.ala_info == null } // 去他妈的直播
response.copy(data_ = response.data_.copy(thread_list = threadList))
}
.onEach { lastResponse = it }

View File

@ -0,0 +1,31 @@
package com.huanchengfly.tieba.post.repository
import com.huanchengfly.tieba.post.api.TiebaApi
import kotlinx.coroutines.flow.map
object PersonalizedRepository {
/**
* 个性推荐
*
* @param loadType 加载类型1 - 下拉刷新 2 - 加载更多
* @param page 分页页码
*/
fun personalizedFlow(loadType: Int, page: Int = 1) =
TiebaApi.getInstance()
.personalizedProtoFlow(loadType, page)
.map { response ->
val liveThreadIds =
response.data_?.thread_list?.filter { it.ala_info != null }?.map { it.id }
?: emptyList()
response.copy(
data_ = response.data_?.copy(
thread_list = response.data_.thread_list.filter { !liveThreadIds.contains(it.id) },
thread_personalized = response.data_.thread_personalized.filter {
!liveThreadIds.contains(
it.tid
)
}
)
)
}
}

View File

@ -20,6 +20,7 @@ import com.huanchengfly.tieba.post.arch.UiIntent
import com.huanchengfly.tieba.post.arch.UiState
import com.huanchengfly.tieba.post.arch.wrapImmutable
import com.huanchengfly.tieba.post.models.DislikeBean
import com.huanchengfly.tieba.post.repository.PersonalizedRepository
import com.huanchengfly.tieba.post.utils.appPreferences
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.collections.immutable.ImmutableList
@ -66,7 +67,8 @@ class PersonalizedViewModel @Inject constructor() :
)
private fun produceRefreshPartialChange(): Flow<PersonalizedPartialChange.Refresh> =
TiebaApi.getInstance().personalizedProtoFlow(1, 1)
PersonalizedRepository
.personalizedFlow(1, 1)
.map<PersonalizedResponse, PersonalizedPartialChange.Refresh> { response ->
val data = response.toData().filter {
!App.INSTANCE.appPreferences.blockVideo || it.get { videoInfo } == null
@ -84,7 +86,8 @@ class PersonalizedViewModel @Inject constructor() :
.catch { emit(PersonalizedPartialChange.Refresh.Failure(it)) }
private fun PersonalizedUiIntent.LoadMore.producePartialChange(): Flow<PersonalizedPartialChange.LoadMore> =
TiebaApi.getInstance().personalizedProtoFlow(2, page)
PersonalizedRepository
.personalizedFlow(2, page)
.map<PersonalizedResponse, PersonalizedPartialChange.LoadMore> { response ->
val data = response.toData().filter {
!App.INSTANCE.appPreferences.blockVideo || it.get { videoInfo } == null

View File

@ -51,7 +51,7 @@ message ThreadInfo {
optional VideoInfo videoInfo = 79;
repeated PbContent richTitle = 111;
repeated PbContent richAbstract = 112;
AlaLiveInfo ala_info = 113;
optional AlaLiveInfo ala_info = 113;
repeated DislikeInfo dislikeInfo = 120;
int32 agreeNum = 124;
Agree agree = 126;