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") }
|
||||
/// No overview available
|
||||
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.
|
||||
internal static var noResults: String { return L10n.tr("Localizable", "noResults") }
|
||||
/// Normal
|
||||
|
|
|
@ -17,6 +17,9 @@ final class UserSignInViewModel: ViewModel {
|
|||
var router: UserSignInCoordinator.Router?
|
||||
let server: SwiftfinStore.State.Server
|
||||
|
||||
@Published
|
||||
var isLoadingUsers = false
|
||||
|
||||
@Published
|
||||
var publicUsers: [UserDto] = []
|
||||
|
||||
|
@ -54,12 +57,14 @@ final class UserSignInViewModel: ViewModel {
|
|||
}
|
||||
|
||||
func loadUsers() {
|
||||
self.isLoadingUsers = true
|
||||
JellyfinAPIAPI.basePath = server.currentURI
|
||||
UserAPI.getPublicUsers()
|
||||
.sink(receiveCompletion: { completion in
|
||||
self.handleAPIRequestError(displayMessage: L10n.unableToConnectServer, completion: completion)
|
||||
}, receiveValue: { response in
|
||||
self.publicUsers = response
|
||||
self.isLoadingUsers = false
|
||||
})
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
|
|
@ -47,12 +47,31 @@ struct UserSignInView: View {
|
|||
L10n.signInToServer(viewModel.server.name).text
|
||||
}
|
||||
|
||||
if !viewModel.publicUsers.isEmpty {
|
||||
Section(header: L10n.publicUsers.text) {
|
||||
Section {
|
||||
if !viewModel.publicUsers.isEmpty {
|
||||
ForEach(viewModel.publicUsers, id: \.id) { user in
|
||||
UserLoginCellView(viewModel: viewModel, user: user)
|
||||
.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