1
1
mirror of https://github.com/danbee/persephone synced 2025-03-04 08:39:11 +00:00
persephone/Shared/State/Reducers/PreferencesReducer.swift
2020-11-07 23:33:36 +01:00

38 lines
817 B
Swift

//
// PreferencesReducer.swift
// Persephone
//
// Created by Daniel Barber on 2019/4/28.
// Copyright © 2019 Dan Barber. All rights reserved.
//
import Foundation
import ReSwift
func preferencesReducer(action: Action, state: PreferencesState?) -> PreferencesState {
var state = state ?? PreferencesState()
switch action {
case let action as UpdateServerHost:
state.mpdServer.host = action.host
case let action as UpdateServerPort:
state.mpdServer.port = action.port
case let action as UpdateCustomArtworkURLToggle:
state.fetchArtworkFromCustomURL = action.useCustomArtworkURL
case let action as UpdateCustomArtworkURL:
state.customArtworkURL = URL(string: action.customArtworkURL)
case is SavePreferences:
state.save()
default:
break
}
return state
}