feat: Update the api crate
This commit is contained in:
@@ -201,7 +201,7 @@ fn update(state: &mut State, message: Message) -> Task<Message> {
|
||||
|
||||
Task::perform(
|
||||
async move {
|
||||
let mut client = api::JellyfinClient::new(config);
|
||||
let mut client = api::JellyfinClient::new_with_config(config);
|
||||
client.authenticate().await
|
||||
},
|
||||
|result| match result {
|
||||
@@ -662,23 +662,21 @@ fn card(item: &Item) -> Element<'_, Message> {
|
||||
|
||||
// fn video(url: &str
|
||||
|
||||
fn init(config: impl Fn() -> api::JellyfinConfig + 'static) -> impl Fn() -> (State, Task<Message>) {
|
||||
move || {
|
||||
let mut jellyfin = api::JellyfinClient::new(config());
|
||||
(
|
||||
State::new(jellyfin.clone()),
|
||||
Task::perform(
|
||||
async move { jellyfin.authenticate_with_cached_token(".session").await },
|
||||
|token| match token {
|
||||
Ok(token) => Message::SetToken(token),
|
||||
Err(e) => Message::Error(format!("Authentication failed: {}", e)),
|
||||
},
|
||||
)
|
||||
.chain(Task::done(Message::Refresh)),
|
||||
fn init() -> (State, Task<Message>) {
|
||||
let mut jellyfin = api::JellyfinClient::new_with_config();
|
||||
(
|
||||
State::new(jellyfin.clone()),
|
||||
Task::perform(
|
||||
async move { jellyfin.authenticate_with_cached_token(".session").await },
|
||||
|token| match token {
|
||||
Ok(token) => Message::SetToken(token),
|
||||
Err(e) => Message::Error(format!("Authentication failed: {}", e)),
|
||||
},
|
||||
)
|
||||
}
|
||||
.chain(Task::done(Message::Refresh)),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn ui(config: impl Fn() -> api::JellyfinConfig + 'static) -> iced::Result {
|
||||
iced::application(init(config), update, view).run()
|
||||
pub fn ui() -> iced::Result {
|
||||
iced::application(init, update, view).run()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user