Merge pull request #78 from PangMo5/PangMo5/binding-side-effect
Remove @Published used for input(keyboard) binding (side effect)
This commit is contained in:
commit
31ba7a07d8
|
@ -10,14 +10,17 @@ import SwiftUI
|
||||||
|
|
||||||
struct ConnectToServerView: View {
|
struct ConnectToServerView: View {
|
||||||
@StateObject var viewModel = ConnectToServerViewModel()
|
@StateObject var viewModel = ConnectToServerViewModel()
|
||||||
|
@State var username = ""
|
||||||
|
@State var password = ""
|
||||||
|
@State var uri = ""
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
if viewModel.isConnectedServer {
|
if viewModel.isConnectedServer {
|
||||||
if viewModel.publicUsers.isEmpty {
|
if viewModel.publicUsers.isEmpty {
|
||||||
Section(header: Text(viewModel.lastPublicUsers.isEmpty || viewModel.username == "" ? "Login to \(ServerEnvironment.current.server.name ?? "")": "")) {
|
Section(header: Text(viewModel.lastPublicUsers.isEmpty || username == "" ? "Login to \(ServerEnvironment.current.server.name ?? "")": "")) {
|
||||||
if viewModel.lastPublicUsers.isEmpty || viewModel.username == "" {
|
if viewModel.lastPublicUsers.isEmpty || username == "" {
|
||||||
TextField("Username", text: $viewModel.username)
|
TextField("Username", text: $username)
|
||||||
.disableAutocorrection(true)
|
.disableAutocorrection(true)
|
||||||
.autocapitalization(.none)
|
.autocapitalization(.none)
|
||||||
} else {
|
} else {
|
||||||
|
@ -30,7 +33,7 @@ struct ConnectToServerView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SecureField("Password (optional)", text: $viewModel.password)
|
SecureField("Password (optional)", text: $password)
|
||||||
.disableAutocorrection(true)
|
.disableAutocorrection(true)
|
||||||
.autocapitalization(.none)
|
.autocapitalization(.none)
|
||||||
}
|
}
|
||||||
|
@ -39,7 +42,7 @@ struct ConnectToServerView: View {
|
||||||
HStack {
|
HStack {
|
||||||
Button {
|
Button {
|
||||||
if !viewModel.lastPublicUsers.isEmpty {
|
if !viewModel.lastPublicUsers.isEmpty {
|
||||||
viewModel.username = ""
|
username = ""
|
||||||
viewModel.showPublicUsers()
|
viewModel.showPublicUsers()
|
||||||
} else {
|
} else {
|
||||||
viewModel.isConnectedServer = false
|
viewModel.isConnectedServer = false
|
||||||
|
@ -62,7 +65,7 @@ struct ConnectToServerView: View {
|
||||||
Text("Login")
|
Text("Login")
|
||||||
}
|
}
|
||||||
Spacer()
|
Spacer()
|
||||||
}.disabled(viewModel.isLoading || viewModel.username.isEmpty)
|
}.disabled(viewModel.isLoading || username.isEmpty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -74,11 +77,11 @@ struct ConnectToServerView: View {
|
||||||
let user = SessionManager.current.getSavedSession(userID: publicUser.id!)
|
let user = SessionManager.current.getSavedSession(userID: publicUser.id!)
|
||||||
SessionManager.current.loginWithSavedSession(user: user)
|
SessionManager.current.loginWithSavedSession(user: user)
|
||||||
} else {
|
} else {
|
||||||
viewModel.username = publicUser.name ?? ""
|
username = publicUser.name ?? ""
|
||||||
viewModel.selectedPublicUser = publicUser
|
viewModel.selectedPublicUser = publicUser
|
||||||
viewModel.hidePublicUsers()
|
viewModel.hidePublicUsers()
|
||||||
if !(publicUser.hasPassword ?? true) {
|
if !(publicUser.hasPassword ?? true) {
|
||||||
viewModel.password = ""
|
password = ""
|
||||||
viewModel.login()
|
viewModel.login()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,7 +95,7 @@ struct ConnectToServerView: View {
|
||||||
Spacer()
|
Spacer()
|
||||||
Button {
|
Button {
|
||||||
viewModel.hidePublicUsers()
|
viewModel.hidePublicUsers()
|
||||||
viewModel.username = ""
|
username = ""
|
||||||
} label: {
|
} label: {
|
||||||
Text("Other User").font(.headline).fontWeight(.semibold)
|
Text("Other User").font(.headline).fontWeight(.semibold)
|
||||||
}
|
}
|
||||||
|
@ -103,7 +106,7 @@ struct ConnectToServerView: View {
|
||||||
} else {
|
} else {
|
||||||
Form {
|
Form {
|
||||||
Section(header: Text("Server Information")) {
|
Section(header: Text("Server Information")) {
|
||||||
TextField("Jellyfin Server URL", text: $viewModel.uri)
|
TextField("Jellyfin Server URL", text: $uri)
|
||||||
.disableAutocorrection(true)
|
.disableAutocorrection(true)
|
||||||
.autocapitalization(.none)
|
.autocapitalization(.none)
|
||||||
Button {
|
Button {
|
||||||
|
@ -117,7 +120,7 @@ struct ConnectToServerView: View {
|
||||||
ProgressView()
|
ProgressView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.disabled(viewModel.isLoading || viewModel.uri.isEmpty)
|
.disabled(viewModel.isLoading || uri.isEmpty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,6 +130,15 @@ struct ConnectToServerView: View {
|
||||||
.alert(item: $viewModel.errorMessage) { _ in
|
.alert(item: $viewModel.errorMessage) { _ in
|
||||||
Alert(title: Text("Error"), message: Text(viewModel.errorMessage ?? ""), dismissButton: .default(Text("Ok")))
|
Alert(title: Text("Error"), message: Text(viewModel.errorMessage ?? ""), dismissButton: .default(Text("Ok")))
|
||||||
}
|
}
|
||||||
|
.onChange(of: uri) { uri in
|
||||||
|
viewModel.uriSubject.send(uri)
|
||||||
|
}
|
||||||
|
.onChange(of: username) { username in
|
||||||
|
viewModel.usernameSubject.send(username)
|
||||||
|
}
|
||||||
|
.onChange(of: password) { password in
|
||||||
|
viewModel.passwordSubject.send(password)
|
||||||
|
}
|
||||||
.navigationTitle(viewModel.isConnectedServer ? "Who's watching?" : "Connect to Jellyfin")
|
.navigationTitle(viewModel.isConnectedServer ? "Who's watching?" : "Connect to Jellyfin")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,7 @@ import Combine
|
||||||
|
|
||||||
struct LatestMediaView: View {
|
struct LatestMediaView: View {
|
||||||
|
|
||||||
@StateObject
|
@StateObject var tempViewModel = ViewModel()
|
||||||
var tempViewModel = ViewModel()
|
|
||||||
@State var items: [BaseItemDto] = []
|
@State var items: [BaseItemDto] = []
|
||||||
private var library_id: String = ""
|
private var library_id: String = ""
|
||||||
@State private var viewDidLoad: Bool = false
|
@State private var viewDidLoad: Bool = false
|
||||||
|
|
|
@ -12,6 +12,9 @@ import SwiftUI
|
||||||
|
|
||||||
struct ConnectToServerView: View {
|
struct ConnectToServerView: View {
|
||||||
@StateObject var viewModel = ConnectToServerViewModel()
|
@StateObject var viewModel = ConnectToServerViewModel()
|
||||||
|
@State var username = ""
|
||||||
|
@State var password = ""
|
||||||
|
@State var uri = ""
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
|
@ -19,10 +22,10 @@ struct ConnectToServerView: View {
|
||||||
if viewModel.isConnectedServer {
|
if viewModel.isConnectedServer {
|
||||||
if viewModel.publicUsers.isEmpty {
|
if viewModel.publicUsers.isEmpty {
|
||||||
Section(header: Text("Login to \(ServerEnvironment.current.server.name ?? "")")) {
|
Section(header: Text("Login to \(ServerEnvironment.current.server.name ?? "")")) {
|
||||||
TextField("Username", text: $viewModel.username)
|
TextField("Username", text: $username)
|
||||||
.disableAutocorrection(true)
|
.disableAutocorrection(true)
|
||||||
.autocapitalization(.none)
|
.autocapitalization(.none)
|
||||||
SecureField("Password", text: $viewModel.password)
|
SecureField("Password", text: $password)
|
||||||
.disableAutocorrection(true)
|
.disableAutocorrection(true)
|
||||||
.autocapitalization(.none)
|
.autocapitalization(.none)
|
||||||
Button {
|
Button {
|
||||||
|
@ -35,7 +38,7 @@ struct ConnectToServerView: View {
|
||||||
ProgressView()
|
ProgressView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.disabled(viewModel.isLoading || viewModel.username.isEmpty)
|
}.disabled(viewModel.isLoading || username.isEmpty)
|
||||||
}
|
}
|
||||||
|
|
||||||
Section {
|
Section {
|
||||||
|
@ -56,10 +59,10 @@ struct ConnectToServerView: View {
|
||||||
ForEach(viewModel.publicUsers, id: \.id) { publicUser in
|
ForEach(viewModel.publicUsers, id: \.id) { publicUser in
|
||||||
HStack {
|
HStack {
|
||||||
Button(action: {
|
Button(action: {
|
||||||
viewModel.username = publicUser.name ?? ""
|
username = publicUser.name ?? ""
|
||||||
viewModel.publicUsers.removeAll()
|
viewModel.publicUsers.removeAll()
|
||||||
if !(publicUser.hasPassword ?? true) {
|
if !(publicUser.hasPassword ?? true) {
|
||||||
viewModel.password = ""
|
password = ""
|
||||||
viewModel.login()
|
viewModel.login()
|
||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
|
@ -88,7 +91,7 @@ struct ConnectToServerView: View {
|
||||||
Section {
|
Section {
|
||||||
Button {
|
Button {
|
||||||
viewModel.publicUsers.removeAll()
|
viewModel.publicUsers.removeAll()
|
||||||
viewModel.username = ""
|
username = ""
|
||||||
} label: {
|
} label: {
|
||||||
HStack {
|
HStack {
|
||||||
Text("Other User").font(.subheadline).fontWeight(.semibold)
|
Text("Other User").font(.subheadline).fontWeight(.semibold)
|
||||||
|
@ -106,7 +109,7 @@ struct ConnectToServerView: View {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Section(header: Text("Server Information")) {
|
Section(header: Text("Server Information")) {
|
||||||
TextField("Jellyfin Server URL", text: $viewModel.uri)
|
TextField("Jellyfin Server URL", text: $uri)
|
||||||
.disableAutocorrection(true)
|
.disableAutocorrection(true)
|
||||||
.autocapitalization(.none)
|
.autocapitalization(.none)
|
||||||
Button {
|
Button {
|
||||||
|
@ -120,11 +123,20 @@ struct ConnectToServerView: View {
|
||||||
ProgressView()
|
ProgressView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.disabled(viewModel.isLoading || viewModel.uri.isEmpty)
|
.disabled(viewModel.isLoading || uri.isEmpty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.onChange(of: uri) { uri in
|
||||||
|
viewModel.uriSubject.send(uri)
|
||||||
|
}
|
||||||
|
.onChange(of: username) { username in
|
||||||
|
viewModel.usernameSubject.send(username)
|
||||||
|
}
|
||||||
|
.onChange(of: password) { password in
|
||||||
|
viewModel.passwordSubject.send(password)
|
||||||
|
}
|
||||||
.alert(item: $viewModel.errorMessage) { _ in
|
.alert(item: $viewModel.errorMessage) { _ in
|
||||||
Alert(title: Text("Error"), message: Text("message"), dismissButton: .default(Text("Try again")))
|
Alert(title: Text("Error"), message: Text("message"), dismissButton: .default(Text("Try again")))
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,7 @@ import JellyfinAPI
|
||||||
import Combine
|
import Combine
|
||||||
|
|
||||||
struct EpisodeItemView: View {
|
struct EpisodeItemView: View {
|
||||||
@StateObject
|
@StateObject var viewModel: EpisodeItemViewModel
|
||||||
var viewModel: EpisodeItemViewModel
|
|
||||||
@State private var orientation = UIDeviceOrientation.unknown
|
@State private var orientation = UIDeviceOrientation.unknown
|
||||||
@Environment(\.horizontalSizeClass) var hSizeClass
|
@Environment(\.horizontalSizeClass) var hSizeClass
|
||||||
@Environment(\.verticalSizeClass) var vSizeClass
|
@Environment(\.verticalSizeClass) var vSizeClass
|
||||||
|
|
|
@ -11,16 +11,11 @@ import Foundation
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct HomeView: View {
|
struct HomeView: View {
|
||||||
@StateObject
|
@StateObject var viewModel = HomeViewModel()
|
||||||
var viewModel = HomeViewModel()
|
@State private var orientation = UIDevice.current.orientation
|
||||||
@State
|
@Environment(\.horizontalSizeClass) var hSizeClass
|
||||||
private var orientation = UIDevice.current.orientation
|
@Environment(\.verticalSizeClass) var vSizeClass
|
||||||
@Environment(\.horizontalSizeClass)
|
@State var showingSettings = false
|
||||||
var hSizeClass
|
|
||||||
@Environment(\.verticalSizeClass)
|
|
||||||
var vSizeClass
|
|
||||||
@State
|
|
||||||
var showingSettings = false
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
|
|
|
@ -10,8 +10,7 @@ import JellyfinAPI
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct LatestMediaView: View {
|
struct LatestMediaView: View {
|
||||||
@StateObject
|
@StateObject var viewModel: LatestMediaViewModel
|
||||||
var viewModel: LatestMediaViewModel
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ScrollView(.horizontal, showsIndicators: false) {
|
ScrollView(.horizontal, showsIndicators: false) {
|
||||||
|
|
|
@ -9,13 +9,10 @@ import JellyfinAPI
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct LibraryFilterView: View {
|
struct LibraryFilterView: View {
|
||||||
@Environment(\.presentationMode)
|
@Environment(\.presentationMode) var presentationMode
|
||||||
var presentationMode
|
@Binding var filters: LibraryFilters
|
||||||
@Binding
|
|
||||||
var filters: LibraryFilters
|
|
||||||
|
|
||||||
@StateObject
|
@StateObject var viewModel: LibraryFilterViewModel
|
||||||
var viewModel: LibraryFilterViewModel
|
|
||||||
|
|
||||||
init(filters: Binding<LibraryFilters>, enabledFilterType: [FilterType]) {
|
init(filters: Binding<LibraryFilters>, enabledFilterType: [FilterType]) {
|
||||||
_filters = filters
|
_filters = filters
|
||||||
|
|
|
@ -9,8 +9,7 @@ import Foundation
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct LibraryListView: View {
|
struct LibraryListView: View {
|
||||||
@StateObject
|
@StateObject var viewModel = LibraryListViewModel()
|
||||||
var viewModel = LibraryListViewModel()
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
List(viewModel.libraries, id: \.self) { library in
|
List(viewModel.libraries, id: \.self) { library in
|
||||||
|
|
|
@ -10,13 +10,11 @@ import JellyfinAPI
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct LibrarySearchView: View {
|
struct LibrarySearchView: View {
|
||||||
@StateObject
|
@StateObject var viewModel: LibrarySearchViewModel
|
||||||
var viewModel: LibrarySearchViewModel
|
@State var searchQuery = ""
|
||||||
|
|
||||||
// MARK: tracks for grid
|
// MARK: tracks for grid
|
||||||
|
|
||||||
@State
|
@State private var tracks: [GridItem] = Array(repeating: .init(.flexible()), count: Int(UIScreen.main.bounds.size.width) / 125)
|
||||||
private var tracks: [GridItem] = Array(repeating: .init(.flexible()), count: Int(UIScreen.main.bounds.size.width) / 125)
|
|
||||||
|
|
||||||
func recalcTracks() {
|
func recalcTracks() {
|
||||||
tracks = Array(repeating: .init(.flexible()), count: Int(UIScreen.main.bounds.size.width) / 125)
|
tracks = Array(repeating: .init(.flexible()), count: Int(UIScreen.main.bounds.size.width) / 125)
|
||||||
|
@ -25,7 +23,7 @@ struct LibrarySearchView: View {
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
VStack {
|
||||||
Spacer().frame(height: 6)
|
Spacer().frame(height: 6)
|
||||||
SearchBar(text: $viewModel.searchQuery)
|
SearchBar(text: $searchQuery)
|
||||||
ZStack {
|
ZStack {
|
||||||
ScrollView(.vertical) {
|
ScrollView(.vertical) {
|
||||||
if !viewModel.items.isEmpty {
|
if !viewModel.items.isEmpty {
|
||||||
|
@ -67,6 +65,9 @@ struct LibrarySearchView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.onChange(of: searchQuery) { query in
|
||||||
|
viewModel.searchQuerySubject.send(query)
|
||||||
|
}
|
||||||
.navigationBarTitle("Search", displayMode: .inline)
|
.navigationBarTitle("Search", displayMode: .inline)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,19 +12,15 @@ import NukeUI
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct LibraryView: View {
|
struct LibraryView: View {
|
||||||
@StateObject
|
@StateObject var viewModel: LibraryViewModel
|
||||||
var viewModel: LibraryViewModel
|
|
||||||
var title: String
|
var title: String
|
||||||
|
|
||||||
// MARK: tracks for grid
|
// MARK: tracks for grid
|
||||||
|
|
||||||
@State
|
@State var isShowingSearchView = false
|
||||||
var isShowingSearchView = false
|
@State var isShowingFilterView = false
|
||||||
@State
|
|
||||||
var isShowingFilterView = false
|
|
||||||
|
|
||||||
@State
|
@State private var tracks: [GridItem] = Array(repeating: .init(.flexible()), count: Int(UIScreen.main.bounds.size.width) / 125)
|
||||||
private var tracks: [GridItem] = Array(repeating: .init(.flexible()), count: Int(UIScreen.main.bounds.size.width) / 125)
|
|
||||||
|
|
||||||
func recalcTracks() {
|
func recalcTracks() {
|
||||||
tracks = Array(repeating: .init(.flexible()), count: Int(UIScreen.main.bounds.size.width) / 125)
|
tracks = Array(repeating: .init(.flexible()), count: Int(UIScreen.main.bounds.size.width) / 125)
|
||||||
|
|
|
@ -10,10 +10,8 @@ import JellyfinAPI
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct MovieItemView: View {
|
struct MovieItemView: View {
|
||||||
@StateObject
|
@StateObject var viewModel: MovieItemViewModel
|
||||||
var viewModel: MovieItemViewModel
|
@State private var orientation = UIDeviceOrientation.unknown
|
||||||
@State
|
|
||||||
private var orientation = UIDeviceOrientation.unknown
|
|
||||||
@Environment(\.horizontalSizeClass)
|
@Environment(\.horizontalSizeClass)
|
||||||
var hSizeClass
|
var hSizeClass
|
||||||
@Environment(\.verticalSizeClass)
|
@Environment(\.verticalSizeClass)
|
||||||
|
|
|
@ -10,8 +10,7 @@ import Combine
|
||||||
import JellyfinAPI
|
import JellyfinAPI
|
||||||
|
|
||||||
struct SeasonItemView: View {
|
struct SeasonItemView: View {
|
||||||
@StateObject
|
@StateObject var viewModel: SeasonItemViewModel
|
||||||
var viewModel: SeasonItemViewModel
|
|
||||||
@State private var orientation = UIDeviceOrientation.unknown
|
@State private var orientation = UIDeviceOrientation.unknown
|
||||||
@Environment(\.horizontalSizeClass) var hSizeClass
|
@Environment(\.horizontalSizeClass) var hSizeClass
|
||||||
@Environment(\.verticalSizeClass) var vSizeClass
|
@Environment(\.verticalSizeClass) var vSizeClass
|
||||||
|
|
|
@ -10,11 +10,9 @@ import JellyfinAPI
|
||||||
import Combine
|
import Combine
|
||||||
|
|
||||||
struct SeriesItemView: View {
|
struct SeriesItemView: View {
|
||||||
@StateObject
|
@StateObject var viewModel: SeriesItemViewModel
|
||||||
var viewModel: SeriesItemViewModel
|
|
||||||
|
|
||||||
@State
|
@State private var tracks: [GridItem] = Array(repeating: .init(.flexible()), count: Int(UIScreen.main.bounds.size.width) / 125)
|
||||||
private var tracks: [GridItem] = Array(repeating: .init(.flexible()), count: Int(UIScreen.main.bounds.size.width) / 125)
|
|
||||||
|
|
||||||
func recalcTracks() {
|
func recalcTracks() {
|
||||||
tracks = Array(repeating: .init(.flexible()), count: Int(UIScreen.main.bounds.size.width) / 125)
|
tracks = Array(repeating: .init(.flexible()), count: Int(UIScreen.main.bounds.size.width) / 125)
|
||||||
|
|
|
@ -14,12 +14,10 @@ import JellyfinAPI
|
||||||
final class ConnectToServerViewModel: ViewModel {
|
final class ConnectToServerViewModel: ViewModel {
|
||||||
@Published
|
@Published
|
||||||
var isConnectedServer = false
|
var isConnectedServer = false
|
||||||
@Published
|
|
||||||
var uri = ""
|
var uriSubject = CurrentValueSubject<String, Never>("")
|
||||||
@Published
|
var usernameSubject = CurrentValueSubject<String, Never>("")
|
||||||
var username = ""
|
var passwordSubject = CurrentValueSubject<String, Never>("")
|
||||||
@Published
|
|
||||||
var password = ""
|
|
||||||
|
|
||||||
@Published
|
@Published
|
||||||
var lastPublicUsers = [UserDto]()
|
var lastPublicUsers = [UserDto]()
|
||||||
|
@ -57,7 +55,7 @@ final class ConnectToServerViewModel: ViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
func connectToServer() {
|
func connectToServer() {
|
||||||
ServerEnvironment.current.create(with: uri)
|
ServerEnvironment.current.create(with: uriSubject.value)
|
||||||
.sink(receiveCompletion: { result in
|
.sink(receiveCompletion: { result in
|
||||||
switch result {
|
switch result {
|
||||||
case let .failure(error):
|
case let .failure(error):
|
||||||
|
@ -72,7 +70,7 @@ final class ConnectToServerViewModel: ViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
func login() {
|
func login() {
|
||||||
SessionManager.current.login(username: username, password: password)
|
SessionManager.current.login(username: usernameSubject.value, password: passwordSubject.value)
|
||||||
.sink(receiveCompletion: { completion in
|
.sink(receiveCompletion: { completion in
|
||||||
self.handleAPIRequestCompletion(completion: completion)
|
self.handleAPIRequestCompletion(completion: completion)
|
||||||
}, receiveValue: { _ in
|
}, receiveValue: { _ in
|
||||||
|
|
|
@ -15,15 +15,14 @@ final class LibrarySearchViewModel: ViewModel {
|
||||||
@Published
|
@Published
|
||||||
var items = [BaseItemDto]()
|
var items = [BaseItemDto]()
|
||||||
|
|
||||||
@Published
|
var searchQuerySubject = CurrentValueSubject<String, Never>("")
|
||||||
var searchQuery = ""
|
|
||||||
var parentID: String?
|
var parentID: String?
|
||||||
|
|
||||||
init(parentID: String?) {
|
init(parentID: String?) {
|
||||||
self.parentID = parentID
|
self.parentID = parentID
|
||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
$searchQuery
|
searchQuerySubject
|
||||||
.debounce(for: 0.25, scheduler: DispatchQueue.main)
|
.debounce(for: 0.25, scheduler: DispatchQueue.main)
|
||||||
.sink(receiveValue: search(with:))
|
.sink(receiveValue: search(with:))
|
||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
|
|
Loading…
Reference in New Issue