Skip to content

Commit

Permalink
Add a loading bar when loading split bundles
Browse files Browse the repository at this point in the history
Summary:
This adds a loading indicator when loading split bundles so that users get a visual indicator about what is going on.

Note that I am currently trying to get the dynamic message that shows the number of modules and percentage to work but it appears that the JavaScript networking client (XMLHttpRequest + RCTNetwork) are not set up to deal with multipart responses in the same way as our native multipart handlers are. I'd like to put this in place now and polish it later if it's possible to fix the issue (I spent all afternoon yesterday trying to make multipart messages work and failed :( ).

Reviewed By: gaearon

Differential Revision: D16281531

fbshipit-source-id: 84e53d7f25642398ed51d8f552919880b8090897
  • Loading branch information
cpojer authored and facebook-github-bot committed Jul 18, 2019
1 parent ba8f88d commit d974793
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Libraries/Utilities/HMRClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ Error: ${e.message}`;

client.on('update-start', () => {
if (isFastRefreshActive()) {
LoadingView.showMessage('Refreshing...');
LoadingView.showMessage('Refreshing...', 'refresh');
}
});

Expand Down
2 changes: 1 addition & 1 deletion Libraries/Utilities/LoadingView.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const TOAST_SHORT_DELAY = 2000;
let isVisible = false;

module.exports = {
showMessage(message: string) {
showMessage(message: string, type: 'load' | 'refresh') {
if (!isVisible) {
ToastAndroid.show(message, ToastAndroid.SHORT);
isVisible = true;
Expand Down
6 changes: 4 additions & 2 deletions Libraries/Utilities/LoadingView.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ import processColor from '../StyleSheet/processColor';
import NativeDevLoadingView from './NativeDevLoadingView';

module.exports = {
showMessage(message: string) {
showMessage(message: string, type: 'load' | 'refresh') {
if (NativeDevLoadingView) {
NativeDevLoadingView.showMessage(
message,
// Use same colors as iOS "Personal Hotspot" bar.
processColor('#ffffff'),
processColor('#2584e8'),
type && type === 'load'
? processColor('#275714')
: processColor('#2584e8'),
);
}
},
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Utilities/LoadingView.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
'use strict';

module.exports = {
showMessage(message: string) {},
showMessage(message: string, type: 'load' | 'refresh') {},
hide() {},
};

0 comments on commit d974793

Please sign in to comment.