Skip to content
Open
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
2 changes: 2 additions & 0 deletions apps/mobile/app/(tabs)/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ function BottomBar({ onAdd }: { onAdd: () => void }) {
backgroundColor: tokens.background,
borderTopWidth: 1,
borderTopColor: tokens.borderSubtle,
zIndex: 10,
elevation: 10,
}}
>
<View style={{ flexDirection: 'row', alignItems: 'center', paddingHorizontal: 6 }}>
Expand Down
1 change: 0 additions & 1 deletion apps/mobile/app/(tabs)/goals.tsx

This file was deleted.

6 changes: 6 additions & 0 deletions apps/mobile/app/(tabs)/profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,12 @@ export default function ProfileScreen() {
description="Balances and activity"
onPress={() => router.push('/accounts' as never)}
/>
<ProfileTile
icon={ChartLineUp}
label="Goals"
description="Savings progress"
onPress={() => router.push('/goals' as never)}
/>
<ProfileTile
icon={ReceiptText}
label="Categories"
Expand Down
2 changes: 2 additions & 0 deletions apps/mobile/app/about.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export default function AboutRoute() {
backend: live,
commit: extra.gitSha,
environment: __DEV__ ? 'development' : 'production',
nativeBuildNumber: Constants.nativeBuildVersion,
nativePlatform: Platform.OS === 'ios' ? 'ios' : 'android',
});
const storeUrl =
Platform.OS === 'ios'
Expand Down
111 changes: 1 addition & 110 deletions apps/mobile/app/goals/index.tsx
Original file line number Diff line number Diff line change
@@ -1,110 +1 @@
import { router } from 'expo-router';
import {
GoalsOverviewScreen,
resolveDefaultCurrency,
type GoalOverviewItem,
} from '@finapp/ui/finance';
import { useLocalSync } from '@/providers/LocalSyncProvider';
import { useLocalRecords } from '@/hooks/useLocalRecords';
import type { LocalRecord } from '@/local/repository';

type Goal = LocalRecord & {
id?: string;
name?: string;
targetAmountMinor?: bigint | number | string;
currency?: string;
archivedAt?: number;
completedAt?: number;
targetDate?: number;
icon?: string;
color?: string;
goalType?: string;
monthlyContributionMinor?: bigint | number | string;
accountId?: string;
priority?: 'low' | 'medium' | 'high';
notes?: string;
reminderFrequency?: 'none' | 'weekly' | 'monthly';
cloudId?: string;
};
type Contribution = LocalRecord & { goalId?: string; amountMinor?: bigint | number | string };
const toMinor = (value: unknown): bigint => {
if (typeof value === 'bigint') return value;
if (typeof value === 'number' && Number.isFinite(value)) return BigInt(Math.trunc(value));
if (typeof value === 'string' && /^-?\d+$/.test(value)) return BigInt(value);
return 0n;
};

