Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
88987e9
refactor(dao): Filter reactions by userId at DB level.
VelikovPetar May 19, 2026
fe4d4e2
refactor(dao): Filter reactions by userId at DB level (pinned messages).
VelikovPetar May 19, 2026
5652130
Merge branch 'refs/heads/master' into feature/FLU-485_optimize_read_m…
VelikovPetar May 19, 2026
466d9d3
refactor(dao): optimize message retrieval with SQL-side pagination fi…
VelikovPetar May 20, 2026
e1ec859
refactor(dao): fix formatting
VelikovPetar May 21, 2026
d38c049
Merge branch 'master' into feature/FLU-485_optimize_read_message_from_db
VelikovPetar May 21, 2026
4689606
refactor(dao): Update CHANGELOG.md
VelikovPetar May 21, 2026
edb86f7
refactor(dao): Apply formatting
VelikovPetar May 21, 2026
4efc8c4
refactor(dao): optimize message and reaction retrieval with grouped q…
VelikovPetar May 22, 2026
9553c2d
refactor(dao): add tests for new methods
VelikovPetar May 22, 2026
b580ccd
refactor(dao): enhance message pagination logic to support inclusive …
VelikovPetar May 25, 2026
52f0c26
refactor(dao): Update docs
VelikovPetar May 25, 2026
d7a18d6
Merge branch 'master' into feature/FLU-485_optimize_read_message_from_db
VelikovPetar May 25, 2026
e465f81
Merge branch 'feature/FLU-485_optimize_read_message_from_db' into fea…
VelikovPetar May 25, 2026
0dfd4fe
refactor(dao): Remove legacy method
VelikovPetar May 25, 2026
80719e6
refactor(dao): Remove legacy method
VelikovPetar May 25, 2026
1da0c45
refactor(dao): Remove legacy method
VelikovPetar May 25, 2026
cc443dc
refactor(dao): Fix warnings
VelikovPetar May 25, 2026
2e719f4
refactor(dao): Add message.id tiebreakier
VelikovPetar May 25, 2026
35569a0
refactor(dao): Add message.id tiebreaker
VelikovPetar May 25, 2026
fa6898e
refactor(dao): Update CHANGELOG.md
VelikovPetar May 25, 2026
c04a7cf
Merge branch 'refs/heads/feature/FLU-485_optimize_read_message_from_d…
VelikovPetar May 26, 2026
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
13 changes: 12 additions & 1 deletion packages/stream_chat_persistence/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
# Upcoming
## Upcoming Changes

🚀 Performance

- Reduce the number of DB reads in the `ChatPersistenceClient.getChannelStates` method.
- Read only the messages matching the `PaginationParams` from DB when calling `MessageDao.getMessagesByCid` instead of reading all messages for the channel and applying pagination in memory.
- Read only the reactions matching the `userId` from DB when calling `ReactionDao.getReactionsByUserId` instead of reading all reactions for the message and filtering in memory.
- Read only the reactions matching the `userId` from DB when calling `PinnedMessageReactionDao.getReactionsByUserId` instead of reading all reactions for the message and filtering in memory.
- Improve the message read times from DB.

🐞 Fixed

- `MessageDao.getMessagesByCid` now honours `PaginationParams.lessThanOrEqual` and `PaginationParams.greaterThanOrEqual` (inclusive of the cursor message), in addition to the existing strict `lessThan`/`greaterThan`.
- `MessageDao.getMessagesByCid` now treats `PaginationParams.greaterThan` as strict (exclusive of the cursor), matching the `PaginationParams` contract and the existing `lessThan` behaviour.
- `MessageDao.getMessagesByCid` with a forward cursor (`greaterThan`/`greaterThanOrEqual`) and a `limit` now returns the messages immediately AFTER the pivot, instead of the channel tail — mirroring how `lessThan` already returned the messages immediately before the pivot.


## 9.24.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import 'package:drift/drift.dart';
import 'package:stream_chat/stream_chat.dart';
import 'package:stream_chat_persistence/src/db/drift_chat_database.dart';
import 'package:stream_chat_persistence/src/db/query_utils.dart';
import 'package:stream_chat_persistence/src/entity/entity.dart';
import 'package:stream_chat_persistence/src/mapper/mapper.dart';

Expand Down Expand Up @@ -66,6 +67,27 @@ class DraftMessageDao extends DatabaseAccessor<DriftChatDatabase>
return _draftFromEntity(result);
}

/// Returns thread drafts in [cid] for every parent message id in
/// [parentIds], keyed by parent message id.
Future<Map<String, Draft?>> getDraftMessagesByParentIds(
String cid,
List<String> parentIds,
) async {
if (parentIds.isEmpty) return const {};
final result = <String, Draft?>{for (final id in parentIds) id: null};
for (final chunk in chunked(parentIds)) {
final query = select(draftMessages)
..where((tbl) => tbl.channelCid.equals(cid) & tbl.parentId.isIn(chunk));
final entities = await query.get();
for (final entity in entities) {
if (entity.parentId case final pid?) {
result[pid] = await _draftFromEntity(entity);
}
}
}
return result;
}

/// Updates the draft message data of a particular channel with
/// the new [messageList] data.
Future<void> updateDraftMessages(List<Draft> draftMessageList) {
Expand Down
Loading
Loading