Skip to content

Commit c92ea70

Browse files
committed
fix(logs): hydrate filters from URL synchronously on mount
The previous useEffect-based initializeFromURL caused useLogsList and useDashboardStats to fire once with default store filters, then refetch after the effect updated filters from the URL. Move the initial hydrate into a useState lazy initializer so the first render already reads URL-derived filters; the popstate handler keeps the existing effect for back/forward navigation.
1 parent 5a91f6c commit c92ea70

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

  • apps/sim/app/workspace/[workspaceId]/logs

apps/sim/app/workspace/[workspaceId]/logs/logs.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,14 @@ export default function Logs() {
221221
const params = useParams()
222222
const workspaceId = params.workspaceId as string
223223

224+
// Hydrate filters from the URL synchronously on first render so
225+
// useLogsList / useDashboardStats fire once with the correct filters
226+
// instead of refetching after a post-mount effect.
227+
useState(() => {
228+
useFilterStore.getState().initializeFromURL()
229+
return null
230+
})
231+
224232
const {
225233
setWorkspaceId,
226234
initializeFromURL,
@@ -666,11 +674,6 @@ export default function Logs() {
666674
debouncedSearchQuery,
667675
])
668676

669-
useEffect(() => {
670-
initializeFromURL()
671-
// eslint-disable-next-line react-hooks/exhaustive-deps
672-
}, [])
673-
674677
useEffect(() => {
675678
const handlePopState = () => {
676679
initializeFromURL()

0 commit comments

Comments
 (0)