Repository navigation
fix(mobile): resolve release, sync, and navigation regressions #285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
b91c09d
43a0353
88b9b5c
dc08a80
08ad897
65c35a2
740dcb8
b93a9ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| 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'; |
| 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)} | ||
| /> | ||
| ); | ||
| } |
| 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'; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
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 | ||
|
|
@@ -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> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If connectivity drops and returns while
registerForPushis 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 settingfailed, 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 👍 / 👎.