mirror of
https://github.com/yattee/yattee.git
synced 2024-12-13 22:00:31 +05:30
remove superfluous vars and chaptermodel
This commit is contained in:
parent
982dca1846
commit
aa5d6733b2
@ -131,8 +131,7 @@ final class PlayerModel: ObservableObject {
|
||||
@Default(.rotateToLandscapeOnEnterFullScreen) private var rotateToLandscapeOnEnterFullScreen
|
||||
#endif
|
||||
|
||||
@Published var playedChapters: [Int] = []
|
||||
@Published var currentChapterIndex: Int?
|
||||
@Published var currentChapter: Int?
|
||||
|
||||
var accounts: AccountsModel { .shared }
|
||||
var comments: CommentsModel { .shared }
|
||||
|
@ -12,11 +12,7 @@ import SwiftUI
|
||||
@ObservedObject private var player = PlayerModel.shared
|
||||
|
||||
var isCurrentChapter: Bool {
|
||||
player.currentChapterIndex == chapterIndex
|
||||
}
|
||||
|
||||
var hasBeenPlayed: Bool {
|
||||
player.playedChapters.contains(chapterIndex)
|
||||
player.currentChapter == chapterIndex
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
@ -35,6 +31,7 @@ import SwiftUI
|
||||
.buttonStyle(.plain)
|
||||
.onReceive(PlayerTimeModel.shared.$currentTime) { cmTime in
|
||||
self.handleTimeUpdate(cmTime)
|
||||
print("currentChapterIndex:", player.currentChapter ?? 0)
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,10 +77,7 @@ import SwiftUI
|
||||
private func handleTimeUpdate(_ cmTime: CMTime) {
|
||||
let time = CMTimeGetSeconds(cmTime)
|
||||
if time >= chapter.start, nextChapterStart == nil || time < nextChapterStart! {
|
||||
player.currentChapterIndex = chapterIndex
|
||||
if !player.playedChapters.contains(chapterIndex) {
|
||||
player.playedChapters.append(chapterIndex)
|
||||
}
|
||||
player.currentChapter = chapterIndex
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user