refactor(llc, core, ui): Deprecate .user, .userStream in favor of .currentUser, .currentUserStream
Signed-off-by: xsahil03x <[email protected]>
This commit is contained in:
@@ -3,6 +3,11 @@
|
||||
✅ Added
|
||||
- Added `MessageListCore.paginationLimit`
|
||||
|
||||
🔄 Changed
|
||||
|
||||
- `StreamChatCore.of(context).user` is now deprecated in favor of `StreamChatCore.of(context).currentUser`.
|
||||
- `StreamChatCore.of(context).userStream` is now deprecated in favor of `StreamChatCore.of(context).currentUserStream`.
|
||||
|
||||
## 2.0.0
|
||||
|
||||
🛑️ Breaking Changes from `1.5.3`
|
||||
|
||||
@@ -87,7 +87,7 @@ class HomeScreen extends StatelessWidget {
|
||||
filter: Filter.and([
|
||||
Filter.equal('type', 'messaging'),
|
||||
Filter.in_('members', [
|
||||
StreamChatCore.of(context).user!.id,
|
||||
StreamChatCore.of(context).currentUser!.id,
|
||||
])
|
||||
]),
|
||||
emptyBuilder: (BuildContext context) => const Center(
|
||||
@@ -336,7 +336,7 @@ class _MessageScreenState extends State<MessageScreen> {
|
||||
/// below, we add two simple extensions to the [StreamChatClient] and [Channel].
|
||||
extension on StreamChatClient {
|
||||
/// Fetches the current user id.
|
||||
String get uid => state.user!.id;
|
||||
String get uid => state.currentUser!.id;
|
||||
}
|
||||
|
||||
extension on Channel {
|
||||
|
||||
@@ -116,7 +116,7 @@ class MessageListCoreState extends State<MessageListCore> {
|
||||
|
||||
bool get _isThreadConversation => widget.parentMessage != null;
|
||||
|
||||
OwnUser? get _currentUser => _streamChannel!.channel.client.state.user;
|
||||
OwnUser? get _currentUser => _streamChannel!.channel.client.state.currentUser;
|
||||
|
||||
var _messages = <Message>[];
|
||||
|
||||
|
||||
@@ -98,10 +98,20 @@ class StreamChatCoreState extends State<StreamChatCore>
|
||||
Widget build(BuildContext context) => widget.child;
|
||||
|
||||
/// The current user
|
||||
User? get user => client.state.user;
|
||||
@Deprecated('Use `.currentUser` instead, Will be removed in future releases')
|
||||
User? get user => client.state.currentUser;
|
||||
|
||||
/// The current user as a stream
|
||||
Stream<User?> get userStream => client.state.userStream;
|
||||
@Deprecated(
|
||||
'Use `.currentUserStream` instead, Will be removed in future releases',
|
||||
)
|
||||
Stream<User?> get userStream => client.state.currentUserStream;
|
||||
|
||||
/// The current user
|
||||
User? get currentUser => client.state.currentUser;
|
||||
|
||||
/// The current user as a stream
|
||||
Stream<User?> get currentUserStream => client.state.currentUserStream;
|
||||
|
||||
StreamSubscription<ConnectivityResult>? _connectivitySubscription;
|
||||
|
||||
@@ -126,7 +136,7 @@ class StreamChatCoreState extends State<StreamChatCore>
|
||||
if (!_isInForeground) return;
|
||||
if (_isConnectionAvailable) {
|
||||
if (client.wsConnectionStatus == ConnectionStatus.disconnected &&
|
||||
user != null) {
|
||||
currentUser != null) {
|
||||
client.openConnection();
|
||||
}
|
||||
} else {
|
||||
@@ -163,7 +173,7 @@ class StreamChatCoreState extends State<StreamChatCore>
|
||||
AppLifecycleState.resumed,
|
||||
AppLifecycleState.inactive,
|
||||
].contains(state);
|
||||
if (user != null) {
|
||||
if (currentUser != null) {
|
||||
if (_isInForeground) {
|
||||
_onForeground();
|
||||
} else {
|
||||
|
||||
@@ -451,7 +451,7 @@ void main() {
|
||||
expect(find.byKey(streamChatCoreKey), findsOneWidget);
|
||||
expect(find.byKey(childKey), findsOneWidget);
|
||||
|
||||
when(() => mockClient.state.userStream)
|
||||
when(() => mockClient.state.currentUserStream)
|
||||
.thenAnswer((_) => userController.stream);
|
||||
|
||||
final streamChatCoreState = tester.state<StreamChatCoreState>(
|
||||
@@ -462,7 +462,7 @@ void main() {
|
||||
userController.add(ownUser);
|
||||
|
||||
await expectLater(
|
||||
streamChatCoreState.userStream,
|
||||
streamChatCoreState.currentUserStream,
|
||||
emits(ownUser),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user