Skip to content

Commit

Permalink
Execute radio/playlist view updates in main thread only
Browse files Browse the repository at this point in the history
  • Loading branch information
sitomani committed Feb 13, 2024
1 parent 68ab001 commit 39a0ebb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
19 changes: 12 additions & 7 deletions 4champ/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,25 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}

if components.path == "/mod", let idString = components.queryItems?.first?.value, let modId = Int(idString) {
dlController.rootViewController = UIApplication.shared.windows[0].rootViewController
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
let window = windowScene.windows.first else {
return false
}
dlController.rootViewController = window.rootViewController
dlController.show(modId: modId)
}

return true
}

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
if url.scheme == "fourchamp" && url.host == "modules" {
if let idString = url.path.split(separator: "/").first, let modId = Int(idString) {
dlController.show(modId: modId)
DispatchQueue.main.async {
if url.scheme == "fourchamp" && url.host == "modules" {
if let idString = url.path.split(separator: "/").first, let modId = Int(idString) {
self.dlController.show(modId: modId)
}
} else {
self.dlController.showImport(for: [url])
}
} else {
dlController.showImport(for: [url])
}
return true
}
Expand Down
8 changes: 6 additions & 2 deletions 4champ/Scenes/Playlists/PlaylistPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,14 @@ class PlaylistPresenter: PlaylistPresentationLogic {
}

let vm = Playlists.Select.ViewModel(playlistName: name, shuffle: shuffle, modules: mods)
viewController?.displayPlaylist(viewModel: vm)
DispatchQueue.main.async {
self.viewController?.displayPlaylist(viewModel: vm)
}
}

func presentModeChange(shuffled: Bool) {
viewController?.displayModeChange(shuffled: shuffled)
DispatchQueue.main.async {
self.viewController?.displayModeChange(shuffled: shuffled)
}
}
}
4 changes: 3 additions & 1 deletion 4champ/Scenes/Radio/RadioPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ class RadioPresenter: RadioPresentationLogic {
}

func presentSessionHistoryInsert() {
self.viewController?.displaySessionHistoryInsert()
DispatchQueue.main.async {
self.viewController?.displaySessionHistoryInsert()
}
}

func presentPlaybackTime(length: Int, elapsed: Int) {
Expand Down

0 comments on commit 39a0ebb

Please sign in to comment.