Merge branch 'develop' into ISSUE-1399/AddingCustomLineForTitleUrl
This commit is contained in:
@@ -1,3 +1,14 @@
|
||||
## Upcoming
|
||||
|
||||
🐞 Fixed
|
||||
|
||||
- Fixed streamWatchers. Before it was always new, now it is possible to follow the watchers of a channel.
|
||||
## Upcoming
|
||||
|
||||
🔄 Changed
|
||||
|
||||
- Cancelling a attachment upload now removes the attachment from the message.
|
||||
|
||||
## 5.3.0
|
||||
|
||||
🔄 Changed
|
||||
|
||||
@@ -463,12 +463,19 @@ class Channel {
|
||||
|
||||
client.logger.info('Found ${attachments.length} attachments');
|
||||
|
||||
void updateAttachment(Attachment attachment) {
|
||||
void updateAttachment(Attachment attachment, {bool remove = false}) {
|
||||
final index = message!.attachments.indexWhere(
|
||||
(it) => it.id == attachment.id,
|
||||
);
|
||||
if (index != -1) {
|
||||
final newAttachments = [...message!.attachments]..[index] = attachment;
|
||||
// update or remove attachment from message.
|
||||
final List<Attachment> newAttachments;
|
||||
if (remove) {
|
||||
newAttachments = [...message!.attachments]..removeAt(index);
|
||||
} else {
|
||||
newAttachments = [...message!.attachments]..[index] = attachment;
|
||||
}
|
||||
|
||||
final updatedMessage = message!.copyWith(attachments: newAttachments);
|
||||
state?.updateMessage(updatedMessage);
|
||||
// updating original message for next iteration
|
||||
@@ -533,6 +540,14 @@ class Channel {
|
||||
);
|
||||
}
|
||||
}).catchError((e, stk) {
|
||||
if (e is StreamChatNetworkError && e.isRequestCancelledError) {
|
||||
client.logger.info('Attachment ${it.id} upload cancelled');
|
||||
|
||||
// remove attachment from message if cancelled.
|
||||
updateAttachment(it, remove: true);
|
||||
return;
|
||||
}
|
||||
|
||||
client.logger.severe('error uploading the attachment', e, stk);
|
||||
updateAttachment(
|
||||
it.copyWith(uploadState: UploadState.failed(error: e.toString())),
|
||||
@@ -1613,6 +1628,10 @@ class ChannelClientState {
|
||||
|
||||
_listenMemberUnbanned();
|
||||
|
||||
_listenUserStartWatching();
|
||||
|
||||
_listenUserStopWatching();
|
||||
|
||||
_startCleaningStaleTypingEvents();
|
||||
|
||||
_startCleaningStalePinnedMessages();
|
||||
@@ -1754,6 +1773,39 @@ class ChannelClientState {
|
||||
));
|
||||
}
|
||||
|
||||
void _listenUserStartWatching() {
|
||||
_subscriptions.add(
|
||||
_channel.on(EventType.userWatchingStart).listen((event) {
|
||||
final watcher = event.user;
|
||||
if (watcher != null) {
|
||||
final existingWatchers = channelState.watchers;
|
||||
updateChannelState(channelState.copyWith(
|
||||
watchers: [
|
||||
...?existingWatchers,
|
||||
watcher,
|
||||
],
|
||||
));
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
void _listenUserStopWatching() {
|
||||
_subscriptions.add(
|
||||
_channel.on(EventType.userWatchingStop).listen((event) {
|
||||
final watcher = event.user;
|
||||
if (watcher != null) {
|
||||
final existingWatchers = channelState.watchers;
|
||||
updateChannelState(channelState.copyWith(
|
||||
watchers: existingWatchers
|
||||
?.where((user) => user.id != watcher.id)
|
||||
.toList(growable: false),
|
||||
));
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
void _listenMemberUnbanned() {
|
||||
_subscriptions.add(_channel
|
||||
.on(EventType.userUnbanned)
|
||||
@@ -2083,7 +2135,7 @@ class ChannelClientState {
|
||||
channelStateStream.map((cs) => cs.watchers),
|
||||
_channel.client.state.usersStream,
|
||||
(watchers, users) => watchers!.map((e) => users[e.id] ?? e).toList(),
|
||||
);
|
||||
).distinct(const ListEquality().equals);
|
||||
|
||||
/// Channel member for the current user.
|
||||
Member? get currentUserMember => members.firstWhereOrNull(
|
||||
|
||||
@@ -74,6 +74,7 @@ class StreamChatNetworkError extends StreamChatError {
|
||||
ChatErrorCode errorCode, {
|
||||
int? statusCode,
|
||||
this.data,
|
||||
this.isRequestCancelledError = false,
|
||||
}) : code = errorCode.code,
|
||||
statusCode = statusCode ?? data?.statusCode,
|
||||
super(errorCode.message);
|
||||
@@ -84,6 +85,7 @@ class StreamChatNetworkError extends StreamChatError {
|
||||
required String message,
|
||||
this.statusCode,
|
||||
this.data,
|
||||
this.isRequestCancelledError = false,
|
||||
}) : super(message);
|
||||
|
||||
///
|
||||
@@ -100,6 +102,7 @@ class StreamChatNetworkError extends StreamChatError {
|
||||
errorResponse?.message ?? response?.statusMessage ?? error.message,
|
||||
statusCode: errorResponse?.statusCode ?? response?.statusCode,
|
||||
data: errorResponse,
|
||||
isRequestCancelledError: error.type == DioErrorType.cancel,
|
||||
)..stackTrace = error.stackTrace;
|
||||
}
|
||||
|
||||
@@ -112,6 +115,9 @@ class StreamChatNetworkError extends StreamChatError {
|
||||
/// Response body. please refer to [ErrorResponse].
|
||||
final ErrorResponse? data;
|
||||
|
||||
/// True, in case the error is due to a cancelled network request.
|
||||
final bool isRequestCancelledError;
|
||||
|
||||
StackTrace? _stackTrace;
|
||||
|
||||
///
|
||||
|
||||
@@ -36,6 +36,12 @@ class EventType {
|
||||
/// Event sent when updating a message
|
||||
static const String messageUpdated = 'message.updated';
|
||||
|
||||
/// Event sent when a user starts watching a channel
|
||||
static const String userWatchingStart = 'user.watching.start';
|
||||
|
||||
/// Event sent when a user stops watching a channel
|
||||
static const String userWatchingStop = 'user.watching.stop';
|
||||
|
||||
/// Event sent when reading a message
|
||||
static const String messageRead = 'message.read';
|
||||
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
## 5.4.0
|
||||
## Upcoming
|
||||
|
||||
✅ Added
|
||||
|
||||
✅ Added
|
||||
- Now it is possible to customize the max lines of the title of a url attachment. Before it was always 1 line.
|
||||
|
||||
🔄 Changed
|
||||
|
||||
- Updated `share_plus` dependency to `^6.3.0`
|
||||
|
||||
## 5.3.0
|
||||
|
||||
🔄 Changed
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:file_selector/file_selector.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
@@ -37,7 +37,7 @@ dependencies:
|
||||
photo_manager: ^2.5.2
|
||||
photo_view: ^0.14.0
|
||||
rxdart: ^0.27.0
|
||||
share_plus: ^4.5.0
|
||||
share_plus: ^6.3.0
|
||||
shimmer: ^2.0.0
|
||||
stream_chat_flutter_core: ^5.3.0
|
||||
synchronized: ^3.0.0
|
||||
|
||||
Reference in New Issue
Block a user