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

TW-2165: Improve tag suggestion with members in room #2200

Merged
merged 5 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
TW-2165: Add ADR for this tick
  • Loading branch information
nqhhdev committed Dec 29, 2024
commit 66c1d47829a033f5ebd92b792b73bb182a584d1b
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# 25. Improve tag suggestion and display members in group chat detail

**Date:** 2024-12-30

## Status

**Accepted**

## Context

- Issue: [#2165](https://github.com/linagora/twake-on-matrix/issues/2165)
- Not all of the members are displayed in the drop-down list when using the tag suggestion feature.
- Can't load more members in the drop-down list when the user scrolls down.

## Decision

1.1 **Improve tag suggestion feature**
- When the user go to the group chat, call the func to get the members from server of the group chat.
More details about this logic can be found in the [ADR #0005](https://github.com/linagora/matrix-dart-sdk/blob/cb37032f466004500c98949739720b3b4457cc73/doc/adr/0005-support-store-members-in-hive.md).

```dart
Future<void> _requestParticipants() async {
if (room == null) return;
try {
await room!.requestParticipants(
at: room!.prev_batch,
notMembership: Membership.leave,
);
} catch (e) {
Logs()
.e('Chat::_requestParticipants(): Failed to request participants', e);
}
}
```
- Next time when user go to the group chat, the members will be stored in the hive db and get the members from the hive db to display in the drop-down list.
- When the user types the `@` character, the tag suggestion feature will be triggered.

1.2 **Display members in the group chat detail**
- When the user clicks on the group chat, how to display the members?
1. Display members with a maximum size defined by the `_maxMembers` variable defined in `chat_details_tab_mixin.dart`.
hoangdat marked this conversation as resolved.
Show resolved Hide resolved
```dart
static const _maxMembers = 30;
```
2. If more members can be loaded, display the Load more button at the end of the list.
3. When the user clicks on the Load more button, call the function to get more members from the Hive database.
```dart
void _requestMoreMembersAction() async {
final currentMembersCount = _displayMembersNotifier.value?.length ?? 0;
_currentMembersCount += _maxMembers;

final members = _membersNotifier.value;
if (members != null && currentMembersCount < members.length) {
final endIndex = _currentMembersCount > members.length
? members.length
: _currentMembersCount;
final newMembers = members.sublist(currentMembersCount, endIndex);
_displayMembersNotifier.value = [
...?_displayMembersNotifier.value,
...newMembers,
];
} else {
_displayMembersNotifier.value = [
...?_displayMembersNotifier.value,
...?members,
];
}
}
```
4. Each call only takes a maximum of 30 members according to variable `maxMembers`
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1876,8 +1876,8 @@ packages:
dependency: "direct main"
description:
path: "."
ref: "twake-supported-0.22.6"
resolved-ref: "58585a19abc4693d96eab4f8dad9c56bf8699cc1"
ref: TW-2165-support-store-members-in-local-database
resolved-ref: cb37032f466004500c98949739720b3b4457cc73
url: "git@github.com:linagora/matrix-dart-sdk.git"
source: git
version: "0.22.6"
Expand Down
Loading