update llc repo

This commit is contained in:
Salvatore Giordano
2021-01-14 12:24:16 +01:00
parent 9544208cb3
commit be75bf3fb3
6 changed files with 50 additions and 26 deletions
@@ -428,6 +428,8 @@ class Channel {
/// Mark all channel messages as read
Future<EmptyResponse> markRead() async {
_checkInitialized();
client.state.totalUnreadCount =
max(0, (client.state.totalUnreadCount ?? 0) - (state.unreadCount ?? 0));
state._unreadCountController.add(0);
final response = await _client.post('$_channelURL/read', data: {});
return _client.decode(response.data, EmptyResponse.fromJson);
+16 -3
View File
@@ -565,8 +565,15 @@ class Client {
await _connectCompleter.future;
}
if (wsConnectionStatus.value != ConnectionStatus.connected) {
throw Exception(
'You cannot use queryChannels without an active connection. Call setUser to connect the client.');
final errorMessage =
'You cannot use queryChannels without an active connection. Please call setUser to connect the client.';
if (persistenceEnabled) {
logger.warning(
'$errorMessage\nTrying to retrieve channels from the offline storage.');
onlyOffline = true;
} else {
throw Exception(errorMessage);
}
}
}
@@ -843,7 +850,8 @@ class Client {
String get _authType => _anonymous ? 'anonymous' : 'jwt';
// TODO: get the right version of the lib from the build toolchain
String get _userAgent => 'stream-chat-dart-client-$PACKAGE_VERSION';
String get _userAgent =>
'stream-chat-dart-client-${PACKAGE_VERSION.split('+')[0]}';
Map<String, String> get _commonQueryParams => {
'user_id': state.user?.id,
@@ -1281,6 +1289,11 @@ class ClientState {
_listenUserUpdated();
}
/// Used internally for optimistic update of unread count
set totalUnreadCount(int unreadCount) {
_totalUnreadCountController?.add(unreadCount ?? 0);
}
void _listenChannelHidden() {
_subscriptions.add(_client.on(EventType.channelHidden).listen((event) {
_client._offlineStorage?.deleteChannels([event.cid]);