Skip to content

Commit

Permalink
Fix loading states
Browse files Browse the repository at this point in the history
  • Loading branch information
joel-jeremy committed Nov 14, 2024
1 parent f528c51 commit 33e6c56
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/loot-core/src/client/data-hooks/schedules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ type UseSchedulesResult = ScheduleData & {
export function useSchedules({
query,
}: UseSchedulesProps = {}): UseSchedulesResult {
const [isLoading, setIsLoading] = useState(false);
const [isLoading, setIsLoading] = useState(query != null);
const [error, setError] = useState<Error | undefined>(undefined);
const [data, setData] = useState<ScheduleData>({
schedules: [],
Expand Down
4 changes: 2 additions & 2 deletions packages/loot-core/src/client/data-hooks/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function useTransactions({
query,
options = { pageCount: 50 },
}: UseTransactionsProps): UseTransactionsResult {
const [isLoading, setIsLoading] = useState(false);
const [isLoading, setIsLoading] = useState(query != null);
const [error, setError] = useState<Error | undefined>(undefined);
const [transactions, setTransactions] = useState<
ReadonlyArray<TransactionEntity>
Expand Down Expand Up @@ -113,7 +113,7 @@ export function usePreviewTransactions(): UsePreviewTransactionsResult {
schedules,
statuses,
} = useCachedSchedules();
const [isLoading, setIsLoading] = useState(false);
const [isLoading, setIsLoading] = useState(isSchedulesLoading);
const [error, setError] = useState<Error | undefined>(undefined);

const scheduleTransactions = useMemo(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/loot-core/src/client/query-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function useQuery<Response = unknown>(
const query = useMemo(makeQuery, dependencies);

const [data, setData] = useState<ReadonlyArray<Response> | null>(null);
const [isLoading, setIsLoading] = useState(query !== null);
const [isLoading, setIsLoading] = useState(query != null);
const [error, setError] = useState<Error | undefined>(undefined);

useEffect(() => {
Expand Down

0 comments on commit 33e6c56

Please sign in to comment.