-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add button and prepare view model to implement API
- Loading branch information
1 parent
5697d52
commit 71aa310
Showing
2 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,43 @@ | ||
import Foundation | ||
|
||
class PodcastFeedViewModel { | ||
enum LoadingState { | ||
case idle | ||
case loading | ||
} | ||
|
||
let uuid: String? | ||
|
||
private(set) var loadingState: LoadingState = .idle | ||
|
||
init(uuid: String?) { | ||
self.uuid = uuid | ||
} | ||
|
||
func checkIfNewEpisodesAreAvailable() async -> Bool { | ||
// Test implementation to simulate the API | ||
await MainActor.run { | ||
loadingState = .loading | ||
} | ||
_ = await shouldReloadPodcasts() | ||
|
||
try? await Task.sleep(nanoseconds: 3_000_000_000) | ||
|
||
await MainActor.run { | ||
Toast.show(L10n.podcastFeedReloadNoEpisodesFound) | ||
} | ||
await MainActor.run { | ||
loadingState = .idle | ||
} | ||
return false | ||
} | ||
|
||
private func shouldReloadPodcasts() async -> Int { | ||
await MainActor.run { | ||
Toast.show(L10n.podcastFeedReloadLoading) | ||
} | ||
return 202 | ||
} | ||
|
||
private func pollUpdatePodcast() async { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters