onIdentityChanged method
- UserId me
override
Handles identity changes to the provided UserId.
Implementation
@override
void onIdentityChanged(UserId me) {
super.onIdentityChanged(me);
Log.debug(
'onIdentityChanged($me) -> ${me.isLocal}',
'$runtimeType($hashCode)',
);
paginated.clear();
archived.clear();
chats.forEach((_, v) => v.dispose());
chats.clear();
_subscriptions.forEach((_, v) => v.cancel());
_subscriptions.clear();
_pagination?.dispose();
_pagination = null;
_localPagination?.dispose();
_localPagination = null;
_remoteSubscription?.close(immediate: true);
_remoteSubscription = null;
_remoteArchiveSubscription?.close(immediate: true);
_remoteArchiveSubscription = null;
_favoriteChatsSubscription?.close(immediate: true);
_favoriteChatsSubscription = null;
_paginationSubscription?.cancel();
_paginationSubscription = null;
status.value = RxStatus.loading();
Log.debug(
'onIdentityChanged() -> status is `loading`',
'$runtimeType($hashCode)',
);
// Set the initial values to local ones, however those will be redefined
// during `_ensurePagination()` method, which invokes `_initSupport()` and
// `_initMonolog()`.
monolog = ChatId.local(me);
Log.debug('5 monolog = $monolog', '$runtimeType-for-E2E');
support = ChatId.local(_supportId);
if (!me.isLocal) {
_monologGuard.synchronized(() async {
if (isClosed || this.me != me) {
return;
}
final monologMixin = await _graphQlProvider.getMonolog();
if (isClosed || this.me != me) {
return;
}
Log.debug('getMonolog() -> $monologMixin', '$runtimeType');
monolog = monologMixin?.id ?? monolog;
Log.debug('6 monolog = $monolog', '$runtimeType-for-E2E');
final supportMixin = await _graphQlProvider.getDialog(
UserId(Config.supportId),
);
if (isClosed || this.me != me) {
return;
}
Log.debug('getDialog(supportId) -> $supportMixin', '$runtimeType');
support = supportMixin?.id ?? support;
}, timeout: const Duration(minutes: 1));
}
// Popup shouldn't listen to recent chats remote updates, as it's happening
// inside single [Chat].
if (!WebUtils.isPopup && _remoteSubscription == null && !me.isLocal) {
_initRemoteSubscription();
_initFavoriteSubscription();
_initArchiveSubscription();
}
_ensurePagination();
}