Skip to content

Commit 976b06f

Browse files
committed
Merge remote-tracking branch 'origin/master' into v10.0.0
# Conflicts: # melos.yaml # packages/stream_chat/CHANGELOG.md # packages/stream_chat/example/pubspec.yaml # packages/stream_chat/lib/version.dart # packages/stream_chat/pubspec.yaml # packages/stream_chat_flutter/CHANGELOG.md # packages/stream_chat_flutter/example/pubspec.yaml # packages/stream_chat_flutter/lib/src/message_input/stream_message_input.dart # packages/stream_chat_flutter/pubspec.yaml # packages/stream_chat_flutter/test/src/poll/creator/goldens/ci/poll_option_reorderable_list_view_dark.png # packages/stream_chat_flutter/test/src/poll/creator/goldens/ci/poll_option_reorderable_list_view_error_dark.png # packages/stream_chat_flutter/test/src/poll/creator/goldens/ci/poll_option_reorderable_list_view_error_light.png # packages/stream_chat_flutter/test/src/poll/creator/goldens/ci/poll_option_reorderable_list_view_light.png # packages/stream_chat_flutter/test/src/poll/creator/goldens/ci/stream_poll_creator_dialog_dark.png # packages/stream_chat_flutter/test/src/poll/creator/goldens/ci/stream_poll_creator_dialog_light.png # packages/stream_chat_flutter/test/src/poll/creator/goldens/ci/stream_poll_creator_full_screen_dialog_dark.png # packages/stream_chat_flutter/test/src/poll/creator/goldens/ci/stream_poll_creator_full_screen_dialog_light.png # packages/stream_chat_flutter/test/src/poll/goldens/ci/poll_option_reorderable_list_view_dark.png # packages/stream_chat_flutter/test/src/poll/goldens/ci/poll_option_reorderable_list_view_error.png # packages/stream_chat_flutter/test/src/poll/goldens/ci/poll_option_reorderable_list_view_light.png # packages/stream_chat_flutter/test/src/poll/goldens/ci/stream_poll_creator_dialog_dark.png # packages/stream_chat_flutter/test/src/poll/goldens/ci/stream_poll_creator_dialog_light.png # packages/stream_chat_flutter/test/src/poll/goldens/ci/stream_poll_creator_full_screen_dialog_dark.png # packages/stream_chat_flutter/test/src/poll/goldens/ci/stream_poll_creator_full_screen_dialog_light.png # packages/stream_chat_flutter_core/CHANGELOG.md # packages/stream_chat_flutter_core/example/pubspec.yaml # packages/stream_chat_flutter_core/pubspec.yaml # packages/stream_chat_localizations/CHANGELOG.md # packages/stream_chat_localizations/example/pubspec.yaml # packages/stream_chat_localizations/pubspec.yaml # packages/stream_chat_persistence/CHANGELOG.md # packages/stream_chat_persistence/example/pubspec.yaml # packages/stream_chat_persistence/lib/src/db/drift_chat_database.dart # packages/stream_chat_persistence/pubspec.yaml # sample_app/pubspec.yaml
2 parents 56e021f + f87b36b commit 976b06f

File tree

51 files changed

+1786
-48
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1786
-48
lines changed

packages/stream_chat/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
## 9.22.0
2+
3+
✅ Added
4+
5+
- Added support for `filterTags` in channels.
6+
- Added support for `Channel.markUnreadByTimestamp` and `Client.markChannelUnreadByTimestamp`
7+
methods to mark all messages after a given timestamp as unread.
8+
- Added support for `hideHistoryBefore` in `Channel.addMembers` and `Client.addChannelMembers` to
9+
specify a timestamp before which channel history should be hidden for newly added members. When
10+
provided, it takes precedence over the `hideHistory` boolean flag.
11+
112
## 10.0.0-beta.10
213

