diff --git a/Shared/MPDClient/Extensions/MPDClient+Connection.swift b/Shared/MPDClient/Extensions/MPDClient+Connection.swift index 589cc2b..1a87b99 100644 --- a/Shared/MPDClient/Extensions/MPDClient+Connection.swift +++ b/Shared/MPDClient/Extensions/MPDClient+Connection.swift @@ -35,19 +35,21 @@ extension MPDClient { self.delegate?.willDisconnect(mpdClient: self) - mpd_connection_free(self.connection) - self.isConnected = false + mpd_connection_free(self.connection) + self.isConnected = false } func connect(host: String, port: Int) { - let commandOperation = BlockOperation() { [unowned self] in - self.sendCommand(command: .connect, userData: ["host": host, "port": port]) + if !isConnected { + let commandOperation = BlockOperation() { [unowned self] in + self.sendCommand(command: .connect, userData: ["host": host, "port": port]) - if self.isConnected { - self.idle() + if self.isConnected { + self.idle() + } } + commandQueue.addOperation(commandOperation) } - commandQueue.addOperation(commandOperation) } func disconnect() { diff --git a/iOS/App.swift b/iOS/App.swift index 89861e4..fcc70ac 100644 --- a/iOS/App.swift +++ b/iOS/App.swift @@ -11,7 +11,6 @@ import ReSwift struct App { static let store = Store(reducer: appReducer, state: nil) static let trackTimer = TrackTimer() - //static let userNotificationsController = UserNotificationsController() static let mpdServerDelegate = MPDServerDelegate() static let mpdServerController = MPDServerController(delegate: mpdServerDelegate) static var mpdClient: MPDClient! diff --git a/iOS/Components/Browser/Album Browser/AlbumViewController.swift b/iOS/Components/Browser/Album Browser/AlbumViewController.swift index dbc610f..a4e1db6 100644 --- a/iOS/Components/Browser/Album Browser/AlbumViewController.swift +++ b/iOS/Components/Browser/Album Browser/AlbumViewController.swift @@ -40,9 +40,6 @@ class AlbumViewController: UICollectionViewController { } @objc func willDisconnect() { - DispatchQueue.main.async { - App.store.dispatch(UpdateAlbumListAction(albums: [])) - } } override func prepare(for segue: UIStoryboardSegue, sender: Any?) { diff --git a/iOS/Components/Browser/Album Detail/AlbumDetailFooterView.swift b/iOS/Components/Browser/Album Detail/AlbumDetailFooterView.swift new file mode 100644 index 0000000..3e7618a --- /dev/null +++ b/iOS/Components/Browser/Album Detail/AlbumDetailFooterView.swift @@ -0,0 +1,9 @@ +// +// AlbumDetailFooterView.swift +// Persephone +// +// Created by Daniel Barber on 2020-4-2. +// Copyright © 2020 Dan Barber. All rights reserved. +// + +import Foundation diff --git a/iOS/SceneDelegate.swift b/iOS/SceneDelegate.swift index 2fc33dc..3a6c218 100644 --- a/iOS/SceneDelegate.swift +++ b/iOS/SceneDelegate.swift @@ -29,11 +29,13 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { // This occurs shortly after the scene enters the background, or when its session is discarded. // Release any resources associated with this scene that can be re-created the next time the scene connects. // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead). + App.mpdServerController.disconnect() } func sceneDidBecomeActive(_ scene: UIScene) { // Called when the scene has moved from an inactive state to an active state. // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. + App.mpdServerController.connect() } func sceneWillResignActive(_ scene: UIScene) {