Merge branch 'develop' of https://github.com/GetStream/stream-chat-flutter into feat/hard-delete

 Conflicts:
	packages/stream_chat/CHANGELOG.md
This commit is contained in:
Deven Joshi
2021-11-25 14:45:02 +05:30
37 changed files with 546 additions and 239 deletions
+8 -1
View File
@@ -2,8 +2,15 @@
✅ Added
- Extra properties added to `PaginationParams` to aid in fetching messages.
- Added hard delete functionality.
🐞 Fixed
- `closeConnection()` now uses `normalClosure` status when closing websocket.
- Fixed local unread count indicator increasing for thread replies
- Fixed user presence indicator not updating correctly
## 3.2.0
🐞 Fixed
@@ -726,4 +733,4 @@
## 0.0.2
- first beta version
- first beta version
+2 -2
View File
@@ -233,10 +233,10 @@ class _MessageViewState extends State<MessageView> {
),
),
),
)
),
],
),
)
),
],
);
}
@@ -1860,10 +1860,13 @@ class ChannelClientState {
(m) => m.user.id == message.user?.id,
) !=
null;
final isThreadMessage = message.parentId != null;
return !message.silent &&
!message.shadowed &&
message.user?.id != userId &&
!userIsMuted;
!userIsMuted &&
!isThreadMessage;
}
/// Update threads with updated information about messages.
@@ -60,8 +60,11 @@ class PaginationParams extends Equatable {
/// ```
const PaginationParams({
this.limit = 10,
this.before = 10,
this.after = 10,
this.offset,
this.next,
this.idAround,
this.greaterThan,
this.greaterThanOrEqual,
this.lessThan,
@@ -78,12 +81,22 @@ class PaginationParams extends Equatable {
/// The amount of items requested from the APIs.
final int limit;
/// The amount of items requested before message ID from the APIs.
final int before;
/// The amount of items requested after message ID from the APIs.
final int after;
/// The offset of requesting items.
final int? offset;
/// A key used to paginate.
final String? next;
/// Message ID to fetch messages around
@JsonKey(name: 'id_around')
final String? idAround;
/// Filter on ids greater than the given value.
@JsonKey(name: 'id_gt')
final String? greaterThan;
@@ -106,7 +119,10 @@ class PaginationParams extends Equatable {
/// Creates a copy of [PaginationParams] with specified attributes overridden.
PaginationParams copyWith({
int? limit,
int? before,
int? after,
int? offset,
String? idAround,
String? next,
String? greaterThan,
String? greaterThanOrEqual,
@@ -115,7 +131,10 @@ class PaginationParams extends Equatable {
}) =>
PaginationParams(
limit: limit ?? this.limit,
before: before ?? this.before,
after: limit ?? this.after,
offset: offset ?? this.offset,
idAround: idAround ?? this.idAround,
next: next ?? this.next,
greaterThan: greaterThan ?? this.greaterThan,
greaterThanOrEqual: greaterThanOrEqual ?? this.greaterThanOrEqual,
@@ -126,8 +145,11 @@ class PaginationParams extends Equatable {
@override
List<Object?> get props => [
limit,
before,
after,
offset,
next,
idAround,
greaterThan,
greaterThanOrEqual,
lessThan,
@@ -21,8 +21,11 @@ Map<String, dynamic> _$SortOptionToJson<T>(SortOption<T> instance) =>
PaginationParams _$PaginationParamsFromJson(Map<String, dynamic> json) =>
PaginationParams(
limit: json['limit'] as int? ?? 10,
before: json['before'] as int? ?? 10,
after: json['after'] as int? ?? 10,
offset: json['offset'] as int?,
next: json['next'] as String?,
idAround: json['id_around'] as String?,
greaterThan: json['id_gt'] as String?,
greaterThanOrEqual: json['id_gte'] as String?,
lessThan: json['id_lt'] as String?,
@@ -32,6 +35,8 @@ PaginationParams _$PaginationParamsFromJson(Map<String, dynamic> json) =>
Map<String, dynamic> _$PaginationParamsToJson(PaginationParams instance) {
final val = <String, dynamic>{
'limit': instance.limit,
'before': instance.before,
'after': instance.after,
};
void writeNotNull(String key, dynamic value) {
@@ -42,6 +47,7 @@ Map<String, dynamic> _$PaginationParamsToJson(PaginationParams instance) {
writeNotNull('offset', instance.offset);
writeNotNull('next', instance.next);
writeNotNull('id_around', instance.idAround);
writeNotNull('id_gt', instance.greaterThan);
writeNotNull('id_gte', instance.greaterThanOrEqual);
writeNotNull('id_lt', instance.lessThan);
@@ -1,3 +1,4 @@
import 'package:equatable/equatable.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:stream_chat/src/core/models/user.dart';
@@ -5,7 +6,7 @@ part 'read.g.dart';
/// The class that defines a read event
@JsonSerializable()
class Read {
class Read extends Equatable {
/// Constructor used for json serialization
Read({
required this.lastRead,
@@ -39,4 +40,11 @@ class Read {
user: user ?? this.user,
unreadMessages: unreadMessages ?? this.unreadMessages,
);
@override
List<Object?> get props => [
lastRead,
user,
unreadMessages,
];
}
@@ -179,5 +179,14 @@ class User extends Equatable {
);
@override
List<Object?> get props => [id, role];
List<Object?> get props => [
id,
role,
lastActive,
online,
extraData,
banned,
teams,
language,
];
}
@@ -121,7 +121,8 @@ class WebSocket with TimerHelper {
_logger?.info('Closing connection with $baseUrl');
if (_webSocketChannel != null) {
_unsubscribeFromWebSocketChannel();
_webSocketChannel?.sink.close(status.goingAway);
_webSocketChannel?.sink
.close(_manuallyClosed ? status.normalClosure : status.goingAway);
_webSocketChannel = null;
}
}
@@ -70,13 +70,19 @@ void main() {
expect(
newReaction.extraData, {'updated_at': '2020-01-28T22:17:31.108742Z'});
final newUserCreateTime = DateTime.now();
newReaction = reaction.copyWith(
type: 'lol',
createdAt: DateTime.parse('2021-01-28T22:17:31.108742Z'),
extraData: {},
messageId: 'test',
score: 2,
user: User(id: 'test'),
user: User(
id: 'test',
createdAt: newUserCreateTime,
updatedAt: newUserCreateTime,
),
userId: 'test',
);
@@ -88,12 +94,21 @@ void main() {
expect(newReaction.extraData, {});
expect(newReaction.messageId, 'test');
expect(newReaction.score, 2);
expect(newReaction.user, User(id: 'test'));
expect(
newReaction.user,
User(
id: 'test',
createdAt: newUserCreateTime,
updatedAt: newUserCreateTime,
),
);
expect(newReaction.userId, 'test');
});
test('merge', () {
final reaction = Reaction.fromJson(jsonFixture('reaction.json'));
final newUserCreateTime = DateTime.now();
final newReaction = reaction.merge(
Reaction(
type: 'lol',
@@ -101,7 +116,11 @@ void main() {
extraData: {},
messageId: 'test',
score: 2,
user: User(id: 'test'),
user: User(
id: 'test',
createdAt: newUserCreateTime,
updatedAt: newUserCreateTime,
),
userId: 'test',
),
);
@@ -114,7 +133,14 @@ void main() {
expect(newReaction.extraData, {});
expect(newReaction.messageId, 'test');
expect(newReaction.score, 2);
expect(newReaction.user, User(id: 'test'));
expect(
newReaction.user,
User(
id: 'test',
createdAt: newUserCreateTime,
updatedAt: newUserCreateTime,
),
);
expect(newReaction.userId, 'test');
});
});