@oxyhq/services 13.0.1 → 13.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/lib/commonjs/ui/hooks/queries/useAccountQueries.js +5 -2
  2. package/lib/commonjs/ui/hooks/queries/useAccountQueries.js.map +1 -1
  3. package/lib/commonjs/ui/hooks/queries/usePaymentQueries.js +12 -12
  4. package/lib/commonjs/ui/hooks/queries/usePaymentQueries.js.map +1 -1
  5. package/lib/commonjs/ui/screens/EditProfileFieldScreen.js +8 -5
  6. package/lib/commonjs/ui/screens/EditProfileFieldScreen.js.map +1 -1
  7. package/lib/commonjs/ui/screens/FileManagementScreen.js +16 -13
  8. package/lib/commonjs/ui/screens/FileManagementScreen.js.map +1 -1
  9. package/lib/commonjs/ui/screens/HistoryViewScreen.js +9 -7
  10. package/lib/commonjs/ui/screens/HistoryViewScreen.js.map +1 -1
  11. package/lib/commonjs/ui/screens/LanguageSelectorScreen.js +6 -4
  12. package/lib/commonjs/ui/screens/LanguageSelectorScreen.js.map +1 -1
  13. package/lib/commonjs/ui/screens/ManageAccountScreen.js +18 -12
  14. package/lib/commonjs/ui/screens/ManageAccountScreen.js.map +1 -1
  15. package/lib/commonjs/ui/screens/PremiumSubscriptionScreen.js +5 -4
  16. package/lib/commonjs/ui/screens/PremiumSubscriptionScreen.js.map +1 -1
  17. package/lib/commonjs/ui/screens/PrivacySettingsScreen.js +12 -7
  18. package/lib/commonjs/ui/screens/PrivacySettingsScreen.js.map +1 -1
  19. package/lib/commonjs/ui/screens/ProfileScreen.js +5 -2
  20. package/lib/commonjs/ui/screens/ProfileScreen.js.map +1 -1
  21. package/lib/commonjs/ui/screens/SavesCollectionsScreen.js +6 -5
  22. package/lib/commonjs/ui/screens/SavesCollectionsScreen.js.map +1 -1
  23. package/lib/commonjs/ui/screens/SearchSettingsScreen.js +7 -4
  24. package/lib/commonjs/ui/screens/SearchSettingsScreen.js.map +1 -1
  25. package/lib/commonjs/ui/screens/WelcomeNewUserScreen.js +10 -7
  26. package/lib/commonjs/ui/screens/WelcomeNewUserScreen.js.map +1 -1
  27. package/lib/commonjs/ui/screens/trust/TrustCenterScreen.js +6 -5
  28. package/lib/commonjs/ui/screens/trust/TrustCenterScreen.js.map +1 -1
  29. package/lib/commonjs/ui/screens/trust/TrustRewardsScreen.js +6 -4
  30. package/lib/commonjs/ui/screens/trust/TrustRewardsScreen.js.map +1 -1
  31. package/lib/module/ui/hooks/queries/useAccountQueries.js +5 -2
  32. package/lib/module/ui/hooks/queries/useAccountQueries.js.map +1 -1
  33. package/lib/module/ui/hooks/queries/usePaymentQueries.js +12 -12
  34. package/lib/module/ui/hooks/queries/usePaymentQueries.js.map +1 -1
  35. package/lib/module/ui/screens/EditProfileFieldScreen.js +8 -5
  36. package/lib/module/ui/screens/EditProfileFieldScreen.js.map +1 -1
  37. package/lib/module/ui/screens/FileManagementScreen.js +16 -13
  38. package/lib/module/ui/screens/FileManagementScreen.js.map +1 -1
  39. package/lib/module/ui/screens/HistoryViewScreen.js +9 -7
  40. package/lib/module/ui/screens/HistoryViewScreen.js.map +1 -1
  41. package/lib/module/ui/screens/LanguageSelectorScreen.js +6 -4
  42. package/lib/module/ui/screens/LanguageSelectorScreen.js.map +1 -1
  43. package/lib/module/ui/screens/ManageAccountScreen.js +18 -12
  44. package/lib/module/ui/screens/ManageAccountScreen.js.map +1 -1
  45. package/lib/module/ui/screens/PremiumSubscriptionScreen.js +5 -4
  46. package/lib/module/ui/screens/PremiumSubscriptionScreen.js.map +1 -1
  47. package/lib/module/ui/screens/PrivacySettingsScreen.js +12 -7
  48. package/lib/module/ui/screens/PrivacySettingsScreen.js.map +1 -1
  49. package/lib/module/ui/screens/ProfileScreen.js +5 -2
  50. package/lib/module/ui/screens/ProfileScreen.js.map +1 -1
  51. package/lib/module/ui/screens/SavesCollectionsScreen.js +6 -5
  52. package/lib/module/ui/screens/SavesCollectionsScreen.js.map +1 -1
  53. package/lib/module/ui/screens/SearchSettingsScreen.js +7 -4
  54. package/lib/module/ui/screens/SearchSettingsScreen.js.map +1 -1
  55. package/lib/module/ui/screens/WelcomeNewUserScreen.js +10 -7
  56. package/lib/module/ui/screens/WelcomeNewUserScreen.js.map +1 -1
  57. package/lib/module/ui/screens/trust/TrustCenterScreen.js +6 -5
  58. package/lib/module/ui/screens/trust/TrustCenterScreen.js.map +1 -1
  59. package/lib/module/ui/screens/trust/TrustRewardsScreen.js +6 -4
  60. package/lib/module/ui/screens/trust/TrustRewardsScreen.js.map +1 -1
  61. package/lib/typescript/commonjs/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
  62. package/lib/typescript/commonjs/ui/screens/EditProfileFieldScreen.d.ts.map +1 -1
  63. package/lib/typescript/commonjs/ui/screens/FileManagementScreen.d.ts.map +1 -1
  64. package/lib/typescript/commonjs/ui/screens/HistoryViewScreen.d.ts.map +1 -1
  65. package/lib/typescript/commonjs/ui/screens/LanguageSelectorScreen.d.ts.map +1 -1
  66. package/lib/typescript/commonjs/ui/screens/ManageAccountScreen.d.ts.map +1 -1
  67. package/lib/typescript/commonjs/ui/screens/PremiumSubscriptionScreen.d.ts.map +1 -1
  68. package/lib/typescript/commonjs/ui/screens/PrivacySettingsScreen.d.ts.map +1 -1
  69. package/lib/typescript/commonjs/ui/screens/ProfileScreen.d.ts.map +1 -1
  70. package/lib/typescript/commonjs/ui/screens/SavesCollectionsScreen.d.ts.map +1 -1
  71. package/lib/typescript/commonjs/ui/screens/SearchSettingsScreen.d.ts.map +1 -1
  72. package/lib/typescript/commonjs/ui/screens/WelcomeNewUserScreen.d.ts.map +1 -1
  73. package/lib/typescript/commonjs/ui/screens/trust/TrustCenterScreen.d.ts.map +1 -1
  74. package/lib/typescript/commonjs/ui/screens/trust/TrustRewardsScreen.d.ts.map +1 -1
  75. package/lib/typescript/module/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
  76. package/lib/typescript/module/ui/screens/EditProfileFieldScreen.d.ts.map +1 -1
  77. package/lib/typescript/module/ui/screens/FileManagementScreen.d.ts.map +1 -1
  78. package/lib/typescript/module/ui/screens/HistoryViewScreen.d.ts.map +1 -1
  79. package/lib/typescript/module/ui/screens/LanguageSelectorScreen.d.ts.map +1 -1
  80. package/lib/typescript/module/ui/screens/ManageAccountScreen.d.ts.map +1 -1
  81. package/lib/typescript/module/ui/screens/PremiumSubscriptionScreen.d.ts.map +1 -1
  82. package/lib/typescript/module/ui/screens/PrivacySettingsScreen.d.ts.map +1 -1
  83. package/lib/typescript/module/ui/screens/ProfileScreen.d.ts.map +1 -1
  84. package/lib/typescript/module/ui/screens/SavesCollectionsScreen.d.ts.map +1 -1
  85. package/lib/typescript/module/ui/screens/SearchSettingsScreen.d.ts.map +1 -1
  86. package/lib/typescript/module/ui/screens/WelcomeNewUserScreen.d.ts.map +1 -1
  87. package/lib/typescript/module/ui/screens/trust/TrustCenterScreen.d.ts.map +1 -1
  88. package/lib/typescript/module/ui/screens/trust/TrustRewardsScreen.d.ts.map +1 -1
  89. package/package.json +1 -1
  90. package/src/ui/hooks/queries/useAccountQueries.ts +5 -2
  91. package/src/ui/hooks/queries/usePaymentQueries.ts +12 -12
  92. package/src/ui/screens/EditProfileFieldScreen.tsx +8 -5
  93. package/src/ui/screens/FileManagementScreen.tsx +16 -13
  94. package/src/ui/screens/HistoryViewScreen.tsx +9 -7
  95. package/src/ui/screens/LanguageSelectorScreen.tsx +6 -4
  96. package/src/ui/screens/ManageAccountScreen.tsx +18 -12
  97. package/src/ui/screens/PremiumSubscriptionScreen.tsx +5 -4
  98. package/src/ui/screens/PrivacySettingsScreen.tsx +12 -7
  99. package/src/ui/screens/ProfileScreen.tsx +5 -2
  100. package/src/ui/screens/SavesCollectionsScreen.tsx +7 -6
  101. package/src/ui/screens/SearchSettingsScreen.tsx +7 -4
  102. package/src/ui/screens/WelcomeNewUserScreen.tsx +10 -7
  103. package/src/ui/screens/trust/TrustCenterScreen.tsx +7 -6
  104. package/src/ui/screens/trust/TrustRewardsScreen.tsx +6 -4
