diff --git a/src/spotify_api.rs b/src/spotify_api.rs
index 6d0042a..9c306f7 100644
--- a/src/spotify_api.rs
+++ b/src/spotify_api.rs
@@ -1,4 +1,3 @@
-use crate::application::ASYNC_RUNTIME;
use crate::model::album::Album;
use crate::model::artist::Artist;
use crate::model::category::Category;
@@ -9,7 +8,6 @@ use crate::model::track::Track;
use crate::spotify_worker::WorkerCommand;
use crate::ui::pagination::{ApiPage, ApiResult};
use chrono::{DateTime, Duration as ChronoDuration, Utc};
-use futures::channel::oneshot;
use log::{debug, error, info};
use rspotify::http::HttpError;
@@ -71,6 +69,7 @@ impl WebApi {
self.worker_channel = channel;
}
+ /// Update the authentication token when it expires.
pub fn update_token(&self) {
{
let token_expiration = self.token_expiration.read().unwrap();
@@ -85,7 +84,7 @@ impl WebApi {
info!("Token will expire in {}, renewing", delta);
}
- let (token_tx, token_rx) = oneshot::channel();
+ let (token_tx, token_rx) = std::sync::mpsc::channel();
let cmd = WorkerCommand::RequestToken(token_tx);
if let Some(channel) = self
.worker_channel
@@ -94,7 +93,7 @@ impl WebApi {
.as_ref()
{
channel.send(cmd).expect("can't send message to worker");
- let token_option = ASYNC_RUNTIME.get().unwrap().block_on(token_rx).unwrap();
+ let token_option = token_rx.recv().unwrap();
if let Some(token) = token_option {
*self.api.token.lock().expect("can't writelock api token") = Some(Token {
access_token: token.access_token,
diff --git a/src/spotify_worker.rs b/src/spotify_worker.rs
index 62ce781..ff92074 100644
--- a/src/spotify_worker.rs
+++ b/src/spotify_worker.rs
@@ -3,7 +3,6 @@ use crate::events::{Event, EventManager};
use crate::model::playable::Playable;
use crate::queue::QueueEvent;
use crate::spotify::PlayerEvent;
-use futures::channel::oneshot;
use futures::{Future, FutureExt};
use librespot_core::keymaster::Token;
use librespot_core::session::Session;
@@ -11,6 +10,7 @@ use librespot_core::spotify_id::{SpotifyAudioType, SpotifyId};
use librespot_playback::mixer::Mixer;
use librespot_playback::player::{Player, PlayerEvent as LibrespotPlayerEvent};
use log::{debug, error, info, warn};
+use std::sync::mpsc::Sender;
use std::time::Duration;
use std::{pin::Pin, time::SystemTime};
use tokio::sync::mpsc;
@@ -26,7 +26,7 @@ pub(crate) enum WorkerCommand {
Stop,
Seek(u32),
SetVolume(u16),
- RequestToken(oneshot::Sender