1
0
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:
Toni Förster 2023-12-03 20:04:57 +01:00
parent 982dca1846
commit aa5d6733b2
No known key found for this signature in database
GPG Key ID: 292F3E5086C83FC7
2 changed files with 4 additions and 11 deletions

View File

@ -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 }

View File

@ -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
}
}
}