Skip to content

Commit e155fca

Browse files
TheoGermainclaudexsahil03xVelikovPetar
authored
fix(persistence): persist channel team field (#2700)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: Sahil Kumar <sahil@getstream.io> Co-authored-by: VelikovPetar <petarvelikov95@gmail.com> Co-authored-by: Sahil Kumar <xdsahil@gmail.com>
1 parent bf32995 commit e155fca

7 files changed

Lines changed: 121 additions & 105 deletions

File tree

packages/stream_chat_persistence/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
- Reduce the number of DB reads in the `ChatPersistenceClient.getChannelStates` method.
66

7+
🐛 Fixed
8+
9+
- Fixed missing persistence of the `team` field on channel entities.
10+
711
🔄 Changed
812

913
- Changed how dates are stored in the local cache, from integer seconds to ISO-8601 strings, in order to preserve millisecond precision.

packages/stream_chat_persistence/lib/src/db/drift_chat_database.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class DriftChatDatabase extends _$DriftChatDatabase {
5555

5656
// you should bump this number whenever you change or add a table definition.
5757
@override
58-
int get schemaVersion => 28;
58+
int get schemaVersion => 29;
5959

6060
// Store DateTime as ISO-8601 text to preserve sub-second precision.
6161
@override

packages/stream_chat_persistence/lib/src/db/drift_chat_database.g.dart

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

packages/stream_chat_persistence/lib/src/entity/channels.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ class Channels extends Table {
4848
/// List of filter tags for this channel
4949
TextColumn get filterTags => text().nullable().map(ListConverter<String>())();
5050

51+
/// The team the channel belongs to
52+
TextColumn get team => text().nullable()();
53+
5154
/// Map of custom channel extraData
5255
TextColumn get extraData => text().nullable().map(MapConverter())();
5356

packages/stream_chat_persistence/lib/src/mapper/channel_mapper.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ extension ChannelEntityX on ChannelEntity {
2121
deletedAt: deletedAt,
2222
createdBy: createdBy,
2323
filterTags: filterTags,
24+
team: team,
2425
extraData: extraData ?? {},
2526
);
2627
}
@@ -60,6 +61,7 @@ extension ChannelModelX on ChannelModel {
6061
messageCount: messageCount,
6162
createdById: createdBy?.id,
6263
filterTags: filterTags,
64+
team: team,
6365
extraData: extraData,
6466
);
6567
}

packages/stream_chat_persistence/test/src/dao/channel_query_dao_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ void main() {
8787
createdAt: now,
8888
memberCount: index + 3,
8989
lastMessageAt: now.add(Duration(hours: index)),
90+
team: 'testTeam$index',
9091
),
9192
).toList(growable: false);
9293

@@ -124,6 +125,7 @@ void main() {
124125
expect(updatedChannel.cid, insertedChannel.cid);
125126
expect(updatedChannel.memberCount, insertedChannel.memberCount);
126127
expect(updatedChannel.filterTags, insertedChannel.filterTags);
128+
expect(updatedChannel.team, insertedChannel.team);
127129

128130
// Should match createdAt date
129131
expect(

packages/stream_chat_persistence/test/src/mapper/channel_mapper_test.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ void main() {
2626
createdById: user.id,
2727
filterTags: ['tag1', 'tag2'],
2828
extraData: {'test_extra_data': 'testData'},
29+
team: 'testTeam',
2930
);
3031

3132
test('toChannelModel should map entity into ChannelModel', () {
@@ -45,6 +46,7 @@ void main() {
4546
expect(channelModel.createdBy!.id, entity.createdById);
4647
expect(channelModel.filterTags, entity.filterTags);
4748
expect(channelModel.extraData, entity.extraData);
49+
expect(channelModel.team, entity.team);
4850
});
4951

5052
test('toChannelState should map entity into ChannelState ', () {
@@ -109,6 +111,7 @@ void main() {
109111
createdBy: createdBy,
110112
filterTags: ['tag1', 'tag2'],
111113
extraData: {'test_extra_data': 'testData'},
114+
team: 'testTeam',
112115
);
113116

114117
final channelEntity = model.toEntity();
@@ -130,5 +133,6 @@ void main() {
130133
expect(channelEntity.filterTags, model.filterTags);
131134
expect(channelEntity.extraData, model.extraData);
132135
expect(channelEntity.createdById, model.createdBy!.id);
136+
expect(channelEntity.team, model.team);
133137
});
134138
}

0 commit comments

Comments
 (0)