(&self)
| 192 | } |
| 193 | |
| 194 | async fn get_api_client(&self) -> RwLockReadGuard<'_, Option<ApiClient>> { |
| 195 | if let Some(expired) = self |
| 196 | .api_client |
| 197 | .read() |
| 198 | .await |
| 199 | .as_ref() |
| 200 | .map(|api_client| api_client.token_expiry <= Instant::now()) |
| 201 | { |
| 202 | if expired { |
| 203 | tracing::info!( |
| 204 | "spotify token expired. refreshing {:?}", |
| 205 | self.api_client |
| 206 | .read() |
| 207 | .await |
| 208 | .as_ref() |
| 209 | .map(|api_client| api_client.token_expiry) |
| 210 | ); |
| 211 | |
| 212 | let _ = self.refresh_login().await; |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | self.api_client.read().await |
| 217 | } |
| 218 | |
| 219 | #[tracing::instrument(level = "debug", skip(self))] |
| 220 | async fn refresh_login(&self) -> Result<()> { |
no test coverage detected