Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions app/src/components/NavBar/Points.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ const Points: React.FC = () => {
// }
// }, [setBackupForPointsCompleted, hasCompletedBackupForPoints]);

// Track if we should check for backup completion on next focus
const shouldCheckBackupRef = React.useRef(false);

// Detect when returning from backup screen and record points if backup was completed
useFocusEffect(
React.useCallback(() => {
Expand All @@ -96,9 +99,10 @@ const Points: React.FC = () => {
const currentHasCompletedBackup =
useSettingStore.getState().hasCompletedBackupForPoints;

// If either backup method is enabled but points haven't been recorded yet, record them now
// This happens when user just completed backup and returned to this screen
// Only check if we explicitly set the flag (when navigating to backup settings)
// This prevents false triggers when returning from other flows (like notification permissions)
if (
shouldCheckBackupRef.current &&
(cloudBackupEnabled || backedUpWithTurnKey) &&
!currentHasCompletedBackup
) {
Expand Down Expand Up @@ -135,6 +139,9 @@ const Points: React.FC = () => {

recordPoints();
}

// Reset the flag after checking
shouldCheckBackupRef.current = false;
}, [navigation, selfClient]),
);

Expand Down Expand Up @@ -314,6 +321,8 @@ const Points: React.FC = () => {
}
} else {
// Navigate to backup screen and return to Points after backup completes
// Set flag to check for backup completion when we return
shouldCheckBackupRef.current = true;
navigation.navigate('CloudBackupSettings', { returnToScreen: 'Points' });
}
};
Expand Down
2 changes: 1 addition & 1 deletion app/src/utils/points/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const getPointsAddress = async (): Promise<string> => {

export const getTotalPoints = async (address: string): Promise<number> => {
try {
const url = `${POINTS_API_BASE_URL}/distribution/${address.toLowerCase()}`;
const url = `${POINTS_API_BASE_URL}/points/${address.toLowerCase()}`;
const response = await fetch(url);

if (!response.ok) {
Expand Down
Loading