MCPcopy Create free account
hub / github.com/Moosync/Moosync / get_api_client

Method get_api_client

src-tauri/src/providers/spotify.rs:194–217  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

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<()> {

Callers 8

fetch_user_playlistsMethod · 0.45
get_playlist_contentMethod · 0.45
searchMethod · 0.45
playlist_from_urlMethod · 0.45
song_from_urlMethod · 0.45
get_suggestionsMethod · 0.45
get_album_contentMethod · 0.45
get_artist_contentMethod · 0.45

Calls 1

refresh_loginMethod · 0.45

Tested by

no test coverage detected