Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
imtoori committed May 7, 2022
2 parents 5f0a309 + 561c200 commit 4ba6df8
Show file tree
Hide file tree
Showing 37 changed files with 648 additions and 114 deletions.
26 changes: 21 additions & 5 deletions packages/stream_chat/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
## 4.1.0

✅ Added

- Added support for extra data in attachment file uploader. Thanks, [@rlee1990](https://github.com/rlee1990).

🔄 Changed

- Deprecated `role` in `Member` in favor of `channelRole`
- Deprecated `currentUserRole` getter in `Channel` in favor of `currentUserChannelRole`

## 4.0.1

- Minor fixes

## 4.0.0

For upgrading to V4, please refer to the [V4 Migration Guide](https://getstream.io/chat/docs/sdk/flutter/guides/migration_guide_4_0/)
For upgrading to V4, please refer to
the [V4 Migration Guide](https://getstream.io/chat/docs/sdk/flutter/guides/migration_guide_4_0/)

✅ Added

Expand All @@ -19,8 +31,10 @@ For upgrading to V4, please refer to the [V4 Migration Guide](https://getstream.
any channel.
- [[#1047]](https://github.com/GetStream/stream-chat-flutter/issues/1047) `own_capabilities` extraData missing after
channel update.
- [[#1054]](https://github.com/GetStream/stream-chat-flutter/issues/1054) Fix `Unsupported operation: Cannot remove from an unmodifiable list`.
- [[#1033]](https://github.com/GetStream/stream-chat-flutter/issues/1033) Hard delete from dashboard does not delete message from client.
- [[#1054]](https://github.com/GetStream/stream-chat-flutter/issues/1054)
Fix `Unsupported operation: Cannot remove from an unmodifiable list`.
- [[#1033]](https://github.com/GetStream/stream-chat-flutter/issues/1033) Hard delete from dashboard does not delete
message from client.
- Send only `user_id` while reconnecting.

✅ Added
Expand Down Expand Up @@ -53,8 +67,10 @@ For upgrading to V4, please refer to the [V4 Migration Guide](https://getstream.
any channel.
- [[#1047]](https://github.com/GetStream/stream-chat-flutter/issues/1047) `own_capabilities` extraData missing after
channel update.
- [[#1054]](https://github.com/GetStream/stream-chat-flutter/issues/1054) Fix `Unsupported operation: Cannot remove from an unmodifiable list`.
- [[#1033]](https://github.com/GetStream/stream-chat-flutter/issues/1033) Hard delete from dashboard does not delete message from client.
- [[#1054]](https://github.com/GetStream/stream-chat-flutter/issues/1054)
Fix `Unsupported operation: Cannot remove from an unmodifiable list`.
- [[#1033]](https://github.com/GetStream/stream-chat-flutter/issues/1033) Hard delete from dashboard does not delete
message from client.
- Send only `user_id` while reconnecting.

✅ Added
Expand Down
14 changes: 14 additions & 0 deletions packages/stream_chat/lib/src/client/channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -448,12 +448,14 @@ class Channel {
it.file!,
onSendProgress: onSendProgress,
cancelToken: cancelToken,
extraData: it.extraData,
).then((it) => it.file);
} else {
future = sendFile(
it.file!,
onSendProgress: onSendProgress,
cancelToken: cancelToken,
extraData: it.extraData,
).then((it) => it.file);
}
_cancelableAttachmentUploadRequest[it.id] = cancelToken;
Expand Down Expand Up @@ -757,6 +759,7 @@ class Channel {
AttachmentFile file, {
ProgressCallback? onSendProgress,
CancelToken? cancelToken,
Map<String, Object?>? extraData,
}) {
_checkInitialized();
return _client.sendFile(
Expand All @@ -765,6 +768,7 @@ class Channel {
type,
onSendProgress: onSendProgress,
cancelToken: cancelToken,
extraData: extraData,
);
}

Expand All @@ -773,6 +777,7 @@ class Channel {
AttachmentFile file, {
ProgressCallback? onSendProgress,
CancelToken? cancelToken,
Map<String, Object?>? extraData,
}) {
_checkInitialized();
return _client.sendImage(
Expand All @@ -781,6 +786,7 @@ class Channel {
type,
onSendProgress: onSendProgress,
cancelToken: cancelToken,
extraData: extraData,
);
}

Expand All @@ -805,27 +811,31 @@ class Channel {
Future<EmptyResponse> deleteFile(
String url, {
CancelToken? cancelToken,
Map<String, Object?>? extraData,
}) {
_checkInitialized();
return _client.deleteFile(
url,
id!,
type,
cancelToken: cancelToken,
extraData: extraData,
);
}

/// Delete an image from this channel.
Future<EmptyResponse> deleteImage(
String url, {
CancelToken? cancelToken,
Map<String, Object?>? extraData,
}) {
_checkInitialized();
return _client.deleteImage(
url,
id!,
type,
cancelToken: cancelToken,
extraData: extraData,
);
}

Expand Down Expand Up @@ -2007,8 +2017,12 @@ class ChannelClientState {
);

/// User role for the current user.
@Deprecated('Please use currentUserChannelRole')
String? get currentUserRole => currentUserMember?.role;

/// Channel role for the current user
String? get currentUserChannelRole => currentUserMember?.channelRole;

/// Channel read list.
List<Read> get read => _channelState.read ?? <Read>[];

Expand Down
8 changes: 8 additions & 0 deletions packages/stream_chat/lib/src/client/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -728,13 +728,15 @@ class StreamChatClient {
String channelType, {
ProgressCallback? onSendProgress,
CancelToken? cancelToken,
Map<String, Object?>? extraData,
}) =>
_chatApi.fileUploader.sendFile(
file,
channelId,
channelType,
onSendProgress: onSendProgress,
cancelToken: cancelToken,
extraData: extraData,
);

/// Send a [image] to the [channelId] of type [channelType]
Expand All @@ -744,13 +746,15 @@ class StreamChatClient {
String channelType, {
ProgressCallback? onSendProgress,
CancelToken? cancelToken,
Map<String, Object?>? extraData,
}) =>
_chatApi.fileUploader.sendImage(
image,
channelId,
channelType,
onSendProgress: onSendProgress,
cancelToken: cancelToken,
extraData: extraData,
);

/// Delete a file from this channel
Expand All @@ -759,12 +763,14 @@ class StreamChatClient {
String channelId,
String channelType, {
CancelToken? cancelToken,
Map<String, Object?>? extraData,
}) =>
_chatApi.fileUploader.deleteFile(
url,
channelId,
channelType,
cancelToken: cancelToken,
extraData: extraData,
);

/// Delete an image from this channel
Expand All @@ -773,12 +779,14 @@ class StreamChatClient {
String channelId,
String channelType, {
CancelToken? cancelToken,
Map<String, Object?>? extraData,
}) =>
_chatApi.fileUploader.deleteImage(
url,
channelId,
channelType,
cancelToken: cancelToken,
extraData: extraData,
);

/// Replaces the [channelId] of type [ChannelType] data with [data].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ abstract class AttachmentFileUploader {
String channelType, {
ProgressCallback? onSendProgress,
CancelToken? cancelToken,
Map<String, Object?>? extraData,
});

/// Uploads a [file] to the given channel.
Expand All @@ -29,6 +30,7 @@ abstract class AttachmentFileUploader {
String channelType, {
ProgressCallback? onSendProgress,
CancelToken? cancelToken,
Map<String, Object?>? extraData,
});

/// Deletes a image using its [url] from the given channel.
Expand All @@ -40,6 +42,7 @@ abstract class AttachmentFileUploader {
String channelId,
String channelType, {
CancelToken? cancelToken,
Map<String, Object?>? extraData,
});

/// Deletes a file using its [url] from the given channel.
Expand All @@ -51,6 +54,7 @@ abstract class AttachmentFileUploader {
String channelId,
String channelType, {
CancelToken? cancelToken,
Map<String, Object?>? extraData,
});
}

Expand All @@ -68,6 +72,7 @@ class StreamAttachmentFileUploader implements AttachmentFileUploader {
String channelType, {
ProgressCallback? onSendProgress,
CancelToken? cancelToken,
Map<String, Object?>? extraData,
}) async {
final multiPartFile = await file.toMultipartFile();
final response = await _client.postFile(
Expand All @@ -86,6 +91,7 @@ class StreamAttachmentFileUploader implements AttachmentFileUploader {
String channelType, {
ProgressCallback? onSendProgress,
CancelToken? cancelToken,
Map<String, Object?>? extraData,
}) async {
final multiPartFile = await file.toMultipartFile();
final response = await _client.postFile(
Expand All @@ -103,6 +109,7 @@ class StreamAttachmentFileUploader implements AttachmentFileUploader {
String channelId,
String channelType, {
CancelToken? cancelToken,
Map<String, Object?>? extraData,
}) async {
final response = await _client.delete(
'/channels/$channelType/$channelId/image',
Expand All @@ -118,6 +125,7 @@ class StreamAttachmentFileUploader implements AttachmentFileUploader {
String channelId,
String channelType, {
CancelToken? cancelToken,
Map<String, Object?>? extraData,
}) async {
final response = await _client.delete(
'/channels/$channelType/$channelId/file',
Expand Down
10 changes: 10 additions & 0 deletions packages/stream_chat/lib/src/core/models/member.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: deprecated_member_use_from_same_package

import 'package:equatable/equatable.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:stream_chat/src/core/models/user.dart';
Expand All @@ -15,6 +17,7 @@ class Member extends Equatable {
this.inviteRejectedAt,
this.invited = false,
this.role,
this.channelRole,
this.userId,
this.isModerator = false,
DateTime? createdAt,
Expand Down Expand Up @@ -46,8 +49,12 @@ class Member extends Equatable {
final bool invited;

/// The role of the user in the channel
@Deprecated('Please use channelRole')
final String? role;

/// The role of this member in the channel
final String? channelRole;

/// The id of the interested user
final String? userId;

Expand Down Expand Up @@ -76,6 +83,7 @@ class Member extends Equatable {
DateTime? inviteRejectedAt,
bool? invited,
String? role,
String? channelRole,
String? userId,
bool? isModerator,
DateTime? createdAt,
Expand All @@ -93,6 +101,7 @@ class Member extends Equatable {
banExpires: banExpires ?? this.banExpires,
shadowBanned: shadowBanned ?? this.shadowBanned,
role: role ?? this.role,
channelRole: channelRole ?? this.channelRole,
userId: userId ?? this.userId,
isModerator: isModerator ?? this.isModerator,
createdAt: createdAt ?? this.createdAt,
Expand All @@ -109,6 +118,7 @@ class Member extends Equatable {
inviteRejectedAt,
invited,
role,
channelRole,
userId,
isModerator,
banned,
Expand Down
2 changes: 2 additions & 0 deletions packages/stream_chat/lib/src/core/models/member.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/stream_chat/lib/version.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import 'package:stream_chat/src/client/client.dart';
/// Current package version
/// Used in [StreamChatClient] to build the `x-stream-client` header
// ignore: constant_identifier_names
const PACKAGE_VERSION = '4.0.1';
const PACKAGE_VERSION = '4.1.0';
2 changes: 1 addition & 1 deletion packages/stream_chat/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: stream_chat
homepage: https://getstream.io/
description: The official Dart client for Stream Chat, a service for building chat applications.
version: 4.0.1
version: 4.1.0
repository: https://github.com/GetStream/stream-chat-flutter
issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues

Expand Down
2 changes: 1 addition & 1 deletion packages/stream_chat/test/fixtures/member.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"name": "Robin Papa",
"image": "https://pbs.twimg.com/profile_images/669512187778498560/L7wQctBt.jpg"
},
"role": "member",
"channel_role": "channel_member",
"created_at": "2020-01-28T22:17:30.95443Z",
"updated_at": "2020-01-28T22:17:30.95443Z"
}
Loading

0 comments on commit 4ba6df8

Please sign in to comment.