fix(llc): update member presence and add skip_push to message (#314)
* update member presence * add skip_push to message * fix tests
This commit is contained in:
@@ -1761,6 +1761,31 @@ class ChannelClientState {
|
||||
}
|
||||
},
|
||||
),
|
||||
)
|
||||
..add(
|
||||
_channel
|
||||
.on()
|
||||
.where((event) =>
|
||||
event.user != null &&
|
||||
members?.any((m) => m.userId == event.user.id) == true)
|
||||
.listen(
|
||||
(event) {
|
||||
final newMembers = List<Member>.from(members);
|
||||
final oldMemberIndex =
|
||||
newMembers.indexWhere((m) => m.userId == event.user.id);
|
||||
if (oldMemberIndex > -1) {
|
||||
final oldMember = newMembers.removeAt(oldMemberIndex);
|
||||
updateChannelState(ChannelState(
|
||||
members: [
|
||||
...newMembers,
|
||||
oldMember.copyWith(
|
||||
user: event.user,
|
||||
),
|
||||
],
|
||||
));
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ part of 'requests.dart';
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
Map<String, dynamic> _$SortOptionToJson(SortOption instance) =>
|
||||
Map<String, dynamic> _$SortOptionToJson<T>(SortOption<T> instance) =>
|
||||
<String, dynamic>{
|
||||
'field': instance.field,
|
||||
'direction': instance.direction,
|
||||
|
||||
@@ -72,6 +72,7 @@ class Message {
|
||||
this.extraData,
|
||||
this.deletedAt,
|
||||
this.status = MessageSendingStatus.sent,
|
||||
this.skipPush,
|
||||
}) : id = id ?? Uuid().v4(),
|
||||
pinExpires = pinExpires?.toUtc();
|
||||
|
||||
@@ -143,6 +144,9 @@ class Message {
|
||||
/// If true the message is silent
|
||||
final bool silent;
|
||||
|
||||
/// If true the message will not send a push notification
|
||||
final bool skipPush;
|
||||
|
||||
/// If true the message is shadowed
|
||||
@JsonKey(includeIfNull: false, toJson: Serialization.readOnly)
|
||||
final bool shadowed;
|
||||
@@ -226,6 +230,7 @@ class Message {
|
||||
'pinned_at',
|
||||
'pin_expires',
|
||||
'pinned_by',
|
||||
'skip_push',
|
||||
];
|
||||
|
||||
/// Serialize to json
|
||||
@@ -262,6 +267,7 @@ class Message {
|
||||
User pinnedBy,
|
||||
Map<String, dynamic> extraData,
|
||||
MessageSendingStatus status,
|
||||
bool skipPush,
|
||||
}) {
|
||||
assert(() {
|
||||
if (pinExpires is! DateTime &&
|
||||
@@ -300,6 +306,7 @@ class Message {
|
||||
pinnedAt: pinnedAt ?? this.pinnedAt,
|
||||
pinnedBy: pinnedBy ?? this.pinnedBy,
|
||||
pinExpires: pinExpires == _pinExpires ? this.pinExpires : pinExpires,
|
||||
skipPush: skipPush ?? this.skipPush,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -93,6 +93,7 @@ Message _$MessageFromJson(Map json) {
|
||||
deletedAt: json['deleted_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['deleted_at'] as String),
|
||||
skipPush: json['skip_push'] as bool,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -123,6 +124,7 @@ Map<String, dynamic> _$MessageToJson(Message instance) {
|
||||
writeNotNull('thread_participants', readonly(instance.threadParticipants));
|
||||
val['show_in_channel'] = instance.showInChannel;
|
||||
val['silent'] = instance.silent;
|
||||
val['skip_push'] = instance.skipPush;
|
||||
writeNotNull('shadowed', readonly(instance.shadowed));
|
||||
writeNotNull('command', readonly(instance.command));
|
||||
writeNotNull('created_at', readonly(instance.createdAt));
|
||||
|
||||
Reference in New Issue
Block a user