Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chat messages pagination #51

Merged
merged 2 commits into from
Jul 17, 2023
Merged

Chat messages pagination #51

merged 2 commits into from
Jul 17, 2023

Conversation

kosukesaigusa
Copy link
Owner

@kosukesaigusa kosukesaigusa commented Jul 17, 2023

Issue

該当なし

説明

コミットメッセージの通り。

UI

UI の変更がある(重要な)場合は、スクリーンショットや画面収録を貼り付けてください。

必要に応じて Before, After の画像を貼り付けるのも有効です。

その他

その他に言及したいことがあれば書いてください。

チェックリスト

  • PR の冒頭に関連する Issue 番号を記載しましたか?
  • 本 PR の変更に関して、エディタや IDE で意図しない警告は増えていませんか?(lint 警告やタイポなど)
  • Issue の完了の定義は満たせていますか?

@kosukesaigusa kosukesaigusa self-assigned this Jul 17, 2023
@@ -9,14 +9,15 @@ environment:

dependencies:
auto_route: ^7.7.0
cloud_firestore: ^4.8.3
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

本当は追加したくなかったけれど、仕方なく。

mottai_flutter_app のチャット機能で最後に読み込んだ QueryDocumentSnapshot を保持する必要があるため。

Comment on lines +12 to +27
Future<(List<ReadChatMessage>, QueryDocumentSnapshot<ReadChatMessage>?)>
loadMessagesWithCursor({
required String chatRoomId,
required int limit,
required QueryDocumentSnapshot<ReadChatMessage>?
lastReadQueryDocumentSnapshot,
}) async {
var query = readChatMessageCollectionReference(chatRoomId: chatRoomId)
.orderBy('createdAt', descending: true);
final qds = lastReadQueryDocumentSnapshot;
if (qds != null) {
query = query.startAfterDocument(qds);
}
final qs = await query.limit(limit).get();
final readChatMessages = qs.docs.map((qds) => qds.data()).toList();
return (readChatMessages, qs.docs.lastOrNull);
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Muhyun-Kim

チャット機能の実装にあたって必要ならこれをいい感じに書き換えてください!

@kosukesaigusa kosukesaigusa merged commit b60697b into main Jul 17, 2023
@kosukesaigusa kosukesaigusa deleted the chat_messages_pagination branch July 17, 2023 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant