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
11 changes: 10 additions & 1 deletion src/app/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import 'react-native-gesture-handler';

import { QueryClientProvider } from '@tanstack/react-query';
import { focusManager, QueryClientProvider } from '@tanstack/react-query';
import { useFonts } from 'expo-font';
import { Stack } from 'expo-router';
import { StatusBar } from 'expo-status-bar';
import { useEffect } from 'react';
import { AppState } from 'react-native';
Comment on lines +3 to +8

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
fd -HI -t f '^(package\.json|app\.json|app\.config\..*)$' . \
  -x rg -n '"web"|react-native-web|expo export' {}

Repository: unplan-tave/unplan-app

Length of output: 1444


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '\n## src/app/_layout.tsx\n'
sed -n '1,120p' src/app/_layout.tsx | cat -n

printf '\n## package.json platform signals\n'
sed -n '1,220p' package.json | cat -n

printf '\n## app config files\n'
fd -HI -t f '^(app\.json|app\.config\..*)$' . -x sh -c 'echo "--- {}"; sed -n "1,220p" "{}" | cat -n'

Repository: unplan-tave/unplan-app

Length of output: 10549


Guard the AppState focus override on web builds.

This app supports Expo web, so this listener should be skipped there; otherwise focusManager.setFocused can interfere with the browser’s focus handling.

Proposed fix
-import { AppState } from 'react-native';
+import { AppState, Platform } from 'react-native';

  useEffect(() => {
+   if (Platform.OS === 'web') {
+     return;
+   }
+
    const subscription = AppState.addEventListener('change', (state) => {
      focusManager.setFocused(state === 'active');
    });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { focusManager, QueryClientProvider } from '@tanstack/react-query';
import { useFonts } from 'expo-font';
import { Stack } from 'expo-router';
import { StatusBar } from 'expo-status-bar';
import { useEffect } from 'react';
import { AppState } from 'react-native';
import { AppState, Platform } from 'react-native';
useEffect(() => {
if (Platform.OS === 'web') {
return;
}
const subscription = AppState.addEventListener('change', (state) => {
focusManager.setFocused(state === 'active');
});
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/app/_layout.tsx` around lines 3 - 8, Guard the AppState focus-listener
setup in the root layout’s useEffect so it runs only on native platforms and is
skipped for Expo web builds. Preserve the existing focusManager.setFocused
behavior and cleanup for supported native platforms.

Sources: Coding guidelines, MCP tools

import { GestureHandlerRootView } from 'react-native-gesture-handler';

import { fontFamilyWeight } from '@/constants/typography';
Expand All @@ -31,6 +32,14 @@ export default function RootLayout() {
if (error) throw error;
}, [error]);

useEffect(() => {
const subscription = AppState.addEventListener('change', (state) => {
focusManager.setFocused(state === 'active');
});

return () => subscription.remove();
}, []);

useEffect(() => {
const initializeApp = async () => {
try {
Expand Down
7 changes: 2 additions & 5 deletions src/domains/measurement/api/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ import type { UseQueryOptions } from '@tanstack/react-query';

type MeasurementQueryOptions<TData> = Omit<UseQueryOptions<TData>, 'queryKey' | 'queryFn'>;

/**
* 지난 날짜 기록은 세션 중 재방문해도 다시 부르지 않는다.
* 데일리↔위클리↔먼슬리 반복 이동 시 과거 날짜 재요청을 막는 핵심.
*/
const PAST_DATE_STALE_TIME = Infinity;
/** 과거 기록도 다른 기기에서 변경될 수 있으므로 화면 재진입·앱 복귀 시 재검증합니다. */
const PAST_DATE_STALE_TIME = 0;
/**
* 오늘/이번 주·월 기록은 하루 중 바뀔 수 있으나, 갱신은 시간 폴링이 아니라
* 컨디션·수면 기록 mutation의 invalidate로 처리한다.
Expand Down
4 changes: 3 additions & 1 deletion src/lib/api/query-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ export const queryClient = new QueryClient({
defaultOptions: {
queries: {
retry: 2,
staleTime: 1000 * 60 * 5,
// 서버 상태는 화면 재진입·앱 복귀 시 재검증합니다. 각 도메인의 명시적인
// staleTime은 해당 데이터의 갱신 특성에 따라 별도로 유지합니다.
staleTime: 0,
},
},
});
31 changes: 21 additions & 10 deletions src/screens/schedule/card-list/hooks/use-card-list-screen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,14 @@ export function useCardListScreen() {
});
const schedules = useMemo(
() => [
...(pinSearchQuery.data?.pages.flatMap((page) => page.schedules) ?? []),
...(queueSearchQuery.data?.pages.flatMap((page) => page.schedules) ?? []),
...(isPinQueryEnabled
? (pinSearchQuery.data?.pages.flatMap((page) => page.schedules) ?? [])
: []),
...(isQueueQueryEnabled
? (queueSearchQuery.data?.pages.flatMap((page) => page.schedules) ?? [])
: []),
],
[pinSearchQuery.data, queueSearchQuery.data],
[isPinQueryEnabled, isQueueQueryEnabled, pinSearchQuery.data, queueSearchQuery.data],
);
const cards = useMemo(
() => toCardItemsFromScheduleList(schedules, personalTags),
Expand All @@ -135,18 +139,25 @@ export function useCardListScreen() {
const handleSearchClear = useCallback(() => {
router.setParams({ q: '' });
}, []);
const hasNextPage = pinSearchQuery.hasNextPage || queueSearchQuery.hasNextPage;
const hasNextPage =
(isPinQueryEnabled && pinSearchQuery.hasNextPage) ||
(isQueueQueryEnabled && queueSearchQuery.hasNextPage);
const isFetchingNextPage =
pinSearchQuery.isFetchingNextPage || queueSearchQuery.isFetchingNextPage;
(isPinQueryEnabled && pinSearchQuery.isFetchingNextPage) ||
(isQueueQueryEnabled && queueSearchQuery.isFetchingNextPage);
const fetchNextPage = useCallback(() => {
if (pinSearchQuery.hasNextPage && !pinSearchQuery.isFetchingNextPage) {
if (isPinQueryEnabled && pinSearchQuery.hasNextPage && !pinSearchQuery.isFetchingNextPage) {
void pinSearchQuery.fetchNextPage();
}

if (queueSearchQuery.hasNextPage && !queueSearchQuery.isFetchingNextPage) {
if (
isQueueQueryEnabled &&
queueSearchQuery.hasNextPage &&
!queueSearchQuery.isFetchingNextPage
) {
void queueSearchQuery.fetchNextPage();
}
}, [pinSearchQuery, queueSearchQuery]);
}, [isPinQueryEnabled, isQueueQueryEnabled, pinSearchQuery, queueSearchQuery]);
const handleScroll = useCardListInfiniteScroll({
hasNextPage,
isFetchingNextPage,
Expand All @@ -162,8 +173,8 @@ export function useCardListScreen() {
sections,
hasActiveFilter,
totalCards:
(pinSearchQuery.data?.pages[0]?.totalElements ?? 0) +
(queueSearchQuery.data?.pages[0]?.totalElements ?? 0),
(isPinQueryEnabled ? (pinSearchQuery.data?.pages[0]?.totalElements ?? 0) : 0) +
(isQueueQueryEnabled ? (queueSearchQuery.data?.pages[0]?.totalElements ?? 0) : 0),
periodLabel: formatCardListPeriodLabel(filters.startDate, filters.endDate),
isLoading:
(isPinQueryEnabled && pinSearchQuery.isLoading) ||
Expand Down
Loading