Skip to content

Commit

Permalink
Merge pull request #1799 from GetStream/chore/sync
Browse files Browse the repository at this point in the history
chore(repo): sync master with v7.0.0
  • Loading branch information
deven98 authored Dec 4, 2023
2 parents 11223e6 + ed16cb8 commit 99e6a73
Show file tree
Hide file tree
Showing 190 changed files with 4,614 additions and 4,116 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/legacy_version_analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: legacy_version_analyze
env:
# Note: The versions below should be manually updated after a new stable
# version comes out.
flutter_version: "3.10.6"
flutter_version: "3.13.9"

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stream_flutter_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: stream_flutter_workflow
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
flutter_channel: "stable"
flutter_version: "3.10.6"
flutter_version: "3.13.9"

on:
pull_request:
Expand Down
14 changes: 14 additions & 0 deletions packages/stream_chat/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## 7.0.0

- 🛑️ Breaking

- Removed deprecated `channelQuery.sort` property. Use `channelStateSort` instead.
- Removed deprecated `RetryPolicy.retryTimeout` property. Use `delayFactor` instead.
- Removed deprecated `StreamChatNetworkError.fromDioError` constructor. Use `StreamChatNetworkError.fromDioException`
instead.
- Removed deprecated `MessageSendingStatus` enum. Use `MessageState` instead.

🔄 Changed

- Updated minimum supported `SDK` version to Flutter 3.13/Dart 3.1

# 6.10.0

🐞 Fixed
Expand Down
4 changes: 2 additions & 2 deletions packages/stream_chat/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ publish_to: "none"
version: 1.0.0+1

environment:
sdk: ">=3.0.0 <4.0.0"
flutter: ">=3.10.0"
sdk: ">=3.1.0 <4.0.0"
flutter: ">=3.13.0"

dependencies:
cupertino_icons: ^1.0.5
Expand Down
2 changes: 1 addition & 1 deletion packages/stream_chat/lib/src/client/channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ class Channel {
]);
}

