Update:iOS remove unused logic of opening last active session on app launch

This commit is contained in:
advplyr 2023-11-12 13:36:23 -06:00
parent 36be91962c
commit ad5146e2ee
2 changed files with 3 additions and 20 deletions

View file

@ -273,7 +273,7 @@ export default {
this.notifyOnReady() this.notifyOnReady()
}, },
notifyOnReady() { notifyOnReady() {
// TODO: iOS opens last active playback session on app launch. Should be consistent with Android // TODO: was used on iOS to open last played media. May be removed
if (!this.isIos) return if (!this.isIos) return
// If settings aren't loaded yet, native player will receive incorrect settings // If settings aren't loaded yet, native player will receive incorrect settings

View file

@ -31,25 +31,8 @@ public class AbsAudioPlayer: CAPPlugin {
} }
@objc func onReady(_ call: CAPPluginCall) { @objc func onReady(_ call: CAPPluginCall) {
Task { await self.restorePlaybackSession() } // TODO: Was used to notify when Abs UI was ready so that last played media could be opened - this was buggy and removed
} call.resolve()
func restorePlaybackSession() async {
do {
// Fetch the most recent active session
let activeSession = try Realm(queue: nil).objects(PlaybackSession.self).where({
$0.isActiveSession == true && $0.serverConnectionConfigId == Store.serverConfig?.id
}).last?.freeze()
if let activeSession = activeSession {
PlayerHandler.stopPlayback(currentSessionId: activeSession.id)
await PlayerProgress.shared.syncFromServer()
try self.startPlaybackSession(activeSession, playWhenReady: false, playbackRate: PlayerSettings.main().playbackRate)
}
} catch {
logger.error("Failed to restore playback session")
debugPrint(error)
}
} }
@objc func startPlaybackSession(_ session: PlaybackSession, playWhenReady: Bool, playbackRate: Float) throws { @objc func startPlaybackSession(_ session: PlaybackSession, playWhenReady: Bool, playbackRate: Float) throws {