Merge pull request #1165 from GetStream/feat/channel-membership
feat(llc): add support for channel.membership
This commit is contained in:
@@ -159,7 +159,6 @@ linter:
|
|||||||
- avoid_escaping_inner_quotes
|
- avoid_escaping_inner_quotes
|
||||||
- unnecessary_overrides
|
- unnecessary_overrides
|
||||||
- prefer_null_aware_method_calls
|
- prefer_null_aware_method_calls
|
||||||
- prefer_null_aware_operators
|
|
||||||
- use_named_constants
|
- use_named_constants
|
||||||
- use_raw_strings
|
- use_raw_strings
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
- Added `PaginationParams.createdAtBeforeOrEqual` for message pagination.
|
- Added `PaginationParams.createdAtBeforeOrEqual` for message pagination.
|
||||||
- Added `PaginationParams.createdAtBefore` for message pagination.
|
- Added `PaginationParams.createdAtBefore` for message pagination.
|
||||||
- Added `PaginationParams.createdAtAround` for message pagination.
|
- Added `PaginationParams.createdAtAround` for message pagination.
|
||||||
|
- Added support for `channel.membership` and `channel.membershipStream` in `Channel`.
|
||||||
|
|
||||||
🔄 Changed
|
🔄 Changed
|
||||||
|
|
||||||
|
|||||||
@@ -171,6 +171,18 @@ class Channel {
|
|||||||
return state!.channelStateStream.map((cs) => cs.channel?.config);
|
return state!.channelStateStream.map((cs) => cs.channel?.config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Relationship of the current user to this channel.
|
||||||
|
Member? get membership {
|
||||||
|
_checkInitialized();
|
||||||
|
return state!._channelState.membership;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Relationship of the current user to this channel as a stream.
|
||||||
|
Stream<Member?> get membershipStream {
|
||||||
|
_checkInitialized();
|
||||||
|
return state!.channelStateStream.map((cs) => cs.membership);
|
||||||
|
}
|
||||||
|
|
||||||
/// Channel user creator.
|
/// Channel user creator.
|
||||||
User? get createdBy {
|
User? get createdBy {
|
||||||
_checkInitialized();
|
_checkInitialized();
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ part of 'attachment_file.dart';
|
|||||||
T _$identity<T>(T value) => value;
|
T _$identity<T>(T value) => value;
|
||||||
|
|
||||||
final _privateConstructorUsedError = UnsupportedError(
|
final _privateConstructorUsedError = UnsupportedError(
|
||||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
|
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
|
||||||
|
|
||||||
UploadState _$UploadStateFromJson(Map<String, dynamic> json) {
|
UploadState _$UploadStateFromJson(Map<String, dynamic> json) {
|
||||||
switch (json['runtimeType']) {
|
switch (json['runtimeType']) {
|
||||||
@@ -31,39 +31,6 @@ UploadState _$UploadStateFromJson(Map<String, dynamic> json) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class _$UploadStateTearOff {
|
|
||||||
const _$UploadStateTearOff();
|
|
||||||
|
|
||||||
Preparing preparing() {
|
|
||||||
return const Preparing();
|
|
||||||
}
|
|
||||||
|
|
||||||
InProgress inProgress({required int uploaded, required int total}) {
|
|
||||||
return InProgress(
|
|
||||||
uploaded: uploaded,
|
|
||||||
total: total,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Success success() {
|
|
||||||
return const Success();
|
|
||||||
}
|
|
||||||
|
|
||||||
Failed failed({required String error}) {
|
|
||||||
return Failed(
|
|
||||||
error: error,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
UploadState fromJson(Map<String, Object?> json) {
|
|
||||||
return UploadState.fromJson(json);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
const $UploadState = _$UploadStateTearOff();
|
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$UploadState {
|
mixin _$UploadState {
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
@@ -156,7 +123,7 @@ class __$$PreparingCopyWithImpl<$Res> extends _$UploadStateCopyWithImpl<$Res>
|
|||||||
/// @nodoc
|
/// @nodoc
|
||||||
@JsonSerializable()
|
@JsonSerializable()
|
||||||
class _$Preparing implements Preparing {
|
class _$Preparing implements Preparing {
|
||||||
const _$Preparing({String? $type}) : $type = $type ?? 'preparing';
|
const _$Preparing({final String? $type}) : $type = $type ?? 'preparing';
|
||||||
|
|
||||||
factory _$Preparing.fromJson(Map<String, dynamic> json) =>
|
factory _$Preparing.fromJson(Map<String, dynamic> json) =>
|
||||||
_$$PreparingFromJson(json);
|
_$$PreparingFromJson(json);
|
||||||
@@ -175,6 +142,7 @@ class _$Preparing implements Preparing {
|
|||||||
(other.runtimeType == runtimeType && other is _$Preparing);
|
(other.runtimeType == runtimeType && other is _$Preparing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
@override
|
@override
|
||||||
int get hashCode => runtimeType.hashCode;
|
int get hashCode => runtimeType.hashCode;
|
||||||
|
|
||||||
@@ -304,7 +272,7 @@ class __$$InProgressCopyWithImpl<$Res> extends _$UploadStateCopyWithImpl<$Res>
|
|||||||
@JsonSerializable()
|
@JsonSerializable()
|
||||||
class _$InProgress implements InProgress {
|
class _$InProgress implements InProgress {
|
||||||
const _$InProgress(
|
const _$InProgress(
|
||||||
{required this.uploaded, required this.total, String? $type})
|
{required this.uploaded, required this.total, final String? $type})
|
||||||
: $type = $type ?? 'inProgress';
|
: $type = $type ?? 'inProgress';
|
||||||
|
|
||||||
factory _$InProgress.fromJson(Map<String, dynamic> json) =>
|
factory _$InProgress.fromJson(Map<String, dynamic> json) =>
|
||||||
@@ -332,6 +300,7 @@ class _$InProgress implements InProgress {
|
|||||||
const DeepCollectionEquality().equals(other.total, total));
|
const DeepCollectionEquality().equals(other.total, total));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(
|
int get hashCode => Object.hash(
|
||||||
runtimeType,
|
runtimeType,
|
||||||
@@ -424,14 +393,14 @@ class _$InProgress implements InProgress {
|
|||||||
}
|
}
|
||||||
|
|
||||||
abstract class InProgress implements UploadState {
|
abstract class InProgress implements UploadState {
|
||||||
const factory InProgress({required int uploaded, required int total}) =
|
const factory InProgress(
|
||||||
_$InProgress;
|
{required final int uploaded, required final int total}) = _$InProgress;
|
||||||
|
|
||||||
factory InProgress.fromJson(Map<String, dynamic> json) =
|
factory InProgress.fromJson(Map<String, dynamic> json) =
|
||||||
_$InProgress.fromJson;
|
_$InProgress.fromJson;
|
||||||
|
|
||||||
int get uploaded;
|
int get uploaded => throw _privateConstructorUsedError;
|
||||||
int get total;
|
int get total => throw _privateConstructorUsedError;
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
_$$InProgressCopyWith<_$InProgress> get copyWith =>
|
_$$InProgressCopyWith<_$InProgress> get copyWith =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
@@ -456,7 +425,7 @@ class __$$SuccessCopyWithImpl<$Res> extends _$UploadStateCopyWithImpl<$Res>
|
|||||||
/// @nodoc
|
/// @nodoc
|
||||||
@JsonSerializable()
|
@JsonSerializable()
|
||||||
class _$Success implements Success {
|
class _$Success implements Success {
|
||||||
const _$Success({String? $type}) : $type = $type ?? 'success';
|
const _$Success({final String? $type}) : $type = $type ?? 'success';
|
||||||
|
|
||||||
factory _$Success.fromJson(Map<String, dynamic> json) =>
|
factory _$Success.fromJson(Map<String, dynamic> json) =>
|
||||||
_$$SuccessFromJson(json);
|
_$$SuccessFromJson(json);
|
||||||
@@ -475,6 +444,7 @@ class _$Success implements Success {
|
|||||||
(other.runtimeType == runtimeType && other is _$Success);
|
(other.runtimeType == runtimeType && other is _$Success);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
@override
|
@override
|
||||||
int get hashCode => runtimeType.hashCode;
|
int get hashCode => runtimeType.hashCode;
|
||||||
|
|
||||||
@@ -596,7 +566,7 @@ class __$$FailedCopyWithImpl<$Res> extends _$UploadStateCopyWithImpl<$Res>
|
|||||||
/// @nodoc
|
/// @nodoc
|
||||||
@JsonSerializable()
|
@JsonSerializable()
|
||||||
class _$Failed implements Failed {
|
class _$Failed implements Failed {
|
||||||
const _$Failed({required this.error, String? $type})
|
const _$Failed({required this.error, final String? $type})
|
||||||
: $type = $type ?? 'failed';
|
: $type = $type ?? 'failed';
|
||||||
|
|
||||||
factory _$Failed.fromJson(Map<String, dynamic> json) =>
|
factory _$Failed.fromJson(Map<String, dynamic> json) =>
|
||||||
@@ -621,6 +591,7 @@ class _$Failed implements Failed {
|
|||||||
const DeepCollectionEquality().equals(other.error, error));
|
const DeepCollectionEquality().equals(other.error, error));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
@override
|
@override
|
||||||
int get hashCode =>
|
int get hashCode =>
|
||||||
Object.hash(runtimeType, const DeepCollectionEquality().hash(error));
|
Object.hash(runtimeType, const DeepCollectionEquality().hash(error));
|
||||||
@@ -711,11 +682,11 @@ class _$Failed implements Failed {
|
|||||||
}
|
}
|
||||||
|
|
||||||
abstract class Failed implements UploadState {
|
abstract class Failed implements UploadState {
|
||||||
const factory Failed({required String error}) = _$Failed;
|
const factory Failed({required final String error}) = _$Failed;
|
||||||
|
|
||||||
factory Failed.fromJson(Map<String, dynamic> json) = _$Failed.fromJson;
|
factory Failed.fromJson(Map<String, dynamic> json) = _$Failed.fromJson;
|
||||||
|
|
||||||
String get error;
|
String get error => throw _privateConstructorUsedError;
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
_$$FailedCopyWith<_$Failed> get copyWith =>
|
_$$FailedCopyWith<_$Failed> get copyWith =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class ChannelState {
|
|||||||
this.watcherCount,
|
this.watcherCount,
|
||||||
this.watchers,
|
this.watchers,
|
||||||
this.read,
|
this.read,
|
||||||
|
this.membership,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// The channel to which this state belongs
|
/// The channel to which this state belongs
|
||||||
@@ -42,6 +43,9 @@ class ChannelState {
|
|||||||
/// The list of channel reads
|
/// The list of channel reads
|
||||||
final List<Read>? read;
|
final List<Read>? read;
|
||||||
|
|
||||||
|
/// Relationship of the current user to this channel.
|
||||||
|
final Member? membership;
|
||||||
|
|
||||||
/// Create a new instance from a json
|
/// Create a new instance from a json
|
||||||
static ChannelState fromJson(Map<String, dynamic> json) =>
|
static ChannelState fromJson(Map<String, dynamic> json) =>
|
||||||
_$ChannelStateFromJson(json);
|
_$ChannelStateFromJson(json);
|
||||||
@@ -58,6 +62,7 @@ class ChannelState {
|
|||||||
int? watcherCount,
|
int? watcherCount,
|
||||||
List<User>? watchers,
|
List<User>? watchers,
|
||||||
List<Read>? read,
|
List<Read>? read,
|
||||||
|
Member? membership,
|
||||||
}) =>
|
}) =>
|
||||||
ChannelState(
|
ChannelState(
|
||||||
channel: channel ?? this.channel,
|
channel: channel ?? this.channel,
|
||||||
@@ -67,5 +72,6 @@ class ChannelState {
|
|||||||
watcherCount: watcherCount ?? this.watcherCount,
|
watcherCount: watcherCount ?? this.watcherCount,
|
||||||
watchers: watchers ?? this.watchers,
|
watchers: watchers ?? this.watchers,
|
||||||
read: read ?? this.read,
|
read: read ?? this.read,
|
||||||
|
membership: membership ?? this.membership,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,9 @@ ChannelState _$ChannelStateFromJson(Map<String, dynamic> json) => ChannelState(
|
|||||||
read: (json['read'] as List<dynamic>?)
|
read: (json['read'] as List<dynamic>?)
|
||||||
?.map((e) => Read.fromJson(e as Map<String, dynamic>))
|
?.map((e) => Read.fromJson(e as Map<String, dynamic>))
|
||||||
.toList(),
|
.toList(),
|
||||||
|
membership: json['membership'] == null
|
||||||
|
? null
|
||||||
|
: Member.fromJson(json['membership'] as Map<String, dynamic>),
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> _$ChannelStateToJson(ChannelState instance) =>
|
Map<String, dynamic> _$ChannelStateToJson(ChannelState instance) =>
|
||||||
@@ -38,4 +41,5 @@ Map<String, dynamic> _$ChannelStateToJson(ChannelState instance) =>
|
|||||||
'watcher_count': instance.watcherCount,
|
'watcher_count': instance.watcherCount,
|
||||||
'watchers': instance.watchers?.map((e) => e.toJson()).toList(),
|
'watchers': instance.watchers?.map((e) => e.toJson()).toList(),
|
||||||
'read': instance.read?.map((e) => e.toJson()).toList(),
|
'read': instance.read?.map((e) => e.toJson()).toList(),
|
||||||
|
'membership': instance.membership?.toJson(),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
},
|
},
|
||||||
"watchers": [],
|
"watchers": [],
|
||||||
"read": [],
|
"read": [],
|
||||||
|
"membership": null,
|
||||||
"messages": [
|
"messages": [
|
||||||
{
|
{
|
||||||
"id": "dry-meadow-0-2b73cc8b-cd86-4a01-8d40-bd82ad07a030",
|
"id": "dry-meadow-0-2b73cc8b-cd86-4a01-8d40-bd82ad07a030",
|
||||||
|
|||||||
@@ -608,7 +608,6 @@ class StreamMessageInputState extends State<StreamMessageInput>
|
|||||||
widget: _buildCommandsOverlayEntry(),
|
widget: _buildCommandsOverlayEntry(),
|
||||||
),
|
),
|
||||||
if (widget.enableEmojiSuggestionsOverlay &&
|
if (widget.enableEmojiSuggestionsOverlay &&
|
||||||
// ignore: deprecated_member_use_from_same_package
|
|
||||||
!widget.disableEmojiSuggestionsOverlay)
|
!widget.disableEmojiSuggestionsOverlay)
|
||||||
OverlayOptions(
|
OverlayOptions(
|
||||||
visible: _focusNode.hasFocus &&
|
visible: _focusNode.hasFocus &&
|
||||||
|
|||||||
Reference in New Issue
Block a user