Skip to content

Commit 43b8773

Browse files
fix: transform pubkeys to hex before using rust crate
1 parent 5f916b3 commit 43b8773

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

lib/ui/user_profile_list/group_chat_details_sheet.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import 'package:whitenoise/ui/core/ui/wn_text_field.dart';
1818
import 'package:whitenoise/ui/user_profile_list/safe_toast_mixin.dart';
1919
import 'package:whitenoise/ui/user_profile_list/share_invite_bottom_sheet.dart';
2020
import 'package:whitenoise/ui/user_profile_list/widgets/user_profile_tile.dart';
21+
import 'package:whitenoise/utils/pubkey_formatter.dart';
2122

2223
class GroupChatDetailsSheet extends ConsumerStatefulWidget {
2324
const GroupChatDetailsSheet({
@@ -181,7 +182,8 @@ class _GroupChatDetailsSheetState extends ConsumerState<GroupChatDetailsSheet> w
181182

182183
for (final userProfile in userProfiles) {
183184
try {
184-
final hasKeyPackage = await userHasKeyPackage(pubkey: userProfile.publicKey);
185+
final hexPubkey = PubkeyFormatter(pubkey: userProfile.publicKey).toHex();
186+
final hasKeyPackage = hexPubkey != null && await userHasKeyPackage(pubkey: hexPubkey);
185187

186188
if (hasKeyPackage) {
187189
userProfilesWithKeyPackage.add(userProfile);

lib/ui/user_profile_list/start_chat_bottom_sheet.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import 'package:whitenoise/ui/core/ui/wn_image.dart';
2323
import 'package:whitenoise/ui/user_profile_list/widgets/share_invite_button.dart';
2424
import 'package:whitenoise/ui/user_profile_list/widgets/share_invite_callout.dart';
2525
import 'package:whitenoise/ui/user_profile_list/widgets/user_profile_card.dart';
26+
import 'package:whitenoise/utils/pubkey_formatter.dart';
2627

2728
// User API interface for testing
2829
abstract class WnUsersApi {
@@ -35,7 +36,10 @@ class DefaultWnUsersApi implements WnUsersApi {
3536

3637
@override
3738
Future<bool> userHasKeyPackage({required String pubkey}) {
38-
return wn_users_api.userHasKeyPackage(pubkey: pubkey);
39+
final hexPubkey = PubkeyFormatter(pubkey: pubkey).toHex();
40+
if (hexPubkey == null) return Future.value(false);
41+
42+
return wn_users_api.userHasKeyPackage(pubkey: hexPubkey);
3943
}
4044
}
4145

@@ -125,14 +129,15 @@ class _StartChatBottomSheetState extends ConsumerState<StartChatBottomSheet> {
125129
});
126130

127131
try {
132+
final userHexPubkey = PubkeyFormatter(pubkey: widget.userProfile.publicKey).toHex() ?? '';
128133
final group = await ref
129134
.read(groupsProvider.notifier)
130135
.createNewGroup(
131136
groupName: '',
132137
groupDescription: '',
133138
isDm: true,
134-
memberPublicKeyHexs: [widget.userProfile.publicKey],
135-
adminPublicKeyHexs: [widget.userProfile.publicKey],
139+
memberPublicKeyHexs: [userHexPubkey],
140+
adminPublicKeyHexs: [userHexPubkey],
136141
);
137142

138143
if (group != null) {

0 commit comments

Comments
 (0)