fix: interceptor handlers
This commit is contained in:
Generated
+1
-1
@@ -2,6 +2,6 @@
|
|||||||
<Workspace
|
<Workspace
|
||||||
version = "1.0">
|
version = "1.0">
|
||||||
<FileRef
|
<FileRef
|
||||||
location = "group:Runner.xcodeproj">
|
location = "self:">
|
||||||
</FileRef>
|
</FileRef>
|
||||||
</Workspace>
|
</Workspace>
|
||||||
|
|||||||
@@ -2,12 +2,9 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:stream_chat/stream_chat.dart';
|
import 'package:stream_chat/stream_chat.dart';
|
||||||
|
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
/// Create a new instance of [StreamChatClient] passing the apikey obtained from your
|
/// Create a new instance of [StreamChatClient]
|
||||||
/// project dashboard.
|
/// by passing the apikey obtained from your project dashboard.
|
||||||
final client = StreamChatClient(
|
final client = StreamChatClient('b67pax5b2wdq', logLevel: Level.INFO);
|
||||||
'b67pax5b2wdq',
|
|
||||||
logLevel: Level.INFO,
|
|
||||||
);
|
|
||||||
|
|
||||||
/// Set the current user. In a production scenario, this should be done using
|
/// Set the current user. In a production scenario, this should be done using
|
||||||
/// a backend to generate a user token using our server SDK.
|
/// a backend to generate a user token using our server SDK.
|
||||||
@@ -21,7 +18,7 @@ Future<void> main() async {
|
|||||||
'https://getstream.io/random_png/?id=cool-shadow-7&name=Cool+shadow',
|
'https://getstream.io/random_png/?id=cool-shadow-7&name=Cool+shadow',
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiY29vbC1zaGFkb3ctNyJ9.gkOlCRb1qgy4joHPaxFwPOdXcGvSPvp6QY0S4mpRkVo',
|
'''eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiY29vbC1zaGFkb3ctNyJ9.gkOlCRb1qgy4joHPaxFwPOdXcGvSPvp6QY0S4mpRkVo''',
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Creates a channel using the type `messaging` and `godevs`.
|
/// Creates a channel using the type `messaging` and `godevs`.
|
||||||
@@ -44,15 +41,16 @@ Future<void> main() async {
|
|||||||
|
|
||||||
/// Example using Stream's Low Level Dart client.
|
/// Example using Stream's Low Level Dart client.
|
||||||
class StreamExample extends StatelessWidget {
|
class StreamExample extends StatelessWidget {
|
||||||
/// To initialize this example, an instance of [client] and [channel] is required.
|
/// To initialize this example, an instance of
|
||||||
|
/// [client] and [channel] is required.
|
||||||
const StreamExample({
|
const StreamExample({
|
||||||
Key key,
|
Key key,
|
||||||
@required this.client,
|
@required this.client,
|
||||||
@required this.channel,
|
@required this.channel,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
/// Instance of [StreamChatClient] we created earlier. This contains information about
|
/// Instance of [StreamChatClient] we created earlier.
|
||||||
/// our application and connection state.
|
/// This contains information about our application and connection state.
|
||||||
final StreamChatClient client;
|
final StreamChatClient client;
|
||||||
|
|
||||||
/// The channel we'd like to observe and participate.
|
/// The channel we'd like to observe and participate.
|
||||||
@@ -104,8 +102,8 @@ class HomeScreen extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
return const Center(
|
return const Center(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: 100.0,
|
width: 100,
|
||||||
height: 100.0,
|
height: 100,
|
||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -180,7 +178,7 @@ class _MessageViewState extends State<MessageView> {
|
|||||||
return Align(
|
return Align(
|
||||||
alignment: Alignment.centerRight,
|
alignment: Alignment.centerRight,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8),
|
||||||
child: Text(item.text),
|
child: Text(item.text),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -188,7 +186,7 @@ class _MessageViewState extends State<MessageView> {
|
|||||||
return Align(
|
return Align(
|
||||||
alignment: Alignment.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8),
|
||||||
child: Text(item.text),
|
child: Text(item.text),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -197,7 +195,7 @@ class _MessageViewState extends State<MessageView> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
@@ -245,7 +243,8 @@ class _MessageViewState extends State<MessageView> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper extension for quickly retrieving the current user id from a [StreamChatClient].
|
/// Helper extension for quickly retrieving
|
||||||
|
/// the current user id from a [StreamChatClient].
|
||||||
extension on StreamChatClient {
|
extension on StreamChatClient {
|
||||||
String get uid => state.user.id;
|
String get uid => state.user.id;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,22 @@
|
|||||||
name: example
|
name: example
|
||||||
description: A new Flutter project.
|
description: A new Flutter project.
|
||||||
|
|
||||||
publish_to: 'none'
|
publish_to: "none"
|
||||||
version: 1.0.0+1
|
version: 1.0.0+1
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.7.0 <3.0.0"
|
sdk: ">=2.7.0 <3.0.0"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
|
cupertino_icons: ^1.0.0
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
cupertino_icons: ^1.0.0
|
|
||||||
stream_chat:
|
stream_chat:
|
||||||
path: ../
|
path: ../
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|
||||||
flutter:
|
flutter:
|
||||||
uses-material-design: true
|
uses-material-design: true
|
||||||
@@ -280,8 +280,7 @@ class StreamChatClient {
|
|||||||
data: $stringData
|
data: $stringData
|
||||||
|
|
||||||
''');
|
''');
|
||||||
|
handler.next(options);
|
||||||
return options;
|
|
||||||
},
|
},
|
||||||
onError: _tokenExpiredInterceptor,
|
onError: _tokenExpiredInterceptor,
|
||||||
),
|
),
|
||||||
@@ -315,33 +314,35 @@ class StreamChatClient {
|
|||||||
await connectUser(User(id: userId), newToken);
|
await connectUser(User(id: userId), newToken);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await httpClient.request(
|
handler.resolve(
|
||||||
err.requestOptions.path,
|
await httpClient.request(
|
||||||
cancelToken: err.requestOptions.cancelToken,
|
err.requestOptions.path,
|
||||||
data: err.requestOptions.data,
|
cancelToken: err.requestOptions.cancelToken,
|
||||||
onReceiveProgress: err.requestOptions.onReceiveProgress,
|
data: err.requestOptions.data,
|
||||||
onSendProgress: err.requestOptions.onSendProgress,
|
onReceiveProgress: err.requestOptions.onReceiveProgress,
|
||||||
queryParameters: err.requestOptions.queryParameters,
|
onSendProgress: err.requestOptions.onSendProgress,
|
||||||
options: Options(
|
queryParameters: err.requestOptions.queryParameters,
|
||||||
method: err.requestOptions.method,
|
options: Options(
|
||||||
sendTimeout: err.requestOptions.sendTimeout,
|
method: err.requestOptions.method,
|
||||||
receiveTimeout: err.requestOptions.receiveTimeout,
|
sendTimeout: err.requestOptions.sendTimeout,
|
||||||
extra: err.requestOptions.extra,
|
receiveTimeout: err.requestOptions.receiveTimeout,
|
||||||
headers: err.requestOptions.headers,
|
extra: err.requestOptions.extra,
|
||||||
responseType: err.requestOptions.responseType,
|
headers: err.requestOptions.headers,
|
||||||
contentType: err.requestOptions.contentType,
|
responseType: err.requestOptions.responseType,
|
||||||
validateStatus: err.requestOptions.validateStatus,
|
contentType: err.requestOptions.contentType,
|
||||||
receiveDataWhenStatusError:
|
validateStatus: err.requestOptions.validateStatus,
|
||||||
err.requestOptions.receiveDataWhenStatusError,
|
receiveDataWhenStatusError:
|
||||||
followRedirects: err.requestOptions.followRedirects,
|
err.requestOptions.receiveDataWhenStatusError,
|
||||||
maxRedirects: err.requestOptions.maxRedirects,
|
followRedirects: err.requestOptions.followRedirects,
|
||||||
requestEncoder: err.requestOptions.requestEncoder,
|
maxRedirects: err.requestOptions.maxRedirects,
|
||||||
responseDecoder: err.requestOptions.responseDecoder,
|
requestEncoder: err.requestOptions.requestEncoder,
|
||||||
listFormat: err.requestOptions.listFormat,
|
responseDecoder: err.requestOptions.responseDecoder,
|
||||||
|
listFormat: err.requestOptions.listFormat,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return err;
|
handler.reject(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -871,7 +871,7 @@ void main() {
|
|||||||
expect(channelState.messages[0], isNotNull);
|
expect(channelState.messages[0], isNotNull);
|
||||||
expect(
|
expect(
|
||||||
channelState.messages[0].createdAt,
|
channelState.messages[0].createdAt,
|
||||||
DateTime.parse('2,020-01-29T03:23:02.843948Z'),
|
DateTime.parse('2020-01-29T03:23:02.843948Z'),
|
||||||
);
|
);
|
||||||
expect(channelState.messages[0].user, isA<User>());
|
expect(channelState.messages[0].user, isA<User>());
|
||||||
expect(channelState.watcherCount, 5);
|
expect(channelState.watcherCount, 5);
|
||||||
|
|||||||
Reference in New Issue
Block a user