good enough fix for the problems

This commit is contained in:
talksik
2022-01-03 19:45:35 -08:00
parent 4f4e5ba397
commit e1735bb8ed
2 changed files with 23 additions and 21 deletions
@@ -386,7 +386,6 @@ extension AuthSessionStore {
let currMessage = try queryDocumentSnapshot.data(as: Message.self)
// print("new message received! \(currMessage!.sentTimestamp)")
DispatchQueue.main.async {
if currMessage != nil { // not really possible but just check
// if the user doesn't exist for the dictionary, then add it
// this means it's most likely someone new (never had user_friend relationship before) messaging for the user's inbox
@@ -407,7 +406,6 @@ extension AuthSessionStore {
}
}
}
}
return currMessage
} catch {
@@ -282,8 +282,6 @@ extension InnerCircleViewModel {
return
}
print("current state of cached audio files: \(self.cachedPlayerItemsDict)")
// start playing if there are messages to listen to
print("have \(AVPlayerItems.count) messages to play")
@@ -308,6 +306,11 @@ extension InnerCircleViewModel {
totalDuration = CMTimeAdd(totalDuration, item.asset.duration)
}
// TODO: not hitting the last one/100%
// it either plays on time or there is a little lag on multiple items...
// offset this by adding 1 when it reaches the totalDuration as it's longer
totalDuration = CMTimeSubtract(totalDuration, CMTimeMakeWithSeconds(1, preferredTimescale: 1))
var times = [NSValue]()
// Set initial time to zero
var currentTime = CMTime.zero
@@ -320,8 +323,9 @@ extension InnerCircleViewModel {
times.append(NSValue(time: currentTime))
}
// Add time observer. Observe boundary time changes on the main queue.
// TODO: not hitting the last one/100%
self.queuePlayer.addBoundaryTimeObserver(forTimes: times, queue: .main) { [weak self] in
// Update UI
self?.messagesListeningProgress += Float(Self.multiplier)