Skip to content

Commit

Permalink
Merge pull request #2174 from acterglobal/ben-2169
Browse files Browse the repository at this point in the history
Add ability to configure suggestion for joined chats
  • Loading branch information
gtalha07 authored Sep 12, 2024
2 parents 3fb5df4 + 0541512 commit 8ff28ef
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
1 change: 1 addition & 0 deletions .changes/2169-suggested-chats.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- [Fix] you can now suggest chat rooms you are already in as well
6 changes: 6 additions & 0 deletions app/lib/common/providers/space_providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,12 @@ final spaceRelationsOverviewProvider =
);
});

final suggestedIdsProvider =
FutureProvider.family<List<String>, String>((ref, spaceId) async {
return (await ref.watch(spaceRelationsOverviewProvider(spaceId).future))
.suggestedIds;
});

final hasSubChatsProvider =
AsyncNotifierProvider.family<HasSubChatsNotifier, bool, String>(
() => HasSubChatsNotifier(),
Expand Down
8 changes: 7 additions & 1 deletion app/lib/features/space/pages/chats_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,13 @@ class SpaceChatsPage extends ConsumerWidget {
child: Column(
children: [
if (chatList.isNotEmpty)
chatsListUI(ref, chatList, chatList.length),
chatsListUI(
ref,
spaceIdOrAlias,
chatList,
chatList.length,
showOptions: true,
),
if (isLoading) _renderLoading(context),
if (remoteChats.isNotEmpty)
renderFurther(context, ref, spaceIdOrAlias, null),
Expand Down
19 changes: 18 additions & 1 deletion app/lib/features/space/widgets/related/chats_helpers.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:acter/common/providers/space_providers.dart';
import 'package:acter/common/widgets/chat/convo_card.dart';
import 'package:acter/common/widgets/chat/convo_hierarchy_card.dart';
import 'package:acter/common/widgets/room/room_hierarchy_options_menu.dart';
import 'package:acter/router/utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
Expand All @@ -10,7 +11,15 @@ import 'package:skeletonizer/skeletonizer.dart';

final _log = Logger('a3::space::related::chats_helpers');

Widget chatsListUI(WidgetRef ref, List<String> chats, int chatsLimit) {
Widget chatsListUI(
WidgetRef ref,
String parentId,
List<String> chats,
int chatsLimit, {
bool showOptions = false,
}) {
final suggestedId =
ref.watch(suggestedIdsProvider(parentId)).valueOrNull ?? [];
return ListView.builder(
shrinkWrap: true,
itemCount: chatsLimit,
Expand All @@ -21,8 +30,16 @@ Widget chatsListUI(WidgetRef ref, List<String> chats, int chatsLimit) {
return ConvoCard(
roomId: roomId,
showParents: false,
showSuggestedMark: suggestedId.contains(roomId),
showSelectedIndication: false,
onTap: () => goToChat(context, roomId),
trailing: showOptions
? RoomHierarchyOptionsMenu(
isSuggested: suggestedId.contains(roomId),
childId: roomId,
parentId: parentId,
)
: null,
);
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,13 @@ class ChatsSection extends ConsumerWidget {
pathParameters: {'spaceId': spaceId},
),
),
chatsListUI(ref, chats, config.listingLimit),
chatsListUI(
ref,
spaceId,
chats,
config.listingLimit,
showOptions: false,
),
if (config.renderRemote)
renderFurther(
context,
Expand Down

0 comments on commit 8ff28ef

Please sign in to comment.