Allow reloading of public users
This commit is contained in:
parent
51d30cf60a
commit
e2291955f9
|
@ -198,6 +198,8 @@ internal enum L10n {
|
||||||
internal static var `none`: String { return L10n.tr("Localizable", "none") }
|
internal static var `none`: String { return L10n.tr("Localizable", "none") }
|
||||||
/// No overview available
|
/// No overview available
|
||||||
internal static var noOverviewAvailable: String { return L10n.tr("Localizable", "noOverviewAvailable") }
|
internal static var noOverviewAvailable: String { return L10n.tr("Localizable", "noOverviewAvailable") }
|
||||||
|
/// No public users
|
||||||
|
internal static var noPublicUsers: String { return L10n.tr("Localizable", "noPublicUsers") }
|
||||||
/// No results.
|
/// No results.
|
||||||
internal static var noResults: String { return L10n.tr("Localizable", "noResults") }
|
internal static var noResults: String { return L10n.tr("Localizable", "noResults") }
|
||||||
/// Normal
|
/// Normal
|
||||||
|
|
|
@ -17,6 +17,9 @@ final class UserSignInViewModel: ViewModel {
|
||||||
var router: UserSignInCoordinator.Router?
|
var router: UserSignInCoordinator.Router?
|
||||||
let server: SwiftfinStore.State.Server
|
let server: SwiftfinStore.State.Server
|
||||||
|
|
||||||
|
@Published
|
||||||
|
var isLoadingUsers = false
|
||||||
|
|
||||||
@Published
|
@Published
|
||||||
var publicUsers: [UserDto] = []
|
var publicUsers: [UserDto] = []
|
||||||
|
|
||||||
|
@ -54,12 +57,14 @@ final class UserSignInViewModel: ViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadUsers() {
|
func loadUsers() {
|
||||||
|
self.isLoadingUsers = true
|
||||||
JellyfinAPIAPI.basePath = server.currentURI
|
JellyfinAPIAPI.basePath = server.currentURI
|
||||||
UserAPI.getPublicUsers()
|
UserAPI.getPublicUsers()
|
||||||
.sink(receiveCompletion: { completion in
|
.sink(receiveCompletion: { completion in
|
||||||
self.handleAPIRequestError(displayMessage: L10n.unableToConnectServer, completion: completion)
|
self.handleAPIRequestError(displayMessage: L10n.unableToConnectServer, completion: completion)
|
||||||
}, receiveValue: { response in
|
}, receiveValue: { response in
|
||||||
self.publicUsers = response
|
self.publicUsers = response
|
||||||
|
self.isLoadingUsers = false
|
||||||
})
|
})
|
||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,12 +47,31 @@ struct UserSignInView: View {
|
||||||
L10n.signInToServer(viewModel.server.name).text
|
L10n.signInToServer(viewModel.server.name).text
|
||||||
}
|
}
|
||||||
|
|
||||||
if !viewModel.publicUsers.isEmpty {
|
Section {
|
||||||
Section(header: L10n.publicUsers.text) {
|
if !viewModel.publicUsers.isEmpty {
|
||||||
ForEach(viewModel.publicUsers, id: \.id) { user in
|
ForEach(viewModel.publicUsers, id: \.id) { user in
|
||||||
UserLoginCellView(viewModel: viewModel, user: user)
|
UserLoginCellView(viewModel: viewModel, user: user)
|
||||||
.disabled(viewModel.isLoading)
|
.disabled(viewModel.isLoading)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
HStack(alignment: .center) {
|
||||||
|
Spacer()
|
||||||
|
L10n.noPublicUsers.text
|
||||||
|
.font(.callout)
|
||||||
|
.foregroundColor(.secondary)
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} header: {
|
||||||
|
HStack {
|
||||||
|
L10n.publicUsers.text
|
||||||
|
Spacer()
|
||||||
|
Button {
|
||||||
|
viewModel.loadUsers()
|
||||||
|
} label: {
|
||||||
|
Image(systemName: "arrow.clockwise.circle.fill")
|
||||||
|
}
|
||||||
|
.disabled(viewModel.isLoadingUsers || viewModel.isLoading)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue