feat: Update the api crate

This commit is contained in:
uttarayan21
2025-11-25 18:48:13 +05:30
parent 77fe7b6bb4
commit ca1fd2e977
9 changed files with 229 additions and 260 deletions

View File

@@ -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()
}