-
Notifications
You must be signed in to change notification settings - Fork 3.9k
LoadingBar rendering improvements #63025
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
JS00001
merged 27 commits into
Expensify:main
from
callstack-internal:loading-bar-rendering-conditions-improvement
Jun 25, 2025
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
ad07324
LoadingBar rendering improvements
martasudol 7ef7b12
prettier & eslint
martasudol c0d830a
prettier & eslint
martasudol 6dc8637
prettier & eslint
martasudol 5b40950
use queueFlushedData
martasudol 2058dca
use ongoingRequest instead of currentRequestCommand
martasudol c7a5e40
set for relevant commands
martasudol 8da7669
removed notifyQueueStateChange call after clearing
martasudol 6aa3601
avoiding rerenders
martasudol d65371b
prettier
martasudol ebb3b1e
reverted `IS_LOADING_REPORT_DATA` changes
martasudol 3596271
Merge branch 'main' into loading-bar-rendering-conditions-improvement
martasudol 73416b1
pr comments
martasudol 4130fb0
listens for persisted requests instead of directly for sequential queue
martasudol 8b75c81
eslint
martasudol 7108d2d
Merge branch 'main' into loading-bar-rendering-conditions-improvement
martasudol 0173685
rename isLoadingReportData to shouldShowLoadingBar
martasudol a48c857
Merge branch 'main' into loading-bar-rendering-conditions-improvement
martasudol 18ddecf
prettier & eslint
martasudol 9f219c9
Onyx.set usage instead of in-memory let
martasudol 8f884f8
Merge branch 'main' into loading-bar-rendering-conditions-improvement
martasudol a5c5d57
onyx.set
martasudol 0b9b843
use ongoing requests Onyx key to handle requests from Pusher
martasudol c7f47a1
Merge branch 'main' into loading-bar-rendering-conditions-improvement
martasudol 5774d7a
add ReadNewestAction to relevant commands
martasudol 9bed9c7
replace useOnyx with network key with useNetwork hook
martasudol bff9461
Update src/hooks/useLoadingBarVisibility.ts
martasudol File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,27 @@ | ||
| import {WRITE_COMMANDS} from '@libs/API/types'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import useNetwork from './useNetwork'; | ||
| import useOnyx from './useOnyx'; | ||
|
|
||
| // Commands that should trigger the LoadingBar to show | ||
| const RELEVANT_COMMANDS = new Set<string>([WRITE_COMMANDS.OPEN_APP, WRITE_COMMANDS.RECONNECT_APP, WRITE_COMMANDS.OPEN_REPORT, WRITE_COMMANDS.READ_NEWEST_ACTION]); | ||
|
|
||
| /** | ||
| * Hook that determines whether LoadingBar should be visible based on active queue requests | ||
| * Shows LoadingBar when any of the RELEVANT_COMMANDS are being processed | ||
| */ | ||
| export default function useLoadingBarVisibility(): boolean { | ||
| const [persistedRequests] = useOnyx(ONYXKEYS.PERSISTED_REQUESTS, {canBeMissing: false}); | ||
| const [ongoingRequests] = useOnyx(ONYXKEYS.PERSISTED_ONGOING_REQUESTS, {canBeMissing: false}); | ||
| const {isOffline} = useNetwork(); | ||
|
|
||
| // Don't show loading bar if currently offline | ||
| if (isOffline) { | ||
| return false; | ||
| } | ||
|
|
||
| const hasPersistedRequests = persistedRequests?.some((request) => RELEVANT_COMMANDS.has(request.command) && !request.initiatedOffline) ?? false; | ||
| const hasOngoingRequests = !!ongoingRequests && RELEVANT_COMMANDS.has(ongoingRequests?.command); | ||
|
|
||
| return hasPersistedRequests || hasOngoingRequests; | ||
| } | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We set
canBeMissingofONYXKEYS.PERSISTED_ONGOING_REQUESTStotruesince since it can benull. (See issue #66591)App/src/libs/actions/PersistedRequests.ts
Line 39 in 39c6b76