fix: persistence (#329)

* fix(llc): Save original passed persistence for client reconnection.

Signed-off-by: Sahil Kumar <[email protected]>

* fix(persistence): Check for empty channels before applying offset

Signed-off-by: Sahil Kumar <[email protected]>

* fix(llc): Remove debug logs

Signed-off-by: Sahil Kumar <[email protected]>

* fix(persistence): Reset isolate on successful disconnect

Signed-off-by: Sahil Kumar <[email protected]>

* use mutexes in persistence client

* fix(persistence): use `super.updateChannelStates`

Signed-off-by: Sahil Kumar <[email protected]>

* fix(persistence): fix database multiple times creation.

Signed-off-by: Sahil Kumar <[email protected]>

Co-authored-by: Sahil Kumar <[email protected]>
This commit is contained in:
Salvatore Giordano
2021-03-12 14:16:41 +01:00
committed by GitHub
co-authored by Sahil Kumar
parent ca1f70948e
commit 9952265109
11 changed files with 332 additions and 154 deletions
@@ -7,11 +7,11 @@ import 'package:logging/logging.dart';
import 'package:rxdart/rxdart.dart';
import 'package:stream_chat/src/api/retry_queue.dart';
import 'package:stream_chat/src/event_type.dart';
import 'package:stream_chat/src/extensions/rate_limit.dart';
import 'package:stream_chat/src/models/attachment_file.dart';
import 'package:stream_chat/src/models/channel_state.dart';
import 'package:stream_chat/src/models/user.dart';
import 'package:stream_chat/stream_chat.dart';
import 'package:stream_chat/src/extensions/rate_limit.dart';
/// This a the class that manages a specific channel.
class Channel {
@@ -1209,9 +1209,9 @@ class ChannelClientState {
ChannelClientState(
this._channel,
ChannelState channelState,
) : _debouncedUpdatePersistenceChannelState = _channel
?._client?.chatPersistenceClient?.updateChannelState
?.debounced(const Duration(seconds: 1)) {
) : _debouncedUpdatePersistenceChannelState = ((ChannelState state) {
_channel?._client?.chatPersistenceClient?.updateChannelState(state);
}).debounced(const Duration(seconds: 1)) {
retryQueue = RetryQueue(
channel: _channel,
logger: Logger('RETRY QUEUE ${_channel.cid}'),