314
- Included the changes from version [`9.21.0`](https://pub.dev/packages/stream_chat/changelog).

packages/stream_chat/lib/src/client/channel.dart

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,14 @@ class Channel {
423423
return state!.channelStateStream.map((cs) => cs.channel?.messageCount);
424424
}
425425

426+
/// List of filter tags applied to this channel.
427+
///
428+
/// Generally used for filtering channels while querying.
429+
List<String>? get filterTags {
430+
_checkInitialized();
431+
return state!._channelState.channel?.filterTags;
432+
}
433+
426434
/// Channel id.
427435
String? get id => state?._channelState.channel?.id ?? _id;
428436

@@ -1714,6 +1722,7 @@ class Channel {
17141722
List<String> memberIds, {
17151723
Message? message,
17161724
bool hideHistory = false,
1725+
DateTime? hideHistoryBefore,
17171726
}) async {
17181727
_checkInitialized();
17191728
return _client.addChannelMembers(
@@ -1722,6 +1731,7 @@ class Channel {
17221731
memberIds,
17231732
message: message,
17241733
hideHistory: hideHistory,
1734+
hideHistoryBefore: hideHistoryBefore,
17251735
);
17261736
}
17271737

@@ -1780,10 +1790,9 @@ class Channel {
17801790
return _client.markChannelRead(id!, type, messageId: messageId);
17811791
}
17821792

1783-
/// Mark message as unread.
1793+
/// Marks the channel as unread by a given [messageId].
17841794
///
1785-
/// You have to provide a [messageId] from which you want the channel
1786-
/// to be marked as unread.
1795+
/// All messages from the provided message onwards will be marked as unread.
17871796
Future<EmptyResponse> markUnread(String messageId) async {
17881797
_checkInitialized();
17891798

@@ -1797,6 +1806,22 @@ class Channel {
17971806
return _client.markChannelUnread(id!, type, messageId);
17981807
}
17991808

1809+
/// Marks the channel as unread by a given [timestamp].
1810+
///
1811+
/// All messages after the provided timestamp will be marked as unread.
1812+
Future<EmptyResponse> markUnreadByTimestamp(DateTime timestamp) async {
1813+
_checkInitialized();
1814+
1815+
if (!canUseReadReceipts) {
1816+
throw const StreamChatError(
1817+
'Cannot mark as unread: Channel does not support read events. '
1818+
'Enable read_events in your channel type configuration.',
1819+
);
1820+
}
1821+
1822+
return _client.markChannelUnreadByTimestamp(id!, type, timestamp);
1823+
}
1824+
18001825
/// Mark the thread with [threadId] in the channel as read.
18011826
Future<EmptyResponse> markThreadRead(String threadId) async {
18021827
_checkInitialized();

packages/stream_chat/lib/src/client/client.dart

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,13 +1321,15 @@ class StreamChatClient {
13211321
List<String> memberIds, {
13221322
Message? message,
13231323
bool hideHistory = false,
1324+
DateTime? hideHistoryBefore,
13241325
}) =>
13251326
_chatApi.channel.addMembers(
13261327
channelId,
13271328
channelType,
13281329
memberIds,
13291330
message: message,
13301331
hideHistory: hideHistory,
1332+
hideHistoryBefore: hideHistoryBefore,
13311333
);
13321334

13331335
/// Remove members from the channel
@@ -1396,9 +1398,10 @@ class StreamChatClient {
13961398
messageId: messageId,
13971399
);
13981400

1399-
/// Mark [channelId] of type [channelType] all messages as read
1400-
/// Optionally provide a [messageId] if you want to mark a
1401-
/// particular message as read
1401+
/// Marks the [channelId] of type [channelType] as unread
1402+
/// by a given [messageId].
1403+
///
1404+
/// All messages from the provided message onwards will be marked as unread.
14021405
Future<EmptyResponse> markChannelUnread(
14031406
String channelId,
14041407
String channelType,
@@ -1410,6 +1413,21 @@ class StreamChatClient {
14101413
messageId,
14111414
);
14121415

1416+
/// Marks the [channelId] of type [channelType] as unread
1417+
/// by a given [timestamp].
1418+
///
1419+
/// All messages after the provided timestamp will be marked as unread.
1420+
Future<EmptyResponse> markChannelUnreadByTimestamp(
1421+
String channelId,
1422+
String channelType,
1423+
DateTime timestamp,
1424+
) =>
1425+
_chatApi.channel.markUnreadByTimestamp(
1426+
channelId,
1427+
channelType,
1428+
timestamp,
1429+
);
1430+
14131431
/// Mark the thread with [threadId] in the channel with [channelId] of type
14141432
/// [channelType] as read.
14151433
Future<EmptyResponse> markThreadRead(

packages/stream_chat/lib/src/core/api/channel_api.dart

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,18 @@ class ChannelApi {
209209
List<String> memberIds, {
210210
Message? message,
211211
bool hideHistory = false,
212+
DateTime? hideHistoryBefore,
212213
}) async {
213214
final response = await _client.post(
214215
_getChannelUrl(channelId, channelType),
215216
data: {
216217
'add_members': memberIds,
217-
'message': message,
218-
'hide_history': hideHistory,
218+
if (message != null) 'message': message,
219+
// [hideHistoryBefore] takes precedence over [hideHistory]
220+
...switch (hideHistoryBefore?.toUtc().toIso8601String()) {
221+
final hideBefore? => {'hide_history_before': hideBefore},
222+
_ => {'hide_history': hideHistory},
223+
},
219224
},
220225
);
221226
return AddMembersResponse.fromJson(response.data);
@@ -323,11 +328,13 @@ class ChannelApi {
323328
return EmptyResponse.fromJson(response.data);
324329
}
325330

326-
/// Marks all messages from the provided [messageId] onwards as unread
331+
/// Marks the channel as unread by a given [messageId].
332+
///
333+
/// All messages from the provided message onwards will be marked as unread.
327334
Future<EmptyResponse> markUnread(
328335
String channelId,
329336
String channelType,
330-
String? messageId,
337+
String messageId,
331338
) async {
332339
final response = await _client.post(
333340
'${_getChannelUrl(channelId, channelType)}/unread',
@@ -336,6 +343,21 @@ class ChannelApi {
336343
return EmptyResponse.fromJson(response.data);
337344
}
338345

346+
/// Marks the channel as unread by a given [timestamp].
347+
///
348+
/// All messages after the provided timestamp will be marked as unread.
349+
Future<EmptyResponse> markUnreadByTimestamp(
350+
String channelId,
351+
String channelType,
352+
DateTime timestamp,
353+
) async {
354+
final response = await _client.post(
355+
'${_getChannelUrl(channelId, channelType)}/unread',
356+
data: {'message_timestamp': timestamp.toUtc().toIso8601String()},
357+
);
358+
return EmptyResponse.fromJson(response.data);
359+
}
360+
339361
/// Mark the provided [threadId] of the channel as read.
340362
Future<EmptyResponse> markThreadRead(
341363
String channelId,

packages/stream_chat/lib/src/core/models/channel_model.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class ChannelModel {
3232
bool? hidden,
3333
DateTime? truncatedAt,
3434
this.messageCount,
35+
this.filterTags,
3536
}) : assert(
3637
(cid != null && cid.contains(':')) || (id != null && type != null),
3738
'provide either a cid or an id and type',
@@ -159,6 +160,12 @@ class ChannelModel {
159160
@JsonKey(includeToJson: false)
160161
final int? messageCount;
161162

163+
/// List of filter tags applied to the channel.
164+
///
165+
/// This is generally used for querying filtered channels based on tags.
166+
@JsonKey(includeToJson: false)
167+
final List<String>? filterTags;
168+
162169
/// Known top level fields.
163170
/// Useful for [Serializer] methods.
164171
static const topLevelFields = [
@@ -178,6 +185,7 @@ class ChannelModel {
178185
'team',
179186
'cooldown',
180187
'message_count',
188+
'filter_tags',
181189
];
182190

183191
/// Serialize to json
@@ -207,6 +215,7 @@ class ChannelModel {
207215
bool? hidden,
208216
DateTime? truncatedAt,
209217
int? messageCount,
218+
List<String>? filterTags,
210219
}) =>
211220
ChannelModel(
212221
id: id ?? this.id,
@@ -234,6 +243,7 @@ class ChannelModel {
234243
: DateTime.parse(extraData?['truncated_at'] as String)) ??
235244
this.truncatedAt,
236245
messageCount: messageCount ?? this.messageCount,
246+
filterTags: filterTags ?? this.filterTags,
237247
);
238248

239249
/// Returns a new [ChannelModel] that is a combination of this channelModel
@@ -261,6 +271,7 @@ class ChannelModel {
261271
hidden: other.hidden,
262272
truncatedAt: other.truncatedAt,
263273
messageCount: other.messageCount,
274+
filterTags: other.filterTags,
264275
);
265276
}
266277
}

packages/stream_chat/lib/src/core/models/channel_model.g.dart

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)