Convert main from async to sync again

* Make entry point synchronous and switch to global runtime instead.

* Switch all futures::block_on() to global runtime.

* Fix formatting.
This commit is contained in:
Thomas
2022-12-11 19:09:22 +01:00
committed by GitHub
parent 7751afafd2
commit ccce78af66
3 changed files with 25 additions and 20 deletions

View File

@@ -7,6 +7,7 @@ use crate::model::playlist::Playlist;
use crate::model::track::Track;
use crate::spotify_worker::WorkerCommand;
use crate::ui::pagination::{ApiPage, ApiResult};
use crate::ASYNC_RUNTIME;
use chrono::{DateTime, Duration as ChronoDuration, Utc};
use futures::channel::oneshot;
use log::{debug, error, info};
@@ -78,7 +79,7 @@ impl WebApi {
.as_ref()
{
channel.send(cmd).expect("can't send message to worker");
let token_option = futures::executor::block_on(token_rx).unwrap();
let token_option = ASYNC_RUNTIME.block_on(token_rx).unwrap();
if let Some(token) = token_option {
*self.api.token.lock().expect("can't writelock api token") = Some(Token {
access_token: token.access_token,