Skip to content

Commit

Permalink
仅当 EpisodeInfo 变更时才重新查询数数据源
Browse files Browse the repository at this point in the history
否则在自动标记看过后会刷新, 导致弹幕重新加载
  • Loading branch information
Him188 committed Nov 10, 2024
1 parent aa89da5 commit d876f0d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ private class EpisodeViewModelImpl(
emitAll(episodeCollectionRepository.episodeCollectionInfoFlow(subjectId, episodeId))
}.stateInBackground(null)

private val episodeInfo = episodeCollection.map { it?.episodeInfo }
private val episodeInfo = episodeCollection.map { it?.episodeInfo }.distinctUntilChanged()
private val subjectDetailsStateFactory: SubjectDetailsStateFactory by inject()

// Media Selection
Expand All @@ -257,7 +257,7 @@ private class EpisodeViewModelImpl(
} else {
subjectInfo.map { subjectInfo ->
MediaFetchRequest.create(subjectInfo, episodeInfo)
}
}.distinctUntilChanged()
},
)
}.shareInBackground(started = SharingStarted.Lazily)
Expand Down
11 changes: 10 additions & 1 deletion datasource/api/src/commonMain/kotlin/source/MediaFetchRequest.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright (C) 2024 OpenAni and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license, which can be found at the following link.
*
* https://github.com/open-ani/ani/blob/main/LICENSE
*/

package me.him188.ani.datasources.api.source

import kotlinx.serialization.Serializable
Expand All @@ -10,7 +19,7 @@ import me.him188.ani.datasources.api.MediaCacheMetadata
* @see MediaSource.fetch
*/
@Serializable
class MediaFetchRequest(
data class MediaFetchRequest(
// 提示, 查看 [MediaFetcher]
/**
* 条目服务 (Bangumi) 提供的条目 ID. 若数据源支持, 可以用此信息做精确匹配.
Expand Down

0 comments on commit d876f0d

Please sign in to comment.