@@ -89,6 +89,7 @@ const ManageAccountScreen: React.FC<BaseScreenProps> = ({
89
89
  const { t, locale } = useI18n();
90
90
  const {
91
91
  user: contextUser,
92
+ activeAccount,
92
93
  isAuthenticated,
93
94
  oxyServices,
94
95
  activeSessionId,
@@ -100,6 +101,11 @@ const ManageAccountScreen: React.FC<BaseScreenProps> = ({
100
101
  const { data: userFromQuery, isLoading: userLoading } = useCurrentUser({
101
102
  enabled: isAuthenticated,
102
103
  });
104
+ // `user` is the device-session OWNER (the human login) — used only for
105
+ // account/session MANAGEMENT and GDPR-level actions (sign-out, device
106
+ // sessions, download-data, delete-account). Identity-of-me surfaces (the
107
+ // profile header, preview-profile target, premium state) read
108
+ // `activeAccount` so a switch into an org/project/bot is reflected here.
103
109
  const user = userFromQuery ?? contextUser;
104
110
 
105
111
  const { data: subscription } = useUserSubscription({ enabled: isAuthenticated });
@@ -121,13 +127,13 @@ const ManageAccountScreen: React.FC<BaseScreenProps> = ({
121
127
  const [signingOutAllDevices, setSigningOutAllDevices] = useState(false);
122
128
  const [signingOut, setSigningOut] = useState(false);
123
129
 
124
- const displayName = useMemo(() => getAccountDisplayName(user, locale), [user, locale]);
125
- const handle = useMemo(() => getAccountFallbackHandle(user), [user]);
130
+ const displayName = useMemo(() => getAccountDisplayName(activeAccount, locale), [activeAccount, locale]);
131
+ const handle = useMemo(() => getAccountFallbackHandle(activeAccount), [activeAccount]);
126
132
  const avatarUri = useMemo(() => {
127
- return user?.avatar
128
- ? oxyServices.getFileDownloadUrl(user.avatar, 'thumb')
133
+ return activeAccount?.avatar
134
+ ? oxyServices.getFileDownloadUrl(activeAccount.avatar, 'thumb')
129
135
  : undefined;
130
- }, [user?.avatar, oxyServices]);
136
+ }, [activeAccount?.avatar, oxyServices]);
131
137
 
132
138
  const handleSignOut = useCallback(async () => {
133
139
  if (signingOut) {
@@ -355,12 +361,12 @@ const ManageAccountScreen: React.FC<BaseScreenProps> = ({
355
361
  </H4>
356
362
  {handle ? (
357
363
  <Text className="text-text-secondary text-sm mt-space-2" numberOfLines={1}>
358
- {user?.username ? `@${handle}` : handle}
364
+ {activeAccount?.username ? `@${handle}` : handle}
359
365
  </Text>
360
366
  ) : null}
361
- {user?.email ? (
367
+ {activeAccount?.email ? (
362
368
  <Text className="text-text-secondary text-sm mt-space-2" numberOfLines={1}>
363
- {user.email}
369
+ {activeAccount.email}
364
370
  </Text>
365
371
  ) : null}
366
372
  </View>
@@ -412,9 +418,9 @@ const ManageAccountScreen: React.FC<BaseScreenProps> = ({
412
418
  || 'See how your profile looks to others'
413
419
  }
414
420
  onPress={() =>
415
- user?.id ? navigate?.('Profile', { userId: user.id }) : undefined
421
+ activeAccount?.id ? navigate?.('Profile', { userId: activeAccount.id }) : undefined
416
422
  }
417
- disabled={!user?.id}
423
+ disabled={!activeAccount?.id}
418
424
  />
419
425
  <SettingsListItem
420
426
  icon={
@@ -581,13 +587,13 @@ const ManageAccountScreen: React.FC<BaseScreenProps> = ({
581
587
  t('accountOverview.items.premium.title') || 'Oxy+'
582
588
  }
583
589
  description={
584
- user?.isPremium
590
+ activeAccount?.isPremium
585
591
  ? (t('accountOverview.items.premium.manage') || 'Manage your premium plan')
586
592
  : (t('accountOverview.items.premium.upgrade') || 'Upgrade to premium features')
587
593
  }
588
594
  onPress={() => navigate?.('PremiumSubscription')}
589
595
  />
590
- {user?.isPremium || subscription?.status === 'active' ? (
596
+ {activeAccount?.isPremium || subscription?.status === 'active' ? (
591
597
  <SettingsListItem
592
598
  icon={
593
599
  <SettingsIcon
@@ -91,8 +91,9 @@ const PremiumSubscriptionScreen: React.FC<BaseScreenProps> = ({
91
91
  navigate,
92
92
  goBack,
93
93
  }) => {
94
- // Use useOxy() hook for OxyContext values
95
- const { user } = useOxy();
94
+ // Premium state belongs to the ACTIVE account (the org/project/bot when
95
+ // switched, else the personal user), not the device-session owner.
96
+ const { activeAccount } = useOxy();
96
97
  const [loading, setLoading] = useState(true);
97
98
  const [subscription, setSubscription] = useState<UserSubscription | null>(null);
98
99
  const [plans, setPlans] = useState<SubscriptionPlan[]>([]);
@@ -328,7 +329,7 @@ const PremiumSubscriptionScreen: React.FC<BaseScreenProps> = ({
328
329
  if (currentAppPackage) {
329
330
  loadSubscriptionData();
330
331
  }
331
- }, [currentAppPackage, user?.isPremium]);
332
+ }, [currentAppPackage, activeAccount?.isPremium]);
332
333
 
333
334
  const detectCurrentApp = () => {
334
335
  const detectedApp = 'mention';
@@ -345,7 +346,7 @@ const PremiumSubscriptionScreen: React.FC<BaseScreenProps> = ({
345
346
  setPlans(availablePlans);
346
347
 
347
348
  let currentSubscription: UserSubscription | null = null;
348
- if (user?.isPremium) {
349
+ if (activeAccount?.isPremium) {
349
350
  currentSubscription = {
350
351
  id: 'sub_12345',
351
352
  planId: 'oxy-insider',
@@ -65,7 +65,9 @@ const PrivacySettingsScreen: React.FC<BaseScreenProps> = ({
65
65
  onClose,
66
66
  goBack,
67
67
  }) => {
68
- const { oxyServices, user } = useOxy();
68
+ // Privacy settings belong to the ACTIVE account (the org/project/bot when
69
+ // switched, else the personal user).
70
+ const { oxyServices, activeAccount } = useOxy();
69
71
  const { t, locale } = useI18n();
70
72
  const bloomTheme = useTheme();
71
73
  const [isLoading, setIsLoading] = useState(true);
@@ -77,8 +79,8 @@ const PrivacySettingsScreen: React.FC<BaseScreenProps> = ({
77
79
  const { values: settings, toggle, savingKeys, setValues } = useSettingToggles<PrivacySettings>({
78
80
  initialValues: DEFAULT_PRIVACY_SETTINGS,
79
81
  onSave: async (key, value) => {
80
- if (!user?.id || !oxyServices) return;
81
- await oxyServices.updatePrivacySettings({ [key]: value }, user.id);
82
+ if (!activeAccount?.id || !oxyServices) return;
83
+ await oxyServices.updatePrivacySettings({ [key]: value }, activeAccount.id);
82
84
  },
83
85
  errorMessage: t('privacySettings.updateError') || 'Failed to update privacy setting',
84
86
  });
@@ -90,8 +92,8 @@ const PrivacySettingsScreen: React.FC<BaseScreenProps> = ({
90
92
  const loadSettings = async () => {
91
93
  try {
92
94
  setIsLoading(true);
93
- if (user?.id && oxyServices) {
94
- const privacySettings = await oxyServices.getPrivacySettings(user.id);
95
+ if (activeAccount?.id && oxyServices) {
96
+ const privacySettings = await oxyServices.getPrivacySettings(activeAccount.id);
95
97
  if (privacySettings) {
96
98
  setValues(privacySettings);
97
99
  }
@@ -107,7 +109,7 @@ const PrivacySettingsScreen: React.FC<BaseScreenProps> = ({
107
109
  };
108
110
 
109
111
  loadSettings();
110
- }, [user?.id, oxyServices, t, setValues]);
112
+ }, [activeAccount?.id, oxyServices, t, setValues]);
111
113
 
112
114
  // Load blocked and restricted users
113
115
  useEffect(() => {
@@ -131,7 +133,10 @@ const PrivacySettingsScreen: React.FC<BaseScreenProps> = ({
131
133
  };
132
134
 
133
135
  loadUsers();
134
- }, [oxyServices]);
136
+ // Re-load when the active account changes so the block/restrict lists
137
+ // reflect the account currently switched into (they resolve via the
138
+ // X-Acting-As header).
139
+ }, [oxyServices, activeAccount?.id]);
135
140
 
136
141
  const handleUnblock = useCallback(async (userId: string) => {
137
142
  if (!oxyServices) return;
@@ -27,8 +27,11 @@ const AVATAR_OVERLAP = -56;
27
27
  const INFO_ICON_SIZE = 18;
28
28
 
29
29
  const ProfileScreen: React.FC<ProfileScreenProps> = ({ userId, username, theme, goBack, navigate }) => {
30
- // Use useOxy() hook for OxyContext values
31
- const { oxyServices, user: currentUser } = useOxy();
30
+ // Use useOxy() hook for OxyContext values. "Me" for own-profile detection
31
+ // and the own-profile fallback is the ACTIVE account (the account switched
32
+ // into), so previewing my profile while switched into an org/project/bot
33
+ // resolves "this is mine" against that account, not the session owner.
34
+ const { oxyServices, activeAccount: currentUser } = useOxy();
32
35
  const [profile, setProfile] = useState<User | null>(null);
33
36
  const [reputationTotal, setReputationTotal] = useState<number | null>(null);
34
37
  const [postsCount, setPostsCount] = useState<number | null>(null);
@@ -38,8 +38,9 @@ const SavesCollectionsScreen: React.FC<BaseScreenProps> = ({
38
38
  onClose,
39
39
  goBack,
40
40
  }) => {
41
- // Use useOxy() hook for OxyContext values
42
- const { oxyServices, user } = useOxy();
41
+ // Saves & collections belong to the ACTIVE account (the org/project/bot when
42
+ // switched, else the personal user).
43
+ const { oxyServices, activeAccount } = useOxy();
43
44
  const { t } = useI18n();
44
45
  const bloomTheme = useTheme();
45
46
  const [savedItems, setSavedItems] = useState<SavedItem[]>([]);
@@ -52,10 +53,10 @@ const SavesCollectionsScreen: React.FC<BaseScreenProps> = ({
52
53
  const loadData = async () => {
53
54
  try {
54
55
  setIsLoading(true);
55
- if (user?.id && oxyServices) {
56
+ if (activeAccount?.id && oxyServices) {
56
57
  const [saved, cols] = await Promise.all([
57
- oxyServices.getSavedItems(user.id),
58
- oxyServices.getCollections(user.id),
58
+ oxyServices.getSavedItems(activeAccount.id),
59
+ oxyServices.getCollections(activeAccount.id),
59
60
  ]);
60
61
  setSavedItems(saved.map((item) => ({
61
62
  id: item.id,
@@ -79,7 +80,7 @@ const SavesCollectionsScreen: React.FC<BaseScreenProps> = ({
79
80
  };
80
81
 
81
82
  loadData();
82
- }, [user?.id, oxyServices, t]);
83
+ }, [activeAccount?.id, oxyServices, t]);
83
84
 
84
85
  const formatDate = (date: Date) => {
85
86
  return date.toLocaleDateString();
@@ -21,7 +21,10 @@ const SearchSettingsScreen: React.FC<BaseScreenProps> = ({
21
21
  onClose,
22
22
  goBack,
23
23
  }) => {
24
- const { oxyServices, user } = useOxy();
24
+ // Search settings are persisted on the ACTIVE account's profile (the
25
+ // org/project/bot when switched, else the personal user); the read/write
26
+ // route to it via the X-Acting-As header.
27
+ const { oxyServices, activeAccount } = useOxy();
25
28
  const { t } = useI18n();
26
29
  const bloomTheme = useTheme();
27
30
  const [isLoading, setIsLoading] = useState(true);
@@ -30,7 +33,7 @@ const SearchSettingsScreen: React.FC<BaseScreenProps> = ({
30
33
  const { values: settings, toggle, savingKeys, setValues } = useSettingToggles<SearchSettings>({
31
34
  initialValues: { safeSearch: false, searchPersonalization: true },
32
35
  onSave: async (key, value) => {
33
- if (!user?.id || !oxyServices) return;
36
+ if (!activeAccount?.id || !oxyServices) return;
34
37
 
35
38
  const fieldMap: Record<keyof SearchSettings, string> = {
36
39
  safeSearch: 'autoFilter',
@@ -53,7 +56,7 @@ const SearchSettingsScreen: React.FC<BaseScreenProps> = ({
53
56
  const loadSettings = async () => {
54
57
  try {
55
58
  setIsLoading(true);
56
- if (user?.id && oxyServices) {
59
+ if (activeAccount?.id && oxyServices) {
57
60
  const userData = await oxyServices.getCurrentUser() as User & { privacySettings?: { autoFilter?: boolean; dataSharing?: boolean } };
58
61
  const privacySettings = userData?.privacySettings || {};
59
62
 
@@ -72,7 +75,7 @@ const SearchSettingsScreen: React.FC<BaseScreenProps> = ({
72
75
  };
73
76
 
74
77
  loadSettings();
75
- }, [user?.id, oxyServices, setValues]);
78
+ }, [activeAccount?.id, oxyServices, setValues]);
76
79
 
77
80
  if (isLoading) {
78
81
  return (
@@ -63,11 +63,14 @@ const WelcomeNewUserScreen: React.FC<BaseScreenProps & { newUser?: any }> = ({
63
63
  theme,
64
64
  newUser,
65
65
  }) => {
66
- // Use useOxy() hook for OxyContext values
67
- const { user, oxyServices } = useOxy();
66
+ // Use useOxy() hook for OxyContext values. The greeting/avatar identity is
67
+ // the ACTIVE account (the personal user during onboarding, but read through
68
+ // `activeAccount` so this stays correct everywhere), with the freshly
69
+ // registered `newUser` as the pre-store-hydration fallback.
70
+ const { activeAccount, oxyServices } = useOxy();
68
71
  const { t, locale } = useI18n();
69
72
  const updateProfileMutation = useUpdateProfile();
70
- const currentUser = user || newUser; // fallback
73
+ const currentUser = activeAccount || newUser; // fallback
71
74
  const bloomTheme = useTheme();
72
75
  const colors = {
73
76
  primary: bloomTheme.colors.primary,
@@ -88,14 +91,14 @@ const WelcomeNewUserScreen: React.FC<BaseScreenProps & { newUser?: any }> = ({
88
91
  const [lastName, setLastName] = useState(() => (currentUser?.name?.last ?? '').trim());
89
92
  const [savingName, setSavingName] = useState(false);
90
93
 
91
- // Update selectedAvatarId when user changes
94
+ // Update selectedAvatarId when the active account's avatar changes
92
95
  useEffect(() => {
93
- if (user?.avatar) {
94
- setSelectedAvatarId(user.avatar);
96
+ if (activeAccount?.avatar) {
97
+ setSelectedAvatarId(activeAccount.avatar);
95
98
  } else if (newUser?.avatar) {
96
99
  setSelectedAvatarId(newUser.avatar);
97
100
  }
98
- }, [user?.avatar, newUser?.avatar]);
101
+ }, [activeAccount?.avatar, newUser?.avatar]);
99
102
 
100
103
  const avatarUri = selectedAvatarId ? oxyServices.getFileDownloadUrl(selectedAvatarId, 'thumb') : undefined;
101
104
 
@@ -20,8 +20,9 @@ const TrustCenterScreen: React.FC<BaseScreenProps> = ({
20
20
  goBack,
21
21
  navigate,
22
22
  }) => {
23
- // Use useOxy() hook for OxyContext values
24
- const { user, oxyServices, isAuthenticated } = useOxy();
23
+ // Reputation/trust is the ACTIVE account's standing (the org/project/bot
24
+ // when switched, else the personal user).
25
+ const { activeAccount, oxyServices, isAuthenticated } = useOxy();
25
26
  const { t } = useI18n();
26
27
  const [reputationTotal, setReputationTotal] = useState<number | null>(null);
27
28
  const [trustTier, setTrustTier] = useState<TrustTier | null>(null);
@@ -33,12 +34,12 @@ const TrustCenterScreen: React.FC<BaseScreenProps> = ({
33
34
  const primaryColor = bloomTheme.colors.primary;
34
35
 
35
36
  useEffect(() => {
36
- if (!user) return;
37
+ if (!activeAccount) return;
37
38
  setIsLoading(true);
38
39
  setError(null);
39
40
  Promise.all([
40
- oxyServices.getReputationBalance(user.id),
41
- oxyServices.getReputationTransactions(user.id, 20, 0),
41
+ oxyServices.getReputationBalance(activeAccount.id),
42
+ oxyServices.getReputationTransactions(activeAccount.id, 20, 0),
42
43
  ])
43
44
  .then(([balance, txns]) => {
44
45
  setReputationTotal(balance.total);
@@ -52,7 +53,7 @@ const TrustCenterScreen: React.FC<BaseScreenProps> = ({
52
53
  );
53
54
  })
54
55
  .finally(() => setIsLoading(false));
55
- }, [user, oxyServices, t]);
56
+ }, [activeAccount, oxyServices, t]);
56
57
 
57
58
  const trustTierLabel = useMemo(
58
59
  () => (trustTier ? getTrustTierLabel(trustTier, t) : null),
@@ -77,7 +77,9 @@ const LOCKED_OPACITY = 0.5;
77
77
 
78
78
  const TrustRewardsScreen: React.FC<BaseScreenProps> = ({ goBack }) => {
79
79
  const { t } = useI18n();
80
- const { user, oxyServices, isAuthenticated } = useOxy();
80
+ // Reputation/trust is the ACTIVE account's standing (the org/project/bot
81
+ // when switched, else the personal user).
82
+ const { activeAccount, oxyServices, isAuthenticated } = useOxy();
81
83
  const [reputationTotal, setReputationTotal] = useState<number>(0);
82
84
  const [, setIsLoading] = useState(true);
83
85
 
@@ -85,12 +87,12 @@ const TrustRewardsScreen: React.FC<BaseScreenProps> = ({ goBack }) => {
85
87
  const colors = bloomTheme.colors;
86
88
 
87
89
  useEffect(() => {
88
- if (!user || !isAuthenticated) {
90
+ if (!activeAccount || !isAuthenticated) {
89
91
  setIsLoading(false);
90
92
  return;
91
93
  }
92
94
  setIsLoading(true);
93
- oxyServices.getReputationBalance(user.id)
95
+ oxyServices.getReputationBalance(activeAccount.id)
94
96
  .then((balance) => {
95
97
  setReputationTotal(balance.total || 0);
96
98
  })
@@ -98,7 +100,7 @@ const TrustRewardsScreen: React.FC<BaseScreenProps> = ({ goBack }) => {
98
100
  setReputationTotal(0);
99
101
  })
100
102
  .finally(() => setIsLoading(false));
101
- }, [user, isAuthenticated, oxyServices]);
103
+ }, [activeAccount, isAuthenticated, oxyServices]);
102
104
 
103
105
  const achievements: Achievement[] = useMemo(() => [
104
106
  {