export default function GoalsScreen() {
const { userId, isConnected } = useLocalSync();
const goals = useLocalRecords<Goal>(userId, 'goal');
const contributions = useLocalRecords<Contribution>(userId, 'goalContribution');
const profiles = useLocalRecords<LocalRecord & { defaultCurrency?: string }>(userId, 'profile');
const settings = useLocalRecords<LocalRecord & { currency?: string; defaultCurrency?: string }>(
userId,
'settings',
);
const currency = resolveDefaultCurrency(profiles.data, settings.data) ?? '';
const activeGoals = (goals.data ?? [])
.filter((goal) => goal.archivedAt === undefined)
.sort(
(left, right) =>
Number(Boolean(left.completedAt)) - Number(Boolean(right.completedAt)) ||
(left.name ?? '').localeCompare(right.name ?? ''),
);
const rows: GoalOverviewItem[] = activeGoals.map((goal) => {
const aliases = [goal.id, goal._id, goal.cloudId].filter(
(value): value is string => typeof value === 'string',
);
const saved = (contributions.data ?? [])
.filter((entry) => typeof entry.goalId === 'string' && aliases.includes(entry.goalId))
.reduce((sum, entry) => sum + toMinor(entry.amountMinor), 0n);
const target = toMinor(goal.targetAmountMinor);
return {
id: String(goal.id ?? goal._id ?? goal.cloudId ?? ''),
name: goal.name ?? 'Savings goal',
icon: goal.icon,
color: goal.color,
goalType: goal.goalType,
monthlyContributionMinor:
goal.monthlyContributionMinor !== undefined
? toMinor(goal.monthlyContributionMinor)
: undefined,
accountId: goal.accountId,
priority: goal.priority,
notes: goal.notes,
reminderFrequency: goal.reminderFrequency,
saved,
target,
currency: goal.currency ?? currency ?? 'INR',
percent: target > 0n ? Number((saved * 100n) / target) : 0,
targetDate: goal.targetDate,
completed: goal.completedAt !== undefined,
};
});
const currencies = new Set(rows.map((row) => row.currency));
const totalSaved = currencies.size === 1 ? rows.reduce((sum, row) => sum + row.saved, 0n) : null;
const loading = goals.loading || contributions.loading || profiles.loading || settings.loading;
const hasError = Boolean(goals.error || contributions.error || profiles.error || settings.error);

return (
<GoalsOverviewScreen
goals={rows}
totalSaved={totalSaved}
currencyCount={currencies.size}
loading={loading}
error={hasError}
connected={isConnected}
defaultCurrency={currency}
onAdd={() => router.push('/goals/new' as never)}
onOpen={(id) => router.push(`/goals/${id}` as never)}
onAnalytics={() => router.push('/goals/analytics' as never)}
onRetry={() => {
goals.retry();
contributions.retry();
profiles.retry();
settings.retry();
}}
onSetCurrency={() => router.push('/settings/currency' as never)}
/>
);
}
export { default } from '@/components/GoalsScreen';
6 changes: 5 additions & 1 deletion apps/mobile/app/settings/notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export default function NotificationSettingsScreen() {
null,
);
const [saving, setSaving] = React.useState(false);
const registrationInFlight = React.useRef(false);
const [error, setError] = React.useState('');

