mirror of
https://github.com/danbee/persephone
synced 2025-03-04 08:39:11 +00:00
Compare commits
3 Commits
22bb7efef2
...
4d2a8087ed
| Author | SHA1 | Date | |
|---|---|---|---|
| 4d2a8087ed | |||
| b311005393 | |||
| 0de001ce16 |
@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2018 Dan Barber. All rights reserved.
|
// Copyright © 2018 Dan Barber. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import AppKit
|
||||||
import ReSwift
|
import ReSwift
|
||||||
import MediaKeyTap
|
import MediaKeyTap
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import AppKit
|
||||||
import ReSwift
|
import ReSwift
|
||||||
import Differ
|
import Differ
|
||||||
|
|
||||||
@ -28,15 +28,6 @@ class AlbumViewController: NSViewController,
|
|||||||
albumScrollView.postsBoundsChangedNotifications = true
|
albumScrollView.postsBoundsChangedNotifications = true
|
||||||
|
|
||||||
albumCollectionView.dataSource = dataSource
|
albumCollectionView.dataSource = dataSource
|
||||||
|
|
||||||
// preferences.addObserver(self, forKeyPath: "mpdLibraryDir")
|
|
||||||
// preferences.addObserver(self, forKeyPath: "fetchMissingArtworkFromInternet")
|
|
||||||
}
|
|
||||||
|
|
||||||
override func viewWillDisappear() {
|
|
||||||
super.viewWillDisappear()
|
|
||||||
|
|
||||||
AppDelegate.store.unsubscribe(self)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override func viewWillLayout() {
|
override func viewWillLayout() {
|
||||||
@ -68,7 +59,7 @@ class AlbumViewController: NSViewController,
|
|||||||
case "mpdLibraryDir":
|
case "mpdLibraryDir":
|
||||||
albumCollectionView.reloadData()
|
albumCollectionView.reloadData()
|
||||||
case "fetchMissingArtworkFromInternet":
|
case "fetchMissingArtworkFromInternet":
|
||||||
AppDelegate.store.dispatch(ResetAlbumListCoverArt())
|
AppDelegate.store.dispatch(ResetAlbumListCoverArtAction())
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -82,16 +73,11 @@ extension AlbumViewController: StoreSubscriber {
|
|||||||
typealias StoreSubscriberStateType = AlbumListState
|
typealias StoreSubscriberStateType = AlbumListState
|
||||||
|
|
||||||
func newState(state: StoreSubscriberStateType) {
|
func newState(state: StoreSubscriberStateType) {
|
||||||
if dataSource.albums == [] {
|
let oldAlbums = dataSource.albums
|
||||||
dataSource.albums = state.albums
|
dataSource.albums = state.albums
|
||||||
albumCollectionView.reloadData()
|
albumCollectionView.animateItemChanges(
|
||||||
} else {
|
oldData: oldAlbums,
|
||||||
let oldAlbums = dataSource.albums
|
newData: dataSource.albums
|
||||||
dataSource.albums = state.albums
|
)
|
||||||
albumCollectionView.animateItemChanges(
|
|
||||||
oldData: oldAlbums,
|
|
||||||
newData: dataSource.albums
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import AppKit
|
||||||
|
|
||||||
class AlbumViewItem: NSCollectionViewItem {
|
class AlbumViewItem: NSCollectionViewItem {
|
||||||
var observer: NSKeyValueObservation?
|
var observer: NSKeyValueObservation?
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import AppKit
|
||||||
|
|
||||||
class MainSplitViewController: NSSplitViewController {
|
class MainSplitViewController: NSSplitViewController {
|
||||||
override func keyDown(with event: NSEvent) {
|
override func keyDown(with event: NSEvent) {
|
||||||
|
|||||||
@ -30,13 +30,13 @@ class NotificationsController: MPDClientDelegate {
|
|||||||
|
|
||||||
func willStartDatabaseUpdate(mpdClient: MPDClient) {
|
func willStartDatabaseUpdate(mpdClient: MPDClient) {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
AppDelegate.store.dispatch(StartedDatabaseUpdate())
|
AppDelegate.store.dispatch(StartedDatabaseUpdateAction())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func didFinishDatabaseUpdate(mpdClient: MPDClient) {
|
func didFinishDatabaseUpdate(mpdClient: MPDClient) {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
AppDelegate.store.dispatch(FinishedDatabaseUpdate())
|
AppDelegate.store.dispatch(FinishedDatabaseUpdateAction())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import AppKit
|
||||||
import ReSwift
|
import ReSwift
|
||||||
|
|
||||||
class QueueViewController: NSViewController,
|
class QueueViewController: NSViewController,
|
||||||
@ -27,12 +27,6 @@ class QueueViewController: NSViewController,
|
|||||||
queueView.columnAutoresizingStyle = .sequentialColumnAutoresizingStyle
|
queueView.columnAutoresizingStyle = .sequentialColumnAutoresizingStyle
|
||||||
}
|
}
|
||||||
|
|
||||||
override func viewWillDisappear() {
|
|
||||||
super.viewWillDisappear()
|
|
||||||
|
|
||||||
AppDelegate.store.unsubscribe(self)
|
|
||||||
}
|
|
||||||
|
|
||||||
override func keyDown(with event: NSEvent) {
|
override func keyDown(with event: NSEvent) {
|
||||||
switch event.keyCode {
|
switch event.keyCode {
|
||||||
case NSEvent.keyCodeSpace:
|
case NSEvent.keyCodeSpace:
|
||||||
@ -128,7 +122,8 @@ extension QueueViewController: StoreSubscriber {
|
|||||||
typealias StoreSubscriberStateType = QueueState
|
typealias StoreSubscriberStateType = QueueState
|
||||||
|
|
||||||
func newState(state: StoreSubscriberStateType) {
|
func newState(state: StoreSubscriberStateType) {
|
||||||
dataSource.setQueueIcon()
|
dataSource.queue = state.queue
|
||||||
|
dataSource.setQueueIcon(state)
|
||||||
queueView.reloadData()
|
queueView.reloadData()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import AppKit
|
||||||
import ReSwift
|
import ReSwift
|
||||||
|
|
||||||
class WindowController: NSWindowController {
|
class WindowController: NSWindowController {
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import AppKit
|
||||||
import PromiseKit
|
import PromiseKit
|
||||||
|
|
||||||
class AlbumDataSource: NSObject, NSCollectionViewDataSource {
|
class AlbumDataSource: NSObject, NSCollectionViewDataSource {
|
||||||
@ -33,7 +33,7 @@ class AlbumDataSource: NSObject, NSCollectionViewDataSource {
|
|||||||
.done { image in
|
.done { image in
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
AppDelegate.store.dispatch(
|
AppDelegate.store.dispatch(
|
||||||
UpdateCoverArt(coverArt: image, albumIndex: indexPath.item)
|
UpdateCoverArtAction(coverArt: image, albumIndex: indexPath.item)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,13 +6,14 @@
|
|||||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import AppKit
|
||||||
|
|
||||||
class QueueDataSource: NSObject, NSOutlineViewDataSource {
|
class QueueDataSource: NSObject, NSOutlineViewDataSource {
|
||||||
|
var queue: [QueueItem] = []
|
||||||
var queueIcon: NSImage? = nil
|
var queueIcon: NSImage? = nil
|
||||||
|
|
||||||
func setQueueIcon() {
|
func setQueueIcon(_ state: QueueState) {
|
||||||
switch AppDelegate.store.state.playerState.state {
|
switch state.state {
|
||||||
case .playing?:
|
case .playing?:
|
||||||
queueIcon = .playIcon
|
queueIcon = .playIcon
|
||||||
case .paused?:
|
case .paused?:
|
||||||
@ -23,7 +24,7 @@ class QueueDataSource: NSObject, NSOutlineViewDataSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func outlineView(_ outlineView: NSOutlineView, numberOfChildrenOfItem item: Any?) -> Int {
|
func outlineView(_ outlineView: NSOutlineView, numberOfChildrenOfItem item: Any?) -> Int {
|
||||||
return AppDelegate.store.state.queueState.queue.count + 1
|
return queue.count + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
func outlineView(_ outlineView: NSOutlineView, isItemExpandable item: Any) -> Bool {
|
func outlineView(_ outlineView: NSOutlineView, isItemExpandable item: Any) -> Bool {
|
||||||
@ -32,7 +33,7 @@ class QueueDataSource: NSObject, NSOutlineViewDataSource {
|
|||||||
|
|
||||||
func outlineView(_ outlineView: NSOutlineView, child index: Int, ofItem item: Any?) -> Any {
|
func outlineView(_ outlineView: NSOutlineView, child index: Int, ofItem item: Any?) -> Any {
|
||||||
if index > 0 {
|
if index > 0 {
|
||||||
return AppDelegate.store.state.queueState.queue[index - 1]
|
return queue[index - 1]
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import AppKit
|
||||||
|
|
||||||
extension CGColor {
|
extension CGColor {
|
||||||
static let albumBorderColorLight = NSColor.black.withAlphaComponent(0.15).cgColor
|
static let albumBorderColorLight = NSColor.black.withAlphaComponent(0.15).cgColor
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import AppKit
|
||||||
|
|
||||||
extension NSEvent {
|
extension NSEvent {
|
||||||
static let keyCodeSpace: UInt16 = 49
|
static let keyCodeSpace: UInt16 = 49
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import AppKit
|
||||||
|
|
||||||
extension NSFont {
|
extension NSFont {
|
||||||
static let systemFontRegular = systemFont(ofSize: 13, weight: .regular)
|
static let systemFontRegular = systemFont(ofSize: 13, weight: .regular)
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import AppKit
|
||||||
|
|
||||||
extension NSImage {
|
extension NSImage {
|
||||||
static let playIcon = NSImage(named: "playButton")
|
static let playIcon = NSImage(named: "playButton")
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import AppKit
|
||||||
|
|
||||||
extension NSUserInterfaceItemIdentifier {
|
extension NSUserInterfaceItemIdentifier {
|
||||||
static let queueSongTitleColumn = NSUserInterfaceItemIdentifier("songTitleColumn")
|
static let queueSongTitleColumn = NSUserInterfaceItemIdentifier("songTitleColumn")
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import AppKit
|
||||||
|
|
||||||
class AlbumViewLayout: NSCollectionViewFlowLayout {
|
class AlbumViewLayout: NSCollectionViewFlowLayout {
|
||||||
let maxItemWidth: CGFloat = 180
|
let maxItemWidth: CGFloat = 180
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import AppKit
|
||||||
import CryptoSwift
|
import CryptoSwift
|
||||||
|
|
||||||
struct Album {
|
struct Album {
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import AppKit
|
||||||
|
|
||||||
class TrackTimer: NSObject {
|
class TrackTimer: NSObject {
|
||||||
var timer: Timer?
|
var timer: Timer?
|
||||||
@ -16,12 +16,12 @@ class TrackTimer: NSObject {
|
|||||||
func start(elapsedTimeMs: UInt?) {
|
func start(elapsedTimeMs: UInt?) {
|
||||||
guard let elapsedTimeMs = elapsedTimeMs else { return }
|
guard let elapsedTimeMs = elapsedTimeMs else { return }
|
||||||
|
|
||||||
timer?.invalidate()
|
|
||||||
|
|
||||||
startTime = CACurrentMediaTime()
|
startTime = CACurrentMediaTime()
|
||||||
startElapsed = Double(elapsedTimeMs) / 1000
|
startElapsed = Double(elapsedTimeMs) / 1000
|
||||||
|
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
|
self.timer?.invalidate()
|
||||||
|
|
||||||
self.timer = Timer.scheduledTimer(
|
self.timer = Timer.scheduledTimer(
|
||||||
withTimeInterval: 0.25,
|
withTimeInterval: 0.25,
|
||||||
repeats: true
|
repeats: true
|
||||||
@ -41,9 +41,9 @@ class TrackTimer: NSObject {
|
|||||||
func stop(elapsedTimeMs: UInt?) {
|
func stop(elapsedTimeMs: UInt?) {
|
||||||
guard let elapsedTimeMs = elapsedTimeMs else { return }
|
guard let elapsedTimeMs = elapsedTimeMs else { return }
|
||||||
|
|
||||||
timer?.invalidate()
|
|
||||||
|
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
|
self.timer?.invalidate()
|
||||||
|
|
||||||
AppDelegate.store.dispatch(
|
AppDelegate.store.dispatch(
|
||||||
UpdateElapsedTimeAction(elapsedTimeMs: elapsedTimeMs)
|
UpdateElapsedTimeAction(elapsedTimeMs: elapsedTimeMs)
|
||||||
)
|
)
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import AppKit
|
||||||
|
|
||||||
class CoverArtQueue {
|
class CoverArtQueue {
|
||||||
static let shared = CoverArtQueue()
|
static let shared = CoverArtQueue()
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import AppKit
|
||||||
|
|
||||||
class CoverArtPrefsController: NSViewController {
|
class CoverArtPrefsController: NSViewController {
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import AppKit
|
||||||
import ReSwift
|
import ReSwift
|
||||||
|
|
||||||
class GeneralPrefsViewController: NSViewController {
|
class GeneralPrefsViewController: NSViewController {
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import AppKit
|
||||||
|
|
||||||
class PreferencesViewController: NSTabViewController {
|
class PreferencesViewController: NSTabViewController {
|
||||||
private lazy var tabViewSizes: [String : NSSize] = [:]
|
private lazy var tabViewSizes: [String : NSSize] = [:]
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import AppKit
|
||||||
|
|
||||||
class PreferencesWindowController: NSWindowController, NSWindowDelegate {
|
class PreferencesWindowController: NSWindowController, NSWindowDelegate {
|
||||||
override func windowDidLoad() {
|
override func windowDidLoad() {
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import AppKit
|
||||||
import PromiseKit
|
import PromiseKit
|
||||||
|
|
||||||
class CoverArtService {
|
class CoverArtService {
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import AppKit
|
||||||
import PromiseKit
|
import PromiseKit
|
||||||
|
|
||||||
extension CoverArtService {
|
extension CoverArtService {
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import AppKit
|
||||||
import PromiseKit
|
import PromiseKit
|
||||||
|
|
||||||
extension CoverArtService {
|
extension CoverArtService {
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import AppKit
|
||||||
import SwiftyJSON
|
import SwiftyJSON
|
||||||
import PromiseKit
|
import PromiseKit
|
||||||
import PMKFoundation
|
import PMKFoundation
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import AppKit
|
||||||
|
|
||||||
struct SongNotifierService {
|
struct SongNotifierService {
|
||||||
let song: Song
|
let song: Song
|
||||||
|
|||||||
@ -6,12 +6,12 @@
|
|||||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import AppKit
|
||||||
import ReSwift
|
import ReSwift
|
||||||
|
|
||||||
struct ResetAlbumListCoverArt: Action {}
|
struct ResetAlbumListCoverArtAction: Action {}
|
||||||
|
|
||||||
struct UpdateCoverArt: Action {
|
struct UpdateCoverArtAction: Action {
|
||||||
var coverArt: NSImage?
|
var coverArt: NSImage?
|
||||||
var albumIndex: Int
|
var albumIndex: Int
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,14 +6,14 @@
|
|||||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import AppKit
|
||||||
import ReSwift
|
import ReSwift
|
||||||
|
|
||||||
struct UpdateCurrentCoverArt: Action {
|
struct UpdateCurrentCoverArtAction: Action {
|
||||||
var coverArt: NSImage?
|
var coverArt: NSImage?
|
||||||
}
|
}
|
||||||
|
|
||||||
struct UpdateCurrentSong: Action {
|
struct UpdateCurrentSongAction: Action {
|
||||||
var currentSong: Song
|
var currentSong: Song
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,6 +25,6 @@ struct UpdateStatusAction: Action {
|
|||||||
var status: MPDClient.MPDStatus
|
var status: MPDClient.MPDStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
struct StartedDatabaseUpdate: Action {}
|
struct StartedDatabaseUpdateAction: Action {}
|
||||||
|
|
||||||
struct FinishedDatabaseUpdate: Action {}
|
struct FinishedDatabaseUpdateAction: Action {}
|
||||||
|
|||||||
@ -15,3 +15,7 @@ struct UpdateQueueAction: Action {
|
|||||||
struct UpdateQueuePosAction: Action {
|
struct UpdateQueuePosAction: Action {
|
||||||
var queuePos: Int
|
var queuePos: Int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct UpdateQueuePlayerStateAction: Action {
|
||||||
|
var state: MPDClient.MPDStatus.State?
|
||||||
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import AppKit
|
||||||
import ReSwift
|
import ReSwift
|
||||||
|
|
||||||
struct PlayerState: StateType {
|
struct PlayerState: StateType {
|
||||||
|
|||||||
@ -11,11 +11,14 @@ import ReSwift
|
|||||||
struct QueueState: StateType {
|
struct QueueState: StateType {
|
||||||
var queue: [QueueItem] = []
|
var queue: [QueueItem] = []
|
||||||
var queuePos: Int = -1
|
var queuePos: Int = -1
|
||||||
|
|
||||||
|
var state: MPDClient.MPDStatus.State?
|
||||||
}
|
}
|
||||||
|
|
||||||
extension QueueState: Equatable {
|
extension QueueState: Equatable {
|
||||||
static func == (lhs: QueueState, rhs: QueueState) -> Bool {
|
static func == (lhs: QueueState, rhs: QueueState) -> Bool {
|
||||||
return (lhs.queue == rhs.queue) &&
|
return (lhs.queue == rhs.queue) &&
|
||||||
(lhs.queuePos == rhs.queuePos)
|
(lhs.queuePos == rhs.queuePos) &&
|
||||||
|
(lhs.state == rhs.state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,10 +15,10 @@ func albumListReducer(action: Action, state: AlbumListState?) -> AlbumListState
|
|||||||
case let action as UpdateAlbumListAction:
|
case let action as UpdateAlbumListAction:
|
||||||
state.albums = action.albums.map { Album(mpdAlbum: $0) }
|
state.albums = action.albums.map { Album(mpdAlbum: $0) }
|
||||||
|
|
||||||
case let action as UpdateCoverArt:
|
case let action as UpdateCoverArtAction:
|
||||||
state.albums[action.albumIndex].coverArt = .loaded(action.coverArt)
|
state.albums[action.albumIndex].coverArt = .loaded(action.coverArt)
|
||||||
|
|
||||||
case is ResetAlbumListCoverArt:
|
case is ResetAlbumListCoverArtAction:
|
||||||
state.albums = AppDelegate.store.state.albumListState.albums.map {
|
state.albums = AppDelegate.store.state.albumListState.albums.map {
|
||||||
var album = $0
|
var album = $0
|
||||||
switch album.coverArt {
|
switch album.coverArt {
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import AppKit
|
||||||
import ReSwift
|
import ReSwift
|
||||||
|
|
||||||
func playerReducer(action: Action, state: PlayerState?) -> PlayerState {
|
func playerReducer(action: Action, state: PlayerState?) -> PlayerState {
|
||||||
@ -25,7 +25,13 @@ func playerReducer(action: Action, state: PlayerState?) -> PlayerState {
|
|||||||
AppDelegate.trackTimer.stop(elapsedTimeMs: state.elapsedTimeMs)
|
AppDelegate.trackTimer.stop(elapsedTimeMs: state.elapsedTimeMs)
|
||||||
}
|
}
|
||||||
|
|
||||||
case let action as UpdateCurrentSong:
|
DispatchQueue.main.async {
|
||||||
|
AppDelegate.store.dispatch(
|
||||||
|
UpdateQueuePlayerStateAction(state: state.state)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
case let action as UpdateCurrentSongAction:
|
||||||
state.currentSong = action.currentSong
|
state.currentSong = action.currentSong
|
||||||
|
|
||||||
if let currentSong = state.currentSong {
|
if let currentSong = state.currentSong {
|
||||||
@ -35,29 +41,29 @@ func playerReducer(action: Action, state: PlayerState?) -> PlayerState {
|
|||||||
.done() { image in
|
.done() { image in
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
if let image = image {
|
if let image = image {
|
||||||
AppDelegate.store.dispatch(UpdateCurrentCoverArt(coverArt: image))
|
AppDelegate.store.dispatch(UpdateCurrentCoverArtAction(coverArt: image))
|
||||||
} else {
|
} else {
|
||||||
AppDelegate.store.dispatch(UpdateCurrentCoverArt(coverArt: .defaultCoverArt))
|
AppDelegate.store.dispatch(UpdateCurrentCoverArtAction(coverArt: .defaultCoverArt))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.cauterize()
|
.cauterize()
|
||||||
} else {
|
} else {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
AppDelegate.store.dispatch(UpdateCurrentCoverArt(coverArt: .defaultCoverArt))
|
AppDelegate.store.dispatch(UpdateCurrentCoverArtAction(coverArt: .defaultCoverArt))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case let action as UpdateCurrentCoverArt:
|
case let action as UpdateCurrentCoverArtAction:
|
||||||
state.currentArtwork = action.coverArt
|
state.currentArtwork = action.coverArt
|
||||||
|
|
||||||
case let action as UpdateElapsedTimeAction:
|
case let action as UpdateElapsedTimeAction:
|
||||||
state.elapsedTimeMs = action.elapsedTimeMs
|
state.elapsedTimeMs = action.elapsedTimeMs
|
||||||
|
|
||||||
case is StartedDatabaseUpdate:
|
case is StartedDatabaseUpdateAction:
|
||||||
state.databaseUpdating = true
|
state.databaseUpdating = true
|
||||||
|
|
||||||
case is FinishedDatabaseUpdate:
|
case is FinishedDatabaseUpdateAction:
|
||||||
state.databaseUpdating = false
|
state.databaseUpdating = false
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import AppKit
|
||||||
import ReSwift
|
import ReSwift
|
||||||
|
|
||||||
func queueReducer(action: Action, state: QueueState?) -> QueueState {
|
func queueReducer(action: Action, state: QueueState?) -> QueueState {
|
||||||
@ -40,10 +40,13 @@ func queueReducer(action: Action, state: QueueState?) -> QueueState {
|
|||||||
|
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
AppDelegate.store.dispatch(
|
AppDelegate.store.dispatch(
|
||||||
UpdateCurrentSong(currentSong: state.queue[newSongRowPos].song)
|
UpdateCurrentSongAction(currentSong: state.queue[newSongRowPos].song)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case let action as UpdateQueuePlayerStateAction:
|
||||||
|
state.state = action.state
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import AppKit
|
||||||
|
|
||||||
class AlbumItemView: NSView {
|
class AlbumItemView: NSView {
|
||||||
var trackingArea: NSTrackingArea?
|
var trackingArea: NSTrackingArea?
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import AppKit
|
||||||
import ReSwift
|
import ReSwift
|
||||||
|
|
||||||
class CurrentCoverArtView: NSImageView {
|
class CurrentCoverArtView: NSImageView {
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2019 Dan Barber. All rights reserved.
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Cocoa
|
import AppKit
|
||||||
|
|
||||||
class MainWindow: NSWindow {
|
class MainWindow: NSWindow {
|
||||||
override func keyDown(with event: NSEvent) {
|
override func keyDown(with event: NSEvent) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user