Skip to content

Commit

Permalink
Merge pull request #272 from GetStream/fix-attachment-upload-state
Browse files Browse the repository at this point in the history
Add `preparing` state to attachment upload state
  • Loading branch information
imtoori authored Feb 19, 2021
2 parents 6da15f7 + ae3daee commit 953a82c
Show file tree
Hide file tree
Showing 15 changed files with 244 additions and 20 deletions.
6 changes: 6 additions & 0 deletions packages/stream_chat/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.2.0-beta

- 🛑 **BREAKING** Changed signature of `StreamClient.search` method
- Added `pinMessage` feature [docs here](https://getstream.io/chat/docs/flutter-dart/pinned_messages/?language=dart)
- Fixed minor bugs

## 1.1.0-beta

- Fixed minor bugs
Expand Down
14 changes: 2 additions & 12 deletions packages/stream_chat/lib/src/api/channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,7 @@ class Channel {
attachments: message.attachments?.map(
(it) {
if (it.uploadState.isSuccess) return it;
return it.copyWith(
uploadState: UploadState.inProgress(
uploaded: 0,
total: it.file?.size ?? it.extraData['file_size'],
),
);
return it.copyWith(uploadState: UploadState.preparing());
},
)?.toList(),
);
Expand Down Expand Up @@ -370,12 +365,7 @@ class Channel {
attachments: message.attachments?.map(
(it) {
if (it.uploadState.isSuccess) return it;
return it.copyWith(
uploadState: UploadState.inProgress(
uploaded: 0,
total: it.file?.size ?? it.extraData['file_size'],
),
);
return it.copyWith(uploadState: UploadState.preparing());
},
)?.toList(),
);
Expand Down
6 changes: 6 additions & 0 deletions packages/stream_chat/lib/src/models/attachment_file.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ part 'attachment_file.g.dart';
/// Union class to hold various [UploadState] of a attachment.
@freezed
abstract class UploadState with _$UploadState {
/// Preparing state of the union
const factory UploadState.preparing() = Preparing;

/// InProgress state of the union
const factory UploadState.inProgress({int uploaded, int total}) = InProgress;

Expand All @@ -26,6 +29,9 @@ abstract class UploadState with _$UploadState {

/// Helper extension for UploadState
extension UploadStateX on UploadState {
/// Returns true if state is [Preparing]
bool get isPreparing => this is Preparing;

/// Returns true if state is [InProgress]
bool get isInProgress => this is InProgress;

Expand Down
141 changes: 141 additions & 0 deletions packages/stream_chat/lib/src/models/attachment_file.freezed.dart

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

7 changes: 7 additions & 0 deletions packages/stream_chat/lib/src/models/attachment_file.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 @@ -2,4 +2,4 @@ import 'package:stream_chat/src/client.dart';

/// Current package version
/// Used in [StreamChatClient] to build the `x-stream-client` header
const PACKAGE_VERSION = '1.1.0-beta';
const PACKAGE_VERSION = '1.2.0-beta';
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: 1.1.0-beta
version: 1.2.0-beta
repository: https://github.com/GetStream/stream-chat-flutter
issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues

Expand Down
5 changes: 5 additions & 0 deletions packages/stream_chat_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.2.0-beta

- Minor fixes
- Update stream_chat_core dependency

## 1.1.1-beta

- Added MessageInput button color customization options
Expand Down
Loading

0 comments on commit 953a82c

Please sign in to comment.