From 9f948df141fe70bc6eb2a188c463ec1a315330c2 Mon Sep 17 00:00:00 2001 From: Daniel Barber Date: Mon, 13 Jan 2020 21:59:06 -0500 Subject: [PATCH] Use the search query UI state --- Persephone/Components/Window/WindowController.swift | 3 +-- Persephone/State/Reducers/UIReducer.swift | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Persephone/Components/Window/WindowController.swift b/Persephone/Components/Window/WindowController.swift index 1d6f050..f77e094 100644 --- a/Persephone/Components/Window/WindowController.swift +++ b/Persephone/Components/Window/WindowController.swift @@ -163,8 +163,7 @@ class WindowController: NSWindowController { } @IBAction func handleSearchQuery(_ sender: NSSearchField) { - //App.store.dispatch(SetSearchQuery(searchQuery: sender.stringValue)) - App.mpdClient.fetchAlbums(filter: sender.stringValue) + App.store.dispatch(SetSearchQuery(searchQuery: sender.stringValue)) } } diff --git a/Persephone/State/Reducers/UIReducer.swift b/Persephone/State/Reducers/UIReducer.swift index 1ce0e33..b788e14 100644 --- a/Persephone/State/Reducers/UIReducer.swift +++ b/Persephone/State/Reducers/UIReducer.swift @@ -6,6 +6,7 @@ // Copyright © 2019 Dan Barber. All rights reserved. // +import AppKit import ReSwift func uiReducer(action: Action, state: UIState?) -> UIState { @@ -35,6 +36,9 @@ func uiReducer(action: Action, state: UIState?) -> UIState { case let action as SetSearchQuery: state.searchQuery = action.searchQuery + DispatchQueue.main.async { + App.mpdClient.fetchAlbums(filter: state.searchQuery) + } default: break