1
1
import { Avatar } from "@/components/Avatar" ;
2
2
import {
3
- useAccountsList ,
4
3
useAccountsStore ,
5
- useCurrentAccount ,
4
+ useActiveSenderProfile ,
5
+ useCurrentProfiles ,
6
+ useSafeCurrentSender ,
6
7
} from "@/features/multi-inbox/multi-inbox.store" ;
7
8
import { Center } from "@/design-system/Center" ;
8
9
import { HStack } from "@/design-system/HStack" ;
@@ -11,15 +12,11 @@ import { Icon, iconRegistry } from "@/design-system/Icon/Icon";
11
12
import { Pressable } from "@/design-system/Pressable" ;
12
13
import { Text } from "@/design-system/Text" ;
13
14
import { DropdownMenu } from "@/design-system/dropdown-menu/dropdown-menu" ;
14
- import { useSafeCurrentAccountInboxId } from "@/hooks/use-current-account-inbox-id" ;
15
15
import { usePreferredInboxAvatar } from "@/hooks/usePreferredInboxAvatar" ;
16
- import { useInboxName } from "@/hooks/useInboxName" ;
17
16
import { translate } from "@/i18n" ;
18
17
import { useHeader } from "@/navigation/use-header" ;
19
18
import { ThemedStyle , useAppTheme } from "@/theme/useAppTheme" ;
20
19
import { converseEventEmitter } from "@/utils/events" ;
21
- import { shortDisplayName } from "@/utils/str" ;
22
- import { useAccountsProfiles } from "@/utils/useAccountsProfiles" ;
23
20
import { useNavigation } from "@react-navigation/native" ;
24
21
import React , { useCallback } from "react" ;
25
22
import { Alert , ViewStyle } from "react-native" ;
@@ -68,10 +65,10 @@ function HeaderRightActions() {
68
65
function HeaderTitle ( ) {
69
66
const { theme, themed } = useAppTheme ( ) ;
70
67
const navigation = useNavigation ( ) ;
71
- const currentAccount = useCurrentAccount ( ) ;
72
- const preferredName = useInboxName ( currentAccount ! ) ;
73
- const accountsProfilesNames = useAccountsProfiles ( ) ;
74
- const accounts = useAccountsList ( ) ;
68
+ const currentAccountInboxId = useSafeCurrentSender ( ) . inboxId ;
69
+ const { data : currentProfile } = useActiveSenderProfile ( ) ;
70
+ const { currentProfiles } = useCurrentProfiles ( ) ;
71
+
75
72
const setCurrentAccount = useAccountsStore ( ( s ) => s . setCurrentAccount ) ;
76
73
77
74
const onDropdownPress = useCallback (
@@ -99,10 +96,13 @@ function HeaderTitle() {
99
96
style = { themed ( $dropDownMenu ) }
100
97
onPress = { onDropdownPress }
101
98
actions = { [
102
- ...accountsProfilesNames . map ( ( profilePreferedName , index ) => ( {
103
- id : accounts [ index ] ,
104
- title : shortDisplayName ( profilePreferedName ) ,
105
- image : currentAccount === accounts [ index ] ? "checkmark" : "" ,
99
+ ...currentProfiles ?. map ( ( profile ) => ( {
100
+ id : profile . id ,
101
+ title : profile . name ,
102
+ image :
103
+ currentAccountInboxId === profile . deviceIdentity . xmtpId
104
+ ? "checkmark"
105
+ : "" ,
106
106
} ) ) ,
107
107
{
108
108
displayInline : true ,
@@ -119,7 +119,7 @@ function HeaderTitle() {
119
119
] }
120
120
>
121
121
< HStack style = { themed ( $rowContainer ) } >
122
- < Text > { shortDisplayName ( preferredName ) } </ Text >
122
+ < Text > { currentProfile ?. name } </ Text >
123
123
< Center style = { themed ( $iconContainer ) } >
124
124
< Icon
125
125
color = { theme . colors . text . secondary }
@@ -136,7 +136,7 @@ function HeaderTitle() {
136
136
function ProfileAvatar ( ) {
137
137
const { theme, themed } = useAppTheme ( ) ;
138
138
const navigation = useNavigation ( ) ;
139
- const currentAccountInboxId = useSafeCurrentAccountInboxId ( ) ;
139
+ const currentAccountInboxId = useSafeCurrentSender ( ) . inboxId ;
140
140
const { data : preferredName } = useInboxName ( {
141
141
inboxId : currentAccountInboxId ,
142
142
} ) ;
0 commit comments