Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/stream_chat_persistence/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

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

🐛 Fixed

- Fixed missing persistence of the `team` field on channel entities.

🔄 Changed

- Changed how dates are stored in the local cache, from integer seconds to ISO-8601 strings, in order to preserve millisecond precision.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class DriftChatDatabase extends _$DriftChatDatabase {

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

// Store DateTime as ISO-8601 text to preserve sub-second precision.
@override
Expand Down
209 changes: 105 additions & 104 deletions packages/stream_chat_persistence/lib/src/db/drift_chat_database.g.dart

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions packages/stream_chat_persistence/lib/src/entity/channels.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class Channels extends Table {
/// List of filter tags for this channel
TextColumn get filterTags => text().nullable().map(ListConverter<String>())();

/// The team the channel belongs to
TextColumn get team => text().nullable()();

/// Map of custom channel extraData
TextColumn get extraData => text().nullable().map(MapConverter())();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ extension ChannelEntityX on ChannelEntity {
deletedAt: deletedAt,
createdBy: createdBy,
filterTags: filterTags,
team: team,
extraData: extraData ?? {},
);
}
Expand Down Expand Up @@ -60,6 +61,7 @@ extension ChannelModelX on ChannelModel {
messageCount: messageCount,
createdById: createdBy?.id,
filterTags: filterTags,
team: team,
extraData: extraData,
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ void main() {
createdAt: now,
memberCount: index + 3,
lastMessageAt: now.add(Duration(hours: index)),
team: 'testTeam$index',
),
).toList(growable: false);

Expand Down Expand Up @@ -124,6 +125,7 @@ void main() {
expect(updatedChannel.cid, insertedChannel.cid);
expect(updatedChannel.memberCount, insertedChannel.memberCount);
expect(updatedChannel.filterTags, insertedChannel.filterTags);
expect(updatedChannel.team, insertedChannel.team);

// Should match createdAt date
expect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ void main() {
createdById: user.id,
filterTags: ['tag1', 'tag2'],
extraData: {'test_extra_data': 'testData'},
team: 'testTeam',
);

test('toChannelModel should map entity into ChannelModel', () {
Expand All @@ -45,6 +46,7 @@ void main() {
expect(channelModel.createdBy!.id, entity.createdById);
expect(channelModel.filterTags, entity.filterTags);
expect(channelModel.extraData, entity.extraData);
expect(channelModel.team, entity.team);
});

test('toChannelState should map entity into ChannelState ', () {
Expand Down Expand Up @@ -109,6 +111,7 @@ void main() {
createdBy: createdBy,
filterTags: ['tag1', 'tag2'],
extraData: {'test_extra_data': 'testData'},
team: 'testTeam',
);

final channelEntity = model.toEntity();
Expand All @@ -130,5 +133,6 @@ void main() {
expect(channelEntity.filterTags, model.filterTags);
expect(channelEntity.extraData, model.extraData);
expect(channelEntity.createdById, model.createdBy!.id);
expect(channelEntity.team, model.team);
});
}
Loading