Skip to content

Commit

Permalink
refactor: Remove unnecessary runBlocking Dispatchers.IO and only wrap…
Browse files Browse the repository at this point in the history
… code that require it
  • Loading branch information
LunarX committed Feb 19, 2025
1 parent a994d4b commit d9ee75c
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Infomaniak Core - Android
* Copyright (C) 2022-2024 Infomaniak Network SA
* Copyright (C) 2022-2025 Infomaniak Network SA
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -30,8 +30,9 @@ class TokenInterceptor(
override fun intercept(chain: Interceptor.Chain): Response {
var request = chain.request()

runBlocking(Dispatchers.IO) {
val apiToken = tokenInterceptorListener.getApiToken() ?: return@runBlocking
runBlocking(Dispatchers.Default) {
tokenInterceptorListener.getApiToken()
}?.let { apiToken ->
val authorization = request.header("Authorization")
if (apiToken.accessToken != authorization?.replaceFirst("Bearer ", "")) {
request = changeAccessToken(request, apiToken)
Expand Down

0 comments on commit d9ee75c

Please sign in to comment.