Skip to content

Commit 9a1098a

Browse files
committed
Move cellular check into PlaybackManager
1 parent 3268fb8 commit 9a1098a

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

podcasts/PlaybackActionHelper.swift

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,7 @@ class PlaybackActionHelper {
1414
return
1515
}
1616

17-
if !episode.downloaded(pathFinder: DownloadManager.shared) {
18-
NetworkUtils.shared.streamEpisodeRequested({
19-
performPlay(episode: episode, filterUuid: filterUuid, podcastUuid: podcastUuid)
20-
}, disallowed: nil)
21-
} else {
22-
performPlay(episode: episode, filterUuid: filterUuid, podcastUuid: podcastUuid)
23-
}
17+
performPlay(episode: episode, filterUuid: filterUuid, podcastUuid: podcastUuid)
2418
}
2519

2620
class func pause() {

podcasts/PlaybackManager.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,24 @@ class PlaybackManager: ServerPlaybackDelegate {
211211
}
212212
}
213213

214-
func play(completion: (() -> Void)? = nil, userInitiated: Bool = true) {
214+
private var cellularAllowedEpisodeUUID: String?
215+
216+
func play(completion: (() -> Void)? = nil, userInitiated: Bool = true, allowed: Bool = false) {
215217
guard let currEpisode = currentEpisode() else { return }
216218

219+
if allowed {
220+
cellularAllowedEpisodeUUID = currEpisode.uuid
221+
}
222+
223+
#if !os(watchOS) && !APPCLIP
224+
if !allowed && cellularAllowedEpisodeUUID != currEpisode.uuid && !currEpisode.downloaded(pathFinder: DownloadManager.shared) {
225+
NetworkUtils.shared.streamEpisodeRequested({ [weak self] in
226+
self?.play(completion: completion, userInitiated: userInitiated, allowed: true)
227+
}, disallowed: nil)
228+
return
229+
}
230+
#endif
231+
217232
FileLog.shared.addMessage("PlaybackManager Play \(currentEpisode()?.title ?? "unknown episode") userInitiated: \(userInitiated)")
218233

219234
if userInitiated {

0 commit comments

Comments
 (0)