[PR #26001] Fix multiple re-renders in useAppsQueryState caused by searchParams dependency #31299

Closed
opened 2026-02-21 20:49:12 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/26001

State: closed
Merged: No


Summary

try to fix #26000

When toggling the "Created by me" checkbox on the apps list page, the UI flickers 1–4 times. It is because the effect in useAppsQueryState depends on both query and searchParams. This PR tries to eliminate multiple flickers when toggling "Created by me".

before the fix:

    1. User toggles the checkbox → setQuery updates query.
    1. Effect runs → router.push updates the URL.
    1. URL change updates searchParams → effect runs again.

after the fix:
- 1. User toggles the checkbox → query changes → effect runs once.
- 2. Effect updates the URL with router.push.
- 3. searchParams updates internally, but no longer retriggers the effect.

after the fix:

  • Refactored useAppsQueryState to follow the same pattern as useDocumentListQueryState.
  • query is now always derived from URL search params.
  • setQuery directly updates the URL; no more local state or useEffect sync.
  • Updated list.tsx to remove the redundant local isCreatedByMe state.

Screenshots

Before
Screenshot from 2025-09-21 09-58-28
After
Screenshot from 2025-09-21 09-53-04

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
**Original Pull Request:** https://github.com/langgenius/dify/pull/26001 **State:** closed **Merged:** No --- ## Summary <!-- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. --> try to fix #26000 When toggling the "Created by me" checkbox on the apps list page, the UI flickers 1–4 times. It is because the effect in `useAppsQueryState` depends on both `query` and `searchParams`. This PR tries to eliminate multiple flickers when toggling "Created by me". **before the fix:** - 1. User toggles the checkbox → setQuery updates query. - 2. Effect runs → router.push updates the URL. - 3. URL change updates searchParams → effect runs again. ~~**after the fix:**~~ ~~- 1. User toggles the checkbox → query changes → effect runs once.~~ ~~- 2. Effect updates the URL with router.push.~~ ~~- 3. searchParams updates internally, but no longer retriggers the effect.~~ **after the fix:** - Refactored `useAppsQueryState` to follow the same pattern as `useDocumentListQueryState`. - `query` is now always derived from URL search params. - `setQuery` directly updates the URL; no more local state or useEffect sync. - Updated `list.tsx` to remove the redundant local `isCreatedByMe` state. ## Screenshots Before <img width="1250" height="965" alt="Screenshot from 2025-09-21 09-58-28" src="https://github.com/user-attachments/assets/343de2ae-c311-43df-bb0f-13c64d9453d8" /> After <img width="1247" height="863" alt="Screenshot from 2025-09-21 09-53-04" src="https://github.com/user-attachments/assets/921c2154-4156-42ff-9df1-92ae02dbf834" /> ## Checklist - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) - [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [x] I've updated the documentation accordingly. - [x] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods
yindo added the pull-request label 2026-02-21 20:49:12 -05:00
yindo closed this issue 2026-02-21 20:49:12 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#31299