diff --git a/packages/stream_chat/lib/src/core/http/interceptor/auth_interceptor.dart b/packages/stream_chat/lib/src/core/http/interceptor/auth_interceptor.dart index 7748f96f..58db2fe3 100644 --- a/packages/stream_chat/lib/src/core/http/interceptor/auth_interceptor.dart +++ b/packages/stream_chat/lib/src/core/http/interceptor/auth_interceptor.dart @@ -8,7 +8,7 @@ import 'package:stream_chat/src/core/http/token_manager.dart'; /// Authentication interceptor that refreshes the token if /// an auth error is received -class AuthInterceptor extends Interceptor { +class AuthInterceptor extends QueuedInterceptor { /// Initialize a new auth interceptor AuthInterceptor(this._client, this._tokenManager); @@ -57,9 +57,7 @@ class AuthInterceptor extends Interceptor { final error = ErrorResponse.fromJson(data); if (error.code == ChatErrorCode.tokenExpired.code) { if (_tokenManager.isStatic) return handler.next(err); - _client.lock(); await _tokenManager.loadToken(refresh: true); - _client.unlock(); try { final options = err.requestOptions; final response = await _client.request( diff --git a/packages/stream_chat/lib/src/core/http/stream_http_client.dart b/packages/stream_chat/lib/src/core/http/stream_http_client.dart index d977b010..169492a7 100644 --- a/packages/stream_chat/lib/src/core/http/stream_http_client.dart +++ b/packages/stream_chat/lib/src/core/http/stream_http_client.dart @@ -76,20 +76,6 @@ class StreamHttpClient { @visibleForTesting final Dio httpClient; - /// Lock the current [StreamHttpClient] instance. - /// - /// [StreamHttpClient] will enqueue the incoming request tasks instead - /// send them directly when [interceptor.requestOptions] is locked. - void lock() => httpClient.lock(); - - /// Unlock the current [StreamHttpClient] instance. - /// - /// [StreamHttpClient] instance dequeue the request task。 - void unlock() => httpClient.unlock(); - - /// Clear the current [StreamHttpClient] instance waiting queue. - void clear() => httpClient.clear(); - /// Shuts down the [StreamHttpClient]. /// /// If [force] is `false` the [StreamHttpClient] will be kept alive diff --git a/packages/stream_chat/test/src/core/http/interceptor/auth_interceptor_test.dart b/packages/stream_chat/test/src/core/http/interceptor/auth_interceptor_test.dart index 1e88ea1e..44b05141 100644 --- a/packages/stream_chat/test/src/core/http/interceptor/auth_interceptor_test.dart +++ b/packages/stream_chat/test/src/core/http/interceptor/auth_interceptor_test.dart @@ -93,14 +93,10 @@ void main() { when(() => tokenManager.isStatic).thenReturn(false); - when(() => client.lock()).thenReturn(() {}); - final token = Token.development('test-user-id'); when(() => tokenManager.loadToken(refresh: true)) .thenAnswer((_) async => token); - when(() => client.unlock()).thenReturn(() {}); - when(() => client.request( path, data: options.data, @@ -127,12 +123,9 @@ void main() { verify(() => tokenManager.isStatic).called(1); - verify(() => client.lock()).called(1); - verify(() => tokenManager.loadToken(refresh: true)).called(1); verifyNoMoreInteractions(tokenManager); - verify(() => client.unlock()).called(1); verify(() => client.request( path, data: options.data, @@ -163,14 +156,10 @@ void main() { when(() => tokenManager.isStatic).thenReturn(false); - when(() => client.lock()).thenReturn(() {}); - final token = Token.development('test-user-id'); when(() => tokenManager.loadToken(refresh: true)) .thenAnswer((_) async => token); - when(() => client.unlock()).thenReturn(() {}); - when(() => client.request( path, data: options.data, @@ -193,12 +182,9 @@ void main() { verify(() => tokenManager.isStatic).called(1); - verify(() => client.lock()).called(1); - verify(() => tokenManager.loadToken(refresh: true)).called(1); verifyNoMoreInteractions(tokenManager); - verify(() => client.unlock()).called(1); verify(() => client.request( path, data: options.data,