final isImage = it.type == 'image';
final isImage = it.type == AttachmentType.image;
final cancelToken = CancelToken();
Future<SendAttachmentResponse> future;
if (isImage) {
Expand Down
15 changes: 2 additions & 13 deletions packages/stream_chat/lib/src/client/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import 'package:stream_chat/src/core/http/stream_http_client.dart';
import 'package:stream_chat/src/core/http/token.dart';
import 'package:stream_chat/src/core/http/token_manager.dart';
import 'package:stream_chat/src/core/models/attachment_file.dart';
import 'package:stream_chat/src/core/models/channel_model.dart';
import 'package:stream_chat/src/core/models/channel_state.dart';
import 'package:stream_chat/src/core/models/event.dart';
import 'package:stream_chat/src/core/models/filter.dart';
Expand Down Expand Up @@ -572,8 +571,6 @@ class StreamChatClient {
/// Requests channels with a given query.
Stream<List<Channel>> queryChannels({
Filter? filter,
@Deprecated('Use channelStateSort instead.')
List<SortOption<ChannelModel>>? sort,
List<SortOption<ChannelState>>? channelStateSort,
bool state = true,
bool watch = true,
Expand All @@ -590,7 +587,7 @@ class StreamChatClient {

final hash = generateHash([
filter,
sort,
channelStateSort,
state,
watch,
presence,
Expand All @@ -604,8 +601,6 @@ class StreamChatClient {
} else {
final channels = await queryChannelsOffline(
filter: filter,
// ignore: deprecated_member_use_from_same_package
sort: sort,
channelStateSort: channelStateSort,
paginationParams: paginationParams,
);
Expand All @@ -614,7 +609,7 @@ class StreamChatClient {
try {
final newQueryChannelsFuture = queryChannelsOnline(
filter: filter,
sort: channelStateSort ?? sort,
sort: channelStateSort,
state: state,
watch: watch,
presence: presence,
Expand Down Expand Up @@ -731,17 +726,11 @@ class StreamChatClient {
/// Requests channels with a given query from the Persistence client.
Future<List<Channel>> queryChannelsOffline({
Filter? filter,
@Deprecated('''
sort has been deprecated.
Please use channelStateSort instead.''')
List<SortOption<ChannelModel>>? sort,
List<SortOption<ChannelState>>? channelStateSort,
PaginationParams paginationParams = const PaginationParams(),
}) async {
final offlineChannels = (await chatPersistenceClient?.getChannelStates(
filter: filter,
// ignore: deprecated_member_use_from_same_package
sort: sort,
channelStateSort: channelStateSort,
paginationParams: paginationParams,
)) ??
Expand Down
10 changes: 0 additions & 10 deletions packages/stream_chat/lib/src/client/retry_policy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class RetryPolicy {
/// Instantiate a new RetryPolicy
RetryPolicy({
required this.shouldRetry,
@Deprecated("Use 'delayFactor' instead.") this.retryTimeout,
this.maxRetryAttempts = 6,
this.delayFactor = const Duration(milliseconds: 200),
this.randomizationFactor = 0.25,
Expand Down Expand Up @@ -53,13 +52,4 @@ class RetryPolicy {
int attempt,
StreamChatError? error,
) shouldRetry;

/// In the case that we want to retry a failed request the retryTimeout
/// method is called to determine the timeout
@Deprecated("Use 'delayFactor' instead.")
final Duration Function(
StreamChatClient client,
int attempt,
StreamChatError? error,
)? retryTimeout;
}
2 changes: 0 additions & 2 deletions packages/stream_chat/lib/src/core/api/requests.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// ignore_for_file: deprecated_member_use_from_same_package

import 'package:equatable/equatable.dart';
import 'package:json_annotation/json_annotation.dart';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,6 @@ class StreamChatNetworkError extends StreamChatError {
this.isRequestCancelledError = false,
}) : super(message);

///
@Deprecated('Use `StreamChatNetworkError.fromDioException` instead')
factory StreamChatNetworkError.fromDioError(DioException error) =
StreamChatNetworkError.fromDioException;

///
factory StreamChatNetworkError.fromDioException(DioException exception) {
final response = exception.response;
Expand Down
74 changes: 61 additions & 13 deletions packages/stream_chat/lib/src/core/models/attachment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,25 @@ import 'package:uuid/uuid.dart';

part 'attachment.g.dart';

mixin AttachmentType {
/// Backend specified types.
static const image = 'image';
static const file = 'file';
static const giphy = 'giphy';
static const video = 'video';
static const audio = 'audio';

/// Application custom types.
static const urlPreview = 'url_preview';
}

/// The class that contains the information about an attachment
@JsonSerializable(includeIfNull: false)
class Attachment extends Equatable {
/// Constructor used for json serialization
Attachment({
String? id,
this.type,
String? type,
this.titleLink,
String? title,
this.thumbUrl,
Expand All @@ -33,26 +45,24 @@ class Attachment extends Equatable {
this.authorLink,
this.authorIcon,
this.assetUrl,
List<Action>? actions,
this.actions = const [],
this.originalWidth,
this.originalHeight,
Map<String, Object?> extraData = const {},
this.file,
UploadState? uploadState,
}) : id = id ?? const Uuid().v4(),
_type = type,
title = title ?? file?.name,
_uploadState = uploadState,
localUri = file?.path != null ? Uri.parse(file!.path!) : null,
actions = actions ?? [],
// For backwards compatibility,
// set 'file_size', 'mime_type' in [extraData].
extraData = {
...extraData,
if (file?.size != null) 'file_size': file?.size,
if (file?.mimeType != null) 'mime_type': file?.mimeType?.mimeType,
} {
this.uploadState = uploadState ??
((assetUrl != null || imageUrl != null || thumbUrl != null)
? const UploadState.success()
: const UploadState.preparing());
}
if (file?.mediaType != null) 'mime_type': file?.mediaType?.mimeType,
};

/// Create a new instance from a json
factory Attachment.fromJson(Map<String, dynamic> json) =>
Expand All @@ -69,7 +79,8 @@ class Attachment extends Equatable {

factory Attachment.fromOGAttachment(OGAttachmentResponse ogAttachment) =>
Attachment(
type: ogAttachment.type,
// If the type is not specified, we default to urlPreview.
type: ogAttachment.type ?? AttachmentType.urlPreview,
title: ogAttachment.title,
titleLink: ogAttachment.titleLink,
text: ogAttachment.text,
Expand All @@ -84,7 +95,20 @@ class Attachment extends Equatable {

///The attachment type based on the URL resource. This can be: audio,
///image or video
final String? type;
String? get type {
// If the attachment contains titleLink but is not of type giphy, we
// consider it as a urlPreview.
if (_type != AttachmentType.giphy && titleLink != null) {
return AttachmentType.urlPreview;
}

return _type;
}

final String? _type;

/// The raw attachment type.
String? get rawType => _type;

///The link to which the attachment message points to.
final String? titleLink;
Expand Down Expand Up @@ -126,13 +150,27 @@ class Attachment extends Equatable {
/// Actions from a command
final List<Action>? actions;

/// The original width of the attached image.
final int? originalWidth;

/// The original height of the attached image.
final int? originalHeight;

final Uri? localUri;

/// The file present inside this attachment.
final AttachmentFile? file;

/// The current upload state of the attachment
late final UploadState uploadState;
UploadState get uploadState {
if (_uploadState case final state?) return state;

return ((assetUrl != null || imageUrl != null || thumbUrl != null)
? const UploadState.success()
: const UploadState.preparing());
}

final UploadState? _uploadState;

/// Map of custom channel extraData
final Map<String, Object?> extraData;
Expand Down Expand Up @@ -175,6 +213,8 @@ class Attachment extends Equatable {
'author_icon',
'asset_url',
'actions',
'original_width',
'original_height',
];

/// Known db specific top level fields.
Expand Down Expand Up @@ -214,6 +254,8 @@ class Attachment extends Equatable {
String? authorIcon,
String? assetUrl,
List<Action>? actions,
int? originalWidth,
int? originalHeight,
AttachmentFile? file,
UploadState? uploadState,
Map<String, Object?>? extraData,
Expand All @@ -238,6 +280,8 @@ class Attachment extends Equatable {
authorIcon: authorIcon ?? this.authorIcon,
assetUrl: assetUrl ?? this.assetUrl,
actions: actions ?? this.actions,
originalWidth: originalWidth ?? this.originalWidth,
originalHeight: originalHeight ?? this.originalHeight,
file: file ?? this.file,
uploadState: uploadState ?? this.uploadState,
extraData: extraData ?? this.extraData,
Expand All @@ -264,6 +308,8 @@ class Attachment extends Equatable {
authorIcon: other.authorIcon,
assetUrl: other.assetUrl,
actions: other.actions,
originalWidth: other.originalWidth,
originalHeight: other.originalHeight,
file: other.file,
uploadState: other.uploadState,
extraData: other.extraData,
Expand Down Expand Up @@ -291,6 +337,8 @@ class Attachment extends Equatable {
authorIcon,
assetUrl,
actions,
originalWidth,
originalHeight,
file,
uploadState,
extraData,
Expand Down
9 changes: 7 additions & 2 deletions packages/stream_chat/lib/src/core/models/attachment.g.dart

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

10 changes: 5 additions & 5 deletions packages/stream_chat/lib/src/core/models/attachment_file.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class AttachmentFile {
String? get extension => name?.split('.').last;

/// The mime type of this file.
MediaType? get mimeType => name?.mimeType;
MediaType? get mediaType => name?.mediaType;

/// Serialize to json
Map<String, dynamic> toJson() => _$AttachmentFileToJson(this);
Expand All @@ -74,14 +74,14 @@ class AttachmentFile {
if (CurrentPlatform.isWeb) {
multiPartFile = MultipartFile.fromBytes(
bytes!,
filename: name ?? 'file',
contentType: mimeType,
filename: name,
contentType: mediaType,
);
} else {
multiPartFile = await MultipartFile.fromFile(
path!,
filename: name ?? 'file',
contentType: mimeType,
filename: name,
contentType: mediaType,
);
}
return multiPartFile;
Expand Down
Loading

0 comments on commit 99e6a73

Please sign in to comment.