Merge branches 'develop' and 'ref/segregate-api-layer' of https://github.com/GetStream/stream-chat-flutter into ref/segregate-api-layer

 Conflicts:
	packages/stream_chat/lib/src/api/channel.dart
	packages/stream_chat/lib/src/client.dart
	packages/stream_chat_persistence/lib/src/db/moor_chat_database.g.dart
This commit is contained in:
Sahil Kumar
2021-05-27 20:07:11 +05:30
44 changed files with 753 additions and 188 deletions
+6
View File
@@ -1,3 +1,9 @@
## 2.0.0-nullsafety.2
- Added new `Filter.raw` constructor
- Changed extraData
- Minor fixes
## 2.0.0-nullsafety.1
- Migrate this package to null safety
+150
View File
@@ -0,0 +1,150 @@
analyzer:
enable-experiment:
- extension-methods
exclude:
- lib/**/*.g.dart
- example/**
- lib/src/emoji
- lib/**/*.freezed.dart
- test/**
linter:
rules:
# these rules are documented on and in the same order as
# the Dart Lint rules page to make maintenance easier
# https://github.com/dart-lang/linter/blob/master/example/all.yaml
- always_use_package_imports
- avoid_empty_else
- avoid_relative_lib_imports
- avoid_slow_async_io
- avoid_types_as_parameter_names
- cancel_subscriptions
- close_sinks
- control_flow_in_finally
- empty_statements
- hash_and_equals
- invariant_booleans
- iterable_contains_unrelated_type
- list_remove_unrelated_type
- literal_only_boolean_expressions
- no_adjacent_strings_in_list
- no_duplicate_case_values
- no_logic_in_create_state
- prefer_void_to_null
- test_types_in_equals
- throw_in_finally
- unnecessary_statements
- unrelated_type_equality_checks
- omit_local_variable_types
- use_key_in_widget_constructors
- valid_regexps
- always_declare_return_types
- always_require_non_null_named_parameters
- annotate_overrides
- avoid_bool_literals_in_conditional_expressions
- avoid_catching_errors
- avoid_init_to_null
- avoid_null_checks_in_equality_operators
- avoid_positional_boolean_parameters
- avoid_private_typedef_functions
- avoid_redundant_argument_values
- avoid_return_types_on_setters
- avoid_returning_null_for_void
- avoid_shadowing_type_parameters
- avoid_single_cascade_in_expression_statements
- avoid_unnecessary_containers
- avoid_unused_constructor_parameters
- await_only_futures
- camel_case_extensions
- camel_case_types
- cascade_invocations
- constant_identifier_names
- curly_braces_in_flow_control_structures
- directives_ordering
- empty_catches
- empty_constructor_bodies
- exhaustive_cases
- file_names
- implementation_imports
- join_return_with_assignment
- leading_newlines_in_multiline_strings
- library_names
- library_prefixes
- lines_longer_than_80_chars
- missing_whitespace_between_adjacent_strings
- non_constant_identifier_names
- null_closures
- one_member_abstracts
- only_throw_errors
- package_api_docs
- package_prefixed_library_names
- parameter_assignments
- prefer_adjacent_string_concatenation
- prefer_asserts_in_initializer_lists
- prefer_asserts_with_message
- prefer_collection_literals
- prefer_conditional_assignment
- prefer_const_constructors
- prefer_const_constructors_in_immutables
- prefer_const_declarations
- prefer_const_literals_to_create_immutables
- prefer_constructors_over_static_methods
- prefer_contains
- prefer_equal_for_default_values
- prefer_expression_function_bodies
- prefer_final_fields
- prefer_final_in_for_each
- prefer_final_locals
- prefer_function_declarations_over_variables
- prefer_generic_function_type_aliases
- prefer_if_elements_to_conditional_expressions
- prefer_if_null_operators
- prefer_initializing_formals
- prefer_inlined_adds
- prefer_int_literals
- prefer_interpolation_to_compose_strings
- prefer_is_empty
- prefer_is_not_empty
- prefer_is_not_operator
- prefer_null_aware_operators
- prefer_single_quotes
- prefer_spread_collections
- prefer_typing_uninitialized_variables
- provide_deprecation_message
- public_member_api_docs
- recursive_getters
- sized_box_for_whitespace
- slash_for_doc_comments
- sort_child_properties_last
- sort_constructors_first
- sort_unnamed_constructors_first
- type_annotate_public_apis
- type_init_formals
- unnecessary_await_in_return
- unnecessary_brace_in_string_interps
- unnecessary_const
- unnecessary_getters_setters
- unnecessary_lambdas
- unnecessary_new
- unnecessary_null_aware_assignments
- unnecessary_null_in_if_null_operators
- unnecessary_nullable_for_final_variable_declarations
- unnecessary_parenthesis
- unnecessary_raw_strings
- unnecessary_string_escapes
- unnecessary_string_interpolations
- unnecessary_this
- use_is_even_rather_than_modulo
- use_late_for_private_fields_and_variables
- use_rethrow_when_possible
- use_setters_to_change_properties
- use_to_and_as_if_applicable
- package_names
- sort_pub_dependencies
- cast_nullable_to_non_nullable
- unnecessary_null_checks
- tighten_type_of_initializing_formals
- null_check_on_nullable_type_parameter
@@ -1327,7 +1327,7 @@ class ChannelClientState {
/// This flag should be managed by UI sdks.
/// When false, any new message (received by WebSocket event
/// - [EventType.messageNew]) will not be pushed on to message list.
bool get isUpToDate => _isUpToDateController.value ?? true;
bool get isUpToDate => _isUpToDateController.value;
set isUpToDate(bool isUpToDate) => _isUpToDateController.add(isUpToDate);
@@ -1428,7 +1428,7 @@ class ChannelClientState {
}
if (_countMessageAsUnread(message)) {
_unreadCountController.add(_unreadCountController.value! + 1);
_unreadCountController.add(_unreadCountController.value + 1);
}
}));
}
@@ -1666,13 +1666,13 @@ class ChannelClientState {
a.createdAt.compareTo(b.createdAt);
/// The channel state related to this client
ChannelState get _channelState => _channelStateController.value!;
ChannelState get _channelState => _channelStateController.value;
/// The channel state related to this client as a stream
Stream<ChannelState> get channelStateStream => _channelStateController.stream;
/// The channel state related to this client
ChannelState get channelState => _channelStateController.value!;
ChannelState get channelState => _channelStateController.value;
late BehaviorSubject<ChannelState> _channelStateController;
final Debounce _debouncedUpdatePersistenceChannelState;
@@ -1684,7 +1684,7 @@ class ChannelClientState {
/// The channel threads related to this channel
Map<String, List<Message>> get threads =>
_threadsController.value!.map((key, value) => MapEntry(key, value));
_threadsController.value.map((key, value) => MapEntry(key, value));
/// The channel threads related to this channel as a stream
Stream<Map<String, List<Message>>> get threadsStream =>
@@ -1701,7 +1701,7 @@ class ChannelClientState {
}
/// Channel related typing users last value
List<User> get typingEvents => _typingEventsController.value!;
List<User> get typingEvents => _typingEventsController.value;
/// Channel related typing users stream
Stream<List<User>> get typingEventsStream => _typingEventsController.stream;
+9 -6
View File
@@ -1248,7 +1248,10 @@ class StreamChatClient {
);
}
return updateMessage(
message.copyWith(pinned: true, pinExpires: pinExpires),
message.copyWith(
pinned: true,
pinExpires: pinExpires,
),
);
}
@@ -1388,25 +1391,25 @@ class ClientState {
void updateUser(User? user) => updateUsers([user]);
/// The current user
OwnUser? get user => _userController.value;
OwnUser? get user => _userController.valueOrNull;
/// The current user as a stream
Stream<OwnUser?> get userStream => _userController.stream;
/// The current user
Map<String, User> get users => _usersController.value!;
Map<String, User> get users => _usersController.value;
/// The current user as a stream
Stream<Map<String, User>> get usersStream => _usersController.stream;
/// The current unread channels count
int? get unreadChannels => _unreadChannelsController.value;
int? get unreadChannels => _unreadChannelsController.valueOrNull;
/// The current unread channels count as a stream
Stream<int?> get unreadChannelsStream => _unreadChannelsController.stream;
/// The current total unread messages count
int? get totalUnreadCount => _totalUnreadCountController.value;
int? get totalUnreadCount => _totalUnreadCountController.valueOrNull;
/// The current total unread messages count as a stream
Stream<int?> get totalUnreadCountStream => _totalUnreadCountController.stream;
@@ -1415,7 +1418,7 @@ class ClientState {
Stream<Map<String, Channel>> get channelsStream => _channelsController.stream;
/// The current list of channels in memory
Map<String, Channel> get channels => _channelsController.value!;
Map<String, Channel> get channels => _channelsController.value;
set channels(Map<String, Channel> channelMap) {
final newChannels = {...channels, ...channelMap};
+1 -1
View File
@@ -3,4 +3,4 @@ import 'package:stream_chat/src/client.dart';
/// Current package version
/// Used in [StreamChatClient] to build the `x-stream-client` header
// ignore: constant_identifier_names
const PACKAGE_VERSION = '2.0.0-nullsafety.1';
const PACKAGE_VERSION = '2.0.0-nullsafety.2';
+2 -2
View File
@@ -1,7 +1,7 @@
name: stream_chat
homepage: https://getstream.io/
description: The official Dart client for Stream Chat, a service for building chat applications.
version: 2.0.0-nullsafety.1
version: 2.0.0-nullsafety.2
repository: https://github.com/GetStream/stream-chat-flutter
issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues
@@ -20,7 +20,7 @@ dependencies:
logging: ^1.0.1
meta: ^1.3.0
mime: ^1.0.0
rxdart: ^0.26.0
rxdart: ^0.27.0
uuid: ^3.0.4
web_socket_channel: ^2.0.0
@@ -449,6 +449,51 @@ void main() {
.called(1);
});
test('should be pinned successfully with null timeout', () async {
final mockDio = MockDio();
when(() => mockDio.options).thenReturn(BaseOptions());
when(() => mockDio.interceptors).thenReturn(Interceptors());
final client = StreamChatClient(
'api-key',
httpClient: mockDio,
tokenProvider: (_) async => '',
);
final channelClient = client.channel('messaging', id: 'testid');
final message = Message(text: 'Hello', id: 'test');
when(() => mockDio.post<String>(
any(),
data: any(named: 'data'),
)).thenAnswer((_) async => Response(
data: jsonEncode(ChannelState()),
statusCode: 200,
requestOptions: FakeRequestOptions(),
));
await channelClient.watch();
when(
() => mockDio.post<String>(
'/messages/${message.id}',
data: anything,
),
).thenAnswer(
(_) async => Response(
data: jsonEncode({'message': message}),
statusCode: 200,
requestOptions: FakeRequestOptions(),
),
);
await channelClient.pinMessage(message);
verify(() =>
mockDio.post<String>('/messages/${message.id}', data: anything))
.called(1);
});
test('should be unpinned successfully', () async {
final mockDio = MockDio();
@@ -1112,6 +1112,28 @@ void main() {
data: {'message': anything})).called(1);
});
test('should complete successfully with a null value', () async {
final message = Message(text: 'Hello');
when(
() => mockDio.post<String>(
'/messages/${message.id}',
data: anything,
),
).thenAnswer(
(_) async => Response(
data: jsonEncode({'message': message}),
statusCode: 200,
requestOptions: FakeRequestOptions(),
),
);
await client.pinMessage(message);
verify(() => mockDio.post<String>('/messages/${message.id}',
data: {'message': anything})).called(1);
});
test('should unpin message successfully', () async {
final message = Message(text: 'Hello');