migrate chatty
This commit is contained in:
@@ -8,7 +8,7 @@ class StreamApiLocalImpl extends StreamApiRepository {
|
||||
final StreamChatClient _client;
|
||||
|
||||
@override
|
||||
Future<ChatUser> connectUser(ChatUser user, String token) async {
|
||||
Future<ChatUser> connectUser(ChatUser user, String? token) async {
|
||||
Map<String, dynamic> extraData = {};
|
||||
if (user.image != null) {
|
||||
extraData['image'] = user.image;
|
||||
@@ -18,7 +18,7 @@ class StreamApiLocalImpl extends StreamApiRepository {
|
||||
}
|
||||
await _client.disconnect();
|
||||
await _client.connectUser(
|
||||
User(id: user.id, extraData: extraData),
|
||||
User(id: user.id!, extraData: extraData as Map<String, Object>),
|
||||
token,
|
||||
);
|
||||
return user;
|
||||
@@ -28,12 +28,12 @@ class StreamApiLocalImpl extends StreamApiRepository {
|
||||
Future<List<ChatUser>> getChatUsers() async {
|
||||
final result = await _client.queryUsers();
|
||||
final chatUsers = result.users
|
||||
.where((element) => element.id != _client.state.user.id)
|
||||
.where((element) => element.id != _client.state.user!.id)
|
||||
.map(
|
||||
(e) => ChatUser(
|
||||
id: e.id,
|
||||
name: e.name,
|
||||
image: e.extraData['image'],
|
||||
image: e.extraData['image'] as String?,
|
||||
),
|
||||
)
|
||||
.toList();
|
||||
@@ -47,25 +47,25 @@ class StreamApiLocalImpl extends StreamApiRepository {
|
||||
|
||||
@override
|
||||
Future<Channel> createGroupChat(
|
||||
String channelId, String name, List<String> members,
|
||||
{String image}) async {
|
||||
String channelId, String? name, List<String?>? members,
|
||||
{String? image}) async {
|
||||
final channel = _client.channel('messaging', id: channelId, extraData: {
|
||||
'name': name,
|
||||
'image': image,
|
||||
'members': [_client.state.user.id, ...members],
|
||||
'name': name!,
|
||||
'image': image!,
|
||||
'members': [_client.state.user!.id, ...members!],
|
||||
});
|
||||
await channel.watch();
|
||||
return channel;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Channel> createSimpleChat(String friendId) async {
|
||||
Future<Channel> createSimpleChat(String? friendId) async {
|
||||
final channel = _client.channel('messaging',
|
||||
id: '${_client.state.user.id.hashCode}${friendId.hashCode}',
|
||||
id: '${_client.state.user!.id.hashCode}${friendId.hashCode}',
|
||||
extraData: {
|
||||
'members': [
|
||||
friendId,
|
||||
_client.state.user.id,
|
||||
_client.state.user!.id,
|
||||
],
|
||||
});
|
||||
await channel.watch();
|
||||
@@ -84,6 +84,6 @@ class StreamApiLocalImpl extends StreamApiRepository {
|
||||
User(id: userId),
|
||||
token,
|
||||
);
|
||||
return _client.state.user.name != null && _client.state.user.name != userId;
|
||||
return _client.state.user!.name != null && _client.state.user!.name != userId;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user