-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🧪 improving rules test e2e stability (#3512)
- Loading branch information
1 parent
666b787
commit 6725d56
Showing
9 changed files
with
87 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 0 additions & 4 deletions
4
packages/desktop-client/src/components/rules/SchedulesQuery.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { useQuery } from 'loot-core/client/query-hooks'; | ||
import { q } from 'loot-core/shared/query'; | ||
import { type ScheduleEntity } from 'loot-core/types/models'; | ||
|
||
export function useSchedules() { | ||
return useQuery<ScheduleEntity[]>(() => q('schedules').select('*'), []); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { useState, useMemo, useEffect, type DependencyList } from 'react'; | ||
|
||
import { type Query } from '../shared/query'; | ||
|
||
import { liveQuery, type LiveQuery } from './query-helpers'; | ||
|
||
/** @deprecated: please use `useQuery`; usage is the same - only the returned value is different (object instead of only the data) */ | ||
export function useLiveQuery<Response = unknown>( | ||
makeQuery: () => Query, | ||
deps: DependencyList, | ||
): Response | null { | ||
const { data } = useQuery<Response>(makeQuery, deps); | ||
return data; | ||
} | ||
|
||
export function useQuery<Response = unknown>( | ||
makeQuery: () => Query, | ||
deps: DependencyList, | ||
): { | ||
data: null | Response; | ||
overrideData: (newData: Response) => void; | ||
isLoading: boolean; | ||
} { | ||
const [data, setData] = useState<null | Response>(null); | ||
const [isLoading, setIsLoading] = useState(true); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
const query = useMemo(makeQuery, deps); | ||
|
||
useEffect(() => { | ||
setIsLoading(true); | ||
|
||
let live: null | LiveQuery<Response> = liveQuery<Response>( | ||
query, | ||
async data => { | ||
if (live) { | ||
setIsLoading(false); | ||
setData(data); | ||
} | ||
}, | ||
); | ||
|
||
return () => { | ||
setIsLoading(false); | ||
live?.unsubscribe(); | ||
live = null; | ||
}; | ||
}, [query]); | ||
|
||
return { | ||
data, | ||
overrideData: setData, | ||
isLoading, | ||
}; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
category: Maintenance | ||
authors: [MatissJanis] | ||
--- | ||
|
||
e2e: improve rules test stability. |