Skip to content

Commit

Permalink
Merge pull request #2190 from bitfriend/activate-integration-test
Browse files Browse the repository at this point in the history
[smallfix] Miscellaneous fixes
  • Loading branch information
bitfriend authored Sep 19, 2024
2 parents 6088a6b + 35999d0 commit 4edf38e
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 51 deletions.
2 changes: 1 addition & 1 deletion app/lib/common/providers/room_providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ final joinRulesAllowedRoomsProvider = FutureProvider.autoDispose
.family<List<String>, String>((ref, roomId) async {
final room = await ref.watch(maybeRoomProvider(roomId).future);
if (room == null) return [];
return room.restrictedRoomIdsStr().map((e) => e.toDartString()).toList();
return asDartStringList(room.restrictedRoomIdsStr());
});

/// Get the user’s membership for a specific space based off the roomId
Expand Down
4 changes: 1 addition & 3 deletions app/lib/common/utils/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,7 @@ String? getIssueId(String url) {

///helper function to convert list ffiString object to DartString.
List<String> asDartStringList(FfiListFfiString data) {
if (data.isEmpty) {
return [];
}
if (data.isEmpty) return [];
return data.toList().map((e) => e.toDartString()).toList();
}

Expand Down
3 changes: 2 additions & 1 deletion app/lib/features/bookmarks/providers/bookmarks_provider.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:acter/common/utils/utils.dart';
import 'package:acter/features/bookmarks/providers/notifiers.dart';
import 'package:acter/features/bookmarks/types.dart';
import 'package:acter_flutter_sdk/acter_flutter_sdk_ffi.dart';
Expand All @@ -11,7 +12,7 @@ final bookmarksManagerProvider =
final bookmarkByTypeProvider =
FutureProvider.family<List<String>, BookmarkType>((ref, type) async {
final bookmarks = await ref.watch(bookmarksManagerProvider.future);
return (bookmarks.entries(type.name)).map((s) => s.toDartString()).toList();
return asDartStringList(bookmarks.entries(type.name));
});

final isBookmarkedProvider =
Expand Down
36 changes: 12 additions & 24 deletions app/lib/features/chat/providers/notifiers/chat_room_notifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -465,12 +465,9 @@ class ChatRoomNotifier extends StateNotifier<ChatRoomState> {

// user read receipts for timeline event item
Map<String, int> receipts = {};
for (final userId in eventItem.readUsers()) {
String id = userId.toDartString();
final ts = eventItem.receiptTs(id);
if (ts != null) {
receipts[id] = ts;
}
for (final userId in asDartStringList(eventItem.readUsers())) {
final ts = eventItem.receiptTs(userId);
if (ts != null) receipts[userId] = ts;
}

// state event
Expand Down Expand Up @@ -575,12 +572,9 @@ class ChatRoomNotifier extends StateNotifier<ChatRoomState> {
break;
case 'm.room.message':
Map<String, dynamic> reactions = {};
for (final key in eventItem.reactionKeys()) {
String k = key.toDartString();
final records = eventItem.reactionRecords(k);
if (records != null) {
reactions[k] = records.toList();
}
for (final key in asDartStringList(eventItem.reactionKeys())) {
final records = eventItem.reactionRecords(key);
if (records != null) reactions[key] = records.toList();
}
String? msgType = eventItem.msgType();
switch (msgType) {
Expand Down Expand Up @@ -810,20 +804,14 @@ class ChatRoomNotifier extends StateNotifier<ChatRoomState> {
break;
case 'm.sticker':
Map<String, dynamic> receipts = {};
for (final userId in eventItem.readUsers()) {
String id = userId.toDartString();
final ts = eventItem.receiptTs(id);
if (ts != null) {
receipts[id] = ts;
}
for (final userId in asDartStringList(eventItem.readUsers())) {
final ts = eventItem.receiptTs(userId);
if (ts != null) receipts[userId] = ts;
}
Map<String, dynamic> reactions = {};
for (final key in eventItem.reactionKeys()) {
String k = key.toDartString();
final records = eventItem.reactionRecords(k);
if (records != null) {
reactions[k] = records.toList();
}
for (final key in asDartStringList(eventItem.reactionKeys())) {
final records = eventItem.reactionRecords(key);
if (records != null) reactions[key] = records.toList();
}
MsgContent? msgContent = eventItem.msgContent();
if (msgContent != null) {
Expand Down
7 changes: 3 additions & 4 deletions app/lib/features/member/widgets/user_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:typed_data';

import 'package:acter/common/providers/room_providers.dart';
import 'package:acter/common/themes/colors/color_scheme.dart';
import 'package:acter/common/utils/utils.dart';
import 'package:acter_avatar/acter_avatar.dart';
import 'package:acter_flutter_sdk/acter_flutter_sdk_ffi.dart';
import 'package:atlas_icons/atlas_icons.dart';
Expand Down Expand Up @@ -134,10 +135,8 @@ class UserBuilder extends ConsumerWidget {

Widget _buildSharedRooms(BuildContext context, Widget tile) {
final sharedRooms =
userProfile?.sharedRooms().map((s) => s.toDartString()).toList() ?? [];
if (sharedRooms.isEmpty) {
return tile;
}
userProfile.let((p0) => asDartStringList(p0.sharedRooms())) ?? [];
if (sharedRooms.isEmpty) return tile;

const style = TextStyle(fontStyle: FontStyle.italic);

Expand Down
4 changes: 3 additions & 1 deletion app/lib/features/super_invites/pages/create.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:acter/common/providers/room_providers.dart';
import 'package:acter/common/toolkit/buttons/danger_action_button.dart';
import 'package:acter/common/toolkit/buttons/primary_action_button.dart';
import 'package:acter/common/utils/routes.dart';
import 'package:acter/common/utils/utils.dart';
import 'package:acter/common/widgets/chat/chat_selector_drawer.dart';
import 'package:acter/common/widgets/checkbox_form_field.dart';
import 'package:acter/common/widgets/input_text_field.dart';
Expand All @@ -28,6 +29,7 @@ class CreateSuperInviteTokenPage extends ConsumerStatefulWidget {
static Key submitBtn = const Key('super-invites-create-submitBtn');
static Key deleteBtn = const Key('super-invites-create-delete');
static Key deleteConfirm = const Key('super-invites-create-delete-confirm');

final SuperInviteToken? token;

const CreateSuperInviteTokenPage({super.key, this.token});
Expand Down Expand Up @@ -58,7 +60,7 @@ class _CreateSuperInviteTokenPageConsumerState
isEdit = true;
final token = widget.token!;
_tokenController.text = token.token();
_roomIds = token.rooms().map((e) => e.toDartString()).toList();
_roomIds = asDartStringList(token.rooms());
_acceptedCount = token.acceptedCount();
_initialDmCheck = token.createDm();
tokenUpdater = token.updateBuilder();
Expand Down
3 changes: 2 additions & 1 deletion app/lib/features/super_invites/pages/super_invites.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:acter/common/utils/routes.dart';
import 'package:acter/common/utils/utils.dart';
import 'package:acter/common/widgets/with_sidebar.dart';
import 'package:acter/features/settings/pages/settings_page.dart';
import 'package:acter/features/super_invites/providers/super_invites_providers.dart';
Expand Down Expand Up @@ -67,7 +68,7 @@ class SuperInvitesPage extends ConsumerWidget {
L10n.of(context).usedTimes(token.acceptedCount());
final tokenStr = token.token().toString();
final firstRoom =
token.rooms().map((t) => t.toDartString()).firstOrNull;
asDartStringList(token.rooms()).firstOrNull;
return Card(
key: Key('edit-token-$tokenStr'),
margin: const EdgeInsets.all(5),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:acter/common/utils/utils.dart';
import 'package:acter/features/home/providers/client_providers.dart';
import 'package:acter_flutter_sdk/acter_flutter_sdk_ffi.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
Expand Down Expand Up @@ -33,10 +34,7 @@ final superInvitesForRoom = FutureProvider.autoDispose
.family<List<SuperInviteToken>, String>((ref, roomId) async {
final allInvites = await ref.watch(superInvitesTokensProvider.future);
return allInvites
.where(
(invite) =>
invite.rooms().map((e) => e.toDartString()).contains(roomId),
)
.where((invite) => asDartStringList(invite.rooms()).contains(roomId))
.toList();
});

Expand Down
13 changes: 6 additions & 7 deletions app/lib/features/tasks/pages/task_item_detail_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -400,22 +400,21 @@ class TaskItemDetailPage extends ConsumerWidget {
}

Widget assigneeName(BuildContext context, Task task, WidgetRef ref) {
final assignees = task.assigneesStr().map((s) => s.toDartString()).toList();
final assignees = asDartStringList(task.assigneesStr());
final roomId = task.roomIdStr();

return Wrap(
direction: Axis.horizontal,
children: assignees.map((i) {
final displayName = ref
.watch(
memberDisplayNameProvider((roomId: task.roomIdStr(), userId: i)),
)
children: assignees.map((userId) {
final dispName = ref
.watch(memberDisplayNameProvider((roomId: roomId, userId: userId)))
.valueOrNull;
return Padding(
padding: const EdgeInsets.only(right: 8),
child: Chip(
labelPadding: EdgeInsets.zero,
label: Text(
displayName ?? i,
dispName ?? userId,
style: Theme.of(context).textTheme.bodyMedium,
),
),
Expand Down
9 changes: 4 additions & 5 deletions app/lib/features/tasks/widgets/task_item.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:acter/common/providers/room_providers.dart';
import 'package:acter/common/utils/routes.dart';
import 'package:acter/common/utils/utils.dart';
import 'package:acter/common/widgets/room/room_avatar_builder.dart';
import 'package:acter/features/tasks/providers/task_items_providers.dart';
import 'package:acter/features/tasks/providers/tasklists_providers.dart';
Expand Down Expand Up @@ -199,14 +200,12 @@ class TaskItem extends ConsumerWidget {
}

Widget? taskAssignee(WidgetRef ref, Task task) {
final assignees = task.assigneesStr().map((s) => s.toDartString()).toList();

final assignees = asDartStringList(task.assigneesStr());
if (assignees.isEmpty) return null;

final roomId = task.roomIdStr();
final avatarInfo = ref.watch(
memberAvatarInfoProvider(
(roomId: task.roomIdStr(), userId: assignees.first),
),
memberAvatarInfoProvider((roomId: roomId, userId: assignees.first)),
);

return ActerAvatar(
Expand Down

0 comments on commit 4edf38e

Please sign in to comment.