React.useEffect(() => {
Expand All @@ -159,15 +160,19 @@ export default function NotificationSettingsScreen() {
'checking' | 'registered' | 'failed' | 'offline'
>('checking');
const register = React.useCallback(async () => {
if (registrationInFlight.current) return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Retry registration after an in-flight connectivity cycle

If connectivity drops and returns while registerForPush is still pending, both dependency-triggered calls return here because the lock is set. When the original request subsequently fails, it clears the lock only after setting failed, but no dependency changes again to start registration, so an online device remains unregistered until the user manually taps Retry. Queue a rerun when a call was skipped or re-check connectivity after the in-flight request completes.

Useful? React with 👍 / 👎.

if (!isConnected) {
setRegistration('offline');
return;
}
registrationInFlight.current = true;
setRegistration('checking');
try {
setRegistration((await registerForPush(convex)) === 'registered' ? 'registered' : 'failed');
} catch {
setRegistration('failed');
} finally {
registrationInFlight.current = false;
}
}, [convex, isConnected]);
React.useEffect(() => {
Expand Down Expand Up @@ -202,7 +207,6 @@ export default function NotificationSettingsScreen() {
setPermission(granted ? 'granted' : 'denied');
if (granted && userId) {
await reconcileRecurringNotifications(userId);
await register();
}
} catch {
setError('Could not request notification permission.');
Expand Down
18 changes: 14 additions & 4 deletions apps/mobile/app/transaction/new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ export default function NewTransactionScreen() {
);
const accountDefault = Boolean(
account &&
profile?.defaultAccountId &&
[account.id, account._id, account.cloudId].includes(profile.defaultAccountId),
profile?.defaultAccountId &&
[account.id, account._id, account.cloudId].includes(profile.defaultAccountId),
);
const categoryDefault = Boolean(
category &&
defaultCategoryId &&
[category.id, category._id, category.cloudId].includes(defaultCategoryId),
defaultCategoryId &&
[category.id, category._id, category.cloudId].includes(defaultCategoryId),
);
useEffect(() => {
if (type !== 'transfer' && !categoryId && category) setCategoryId(recordId(category));
Expand All @@ -124,6 +124,16 @@ export default function NewTransactionScreen() {
if (fields.categoryId) setCategoryId(fields.categoryId);
setReview(scanReview);
},
onCurrencyChange: (fields) => {
const amounts = new Map(fields.rows.map((row) => [row.id, row.amount]));
setAmount(fields.amount);
setItems(
(current) =>
current?.map((row) =>
amounts.has(row.id) ? { ...row, amount: amounts.get(row.id)! } : row,
) ?? current,
);
},
});
const itemsState = personalItemsState(type === 'transfer' ? null : items, itemCurrency, amount);
let amountMinor: bigint | null = null;
Expand Down
110 changes: 110 additions & 0 deletions apps/mobile/components/GoalsScreen.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import { router } from 'expo-router';
import {
GoalsOverviewScreen,
resolveDefaultCurrency,
type GoalOverviewItem,
} from '@finapp/ui/finance';
import { useLocalSync } from '@/providers/LocalSyncProvider';
import { useLocalRecords } from '@/hooks/useLocalRecords';
import type { LocalRecord } from '@/local/repository';

type Goal = LocalRecord & {
id?: string;
name?: string;
targetAmountMinor?: bigint | number | string;
currency?: string;
archivedAt?: number;
completedAt?: number;
targetDate?: number;
icon?: string;
color?: string;
goalType?: string;
monthlyContributionMinor?: bigint | number | string;
accountId?: string;
priority?: 'low' | 'medium' | 'high';
notes?: string;
reminderFrequency?: 'none' | 'weekly' | 'monthly';
cloudId?: string;
};
type Contribution = LocalRecord & { goalId?: string; amountMinor?: bigint | number | string };
const toMinor = (value: unknown): bigint => {
if (typeof value === 'bigint') return value;
if (typeof value === 'number' && Number.isFinite(value)) return BigInt(Math.trunc(value));
if (typeof value === 'string' && /^-?\d+$/.test(value)) return BigInt(value);
return 0n;
};

export default function GoalsScreen() {
const { userId, isConnected } = useLocalSync();
const goals = useLocalRecords<Goal>(userId, 'goal');
const contributions = useLocalRecords<Contribution>(userId, 'goalContribution');
const profiles = useLocalRecords<LocalRecord & { defaultCurrency?: string }>(userId, 'profile');
const settings = useLocalRecords<LocalRecord & { currency?: string; defaultCurrency?: string }>(
userId,
'settings',
);
const currency = resolveDefaultCurrency(profiles.data, settings.data) ?? '';
const activeGoals = (goals.data ?? [])
.filter((goal) => goal.archivedAt === undefined)
.sort(
(left, right) =>
Number(Boolean(left.completedAt)) - Number(Boolean(right.completedAt)) ||
(left.name ?? '').localeCompare(right.name ?? ''),
);
const rows: GoalOverviewItem[] = activeGoals.map((goal) => {
const aliases = [goal.id, goal._id, goal.cloudId].filter(
(value): value is string => typeof value === 'string',
);
const saved = (contributions.data ?? [])
.filter((entry) => typeof entry.goalId === 'string' && aliases.includes(entry.goalId))
.reduce((sum, entry) => sum + toMinor(entry.amountMinor), 0n);
const target = toMinor(goal.targetAmountMinor);
return {
id: String(goal.id ?? goal._id ?? goal.cloudId ?? ''),
name: goal.name ?? 'Savings goal',
icon: goal.icon,
color: goal.color,
goalType: goal.goalType,
monthlyContributionMinor:
goal.monthlyContributionMinor !== undefined
? toMinor(goal.monthlyContributionMinor)
: undefined,
accountId: goal.accountId,
priority: goal.priority,
notes: goal.notes,
reminderFrequency: goal.reminderFrequency,
saved,
target,
currency: goal.currency ?? currency ?? 'INR',
percent: target > 0n ? Number((saved * 100n) / target) : 0,
targetDate: goal.targetDate,
completed: goal.completedAt !== undefined,
};
});
const currencies = new Set(rows.map((row) => row.currency));
const totalSaved = currencies.size === 1 ? rows.reduce((sum, row) => sum + row.saved, 0n) : null;
const loading = goals.loading || contributions.loading || profiles.loading || settings.loading;
const hasError = Boolean(goals.error || contributions.error || profiles.error || settings.error);

return (
<GoalsOverviewScreen
goals={rows}
totalSaved={totalSaved}
currencyCount={currencies.size}
loading={loading}
error={hasError}
connected={isConnected}
defaultCurrency={currency}
onAdd={() => router.push('/goals/new' as never)}
onOpen={(id) => router.push(`/goals/${id}` as never)}
onAnalytics={() => router.push('/goals/analytics' as never)}
onRetry={() => {
goals.retry();
contributions.retry();
profiles.retry();
settings.retry();
}}
onSetCurrency={() => router.push('/settings/currency' as never)}
/>
);
}
11 changes: 8 additions & 3 deletions apps/mobile/components/UpdateRequiredNotice.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React from 'react';
import { Linking, Pressable, Text, View } from 'react-native';
import { Linking, Platform, Pressable, Text, View } from 'react-native';
import { useConvexAuth, useQuery } from 'convex/react';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { api } from '@convex/_generated/api';
import { updateRequired } from '@finapp/ui/version';
import type { ThemeTokens } from '@finapp/ui/tokens';

const STORE_URL = 'https://play.google.com/store/apps/details?id=com.neerajcodz.finapp';
const IOS_STORE_URL = 'https://apps.apple.com/search?term=Finapp';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Link the mandatory update to the exact iOS listing

When an outdated iOS build displays this mandatory-update notice, the Update action opens a generic App Store search rather than this app's product page. Because “Finapp” is not a unique app name, users can be shown unrelated products and have no reliable route to the update needed to restore syncing; use the stable App Store product URL or ID instead.

Useful? React with 👍 / 👎.

const ANDROID_STORE_URL = 'https://play.google.com/store/apps/details?id=com.neerajcodz.finapp';

/**
* Asks the user to update when this build is older than the backend's minimum supported
Expand Down Expand Up @@ -40,7 +41,11 @@ export function UpdateRequiredNotice({ tokens }: { tokens: ThemeTokens }) {
</Text>
<Pressable
accessibilityRole="link"
onPress={() => void Linking.openURL(STORE_URL).catch(() => undefined)}
onPress={() =>
void Linking.openURL(Platform.OS === 'ios' ? IOS_STORE_URL : ANDROID_STORE_URL).catch(
() => undefined,
)
}
hitSlop={8}
>
<Text style={{ color: tokens.primary, fontWeight: '600' }}>Update</Text>
Expand Down
9 changes: 9 additions & 0 deletions apps/mobile/components/finance/SplitExpenseForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ export function SplitExpenseForm({ fixedGroupId }: { fixedGroupId?: string }) {
});
setReview(scanReview);
},
onCurrencyChange: (fields) => {
const amounts = new Map(fields.rows.map((row) => [row.id, row.amount]));
composer.set('amount', fields.amount);
composer.setItems(
composer.items.map((row) =>
amounts.has(row.id) ? { ...row, amount: amounts.get(row.id)! } : row,
),
);
},
});

function chooseGroup(id: string) {
Expand Down
Loading
Loading