diff --git a/app/components/channel_loader/__snapshots__/channel_loader.test.js.snap b/app/components/channel_loader/__snapshots__/channel_loader.test.js.snap index dc01e0f27..ef5361673 100644 --- a/app/components/channel_loader/__snapshots__/channel_loader.test.js.snap +++ b/app/components/channel_loader/__snapshots__/channel_loader.test.js.snap @@ -16,6 +16,68 @@ exports[`ChannelLoader should match snapshot 1`] = ` ] } > + + + + + + + + { + Animated.timing(this.top, { + toValue: 0, + duration: 300, + delay: 500, + useNativeDriver: false, + }).start(); + } + buildSections({key, style, bg, color}) { return ( + + + + + + + + {Array(this.state.maxRows).fill().map((item, index) => this.buildSections({ key: index, style, @@ -143,5 +192,36 @@ const getStyleSheet = makeStyleSheetFromTheme((theme) => { paddingRight: 20, marginVertical: 10, }, + indicator: { + position: 'absolute', + height: INDICATOR_BAR_HEIGHT, + width: '100%', + ...Platform.select({ + android: { + elevation: 9, + }, + ios: { + zIndex: 9, + }, + }), + backgroundColor: '#3D3C40', + }, + indicatorWrapper: { + alignItems: 'center', + height: INDICATOR_BAR_HEIGHT, + flexDirection: 'row', + paddingLeft: 12, + paddingRight: 5, + }, + indicatorText: { + color: '#fff', + fontWeight: 'bold', + }, + activityIndicator: { + alignItems: 'flex-start', + height: 24, + justifyContent: 'center', + paddingRight: 10, + }, }; }); diff --git a/app/components/channel_loader/channel_loader.test.js b/app/components/channel_loader/channel_loader.test.js index faccb30e9..4f16ec3b0 100644 --- a/app/components/channel_loader/channel_loader.test.js +++ b/app/components/channel_loader/channel_loader.test.js @@ -8,14 +8,34 @@ import Preferences from '@mm-redux/constants/preferences'; import ChannelLoader from './channel_loader'; +jest.useFakeTimers(); + describe('ChannelLoader', () => { const baseProps = { channelIsLoading: true, theme: Preferences.THEMES.default, + retryLoad: jest.fn(), }; test('should match snapshot', () => { const wrapper = shallow(); expect(wrapper.getElement()).toMatchSnapshot(); }); + + test('should call setTimeout and setInterval for showIndicator and retryLoad on mount', () => { + const wrapper = shallow(); + const instance = wrapper.instance(); + + expect(setTimeout).toHaveBeenCalledWith(instance.showIndicator, 10000); + expect(setInterval).toHaveBeenCalledWith(baseProps.retryLoad, 10000); + }); + + test('should clear timer and interval on unmount', () => { + const wrapper = shallow(); + const instance = wrapper.instance(); + instance.componentWillUnmount(); + + expect(clearTimeout).toHaveBeenCalledWith(instance.stillLoadingTimeout); + expect(clearInterval).toHaveBeenCalledWith(instance.retryLoadInterval); + }); }); diff --git a/app/screens/channel/channel_base.js b/app/screens/channel/channel_base.js index 1efb2d4b7..39ad17665 100644 --- a/app/screens/channel/channel_base.js +++ b/app/screens/channel/channel_base.js @@ -233,6 +233,15 @@ export default class ChannelBase extends PureComponent { } }; + retryLoad = () => { + const {currentTeamId, actions} = this.props; + if (currentTeamId) { + this.loadChannels(currentTeamId); + } else { + actions.selectDefaultTeam(); + } + } + retryLoadChannels = () => { this.loadChannels(this.props.currentTeamId); }; @@ -270,6 +279,7 @@ export default class ChannelBase extends PureComponent { ); } diff --git a/assets/base/i18n/en.json b/assets/base/i18n/en.json index 3a4fe5035..48fd7168c 100644 --- a/assets/base/i18n/en.json +++ b/assets/base/i18n/en.json @@ -198,6 +198,7 @@ "mobile.channel_list.members": "MEMBERS", "mobile.channel_list.not_member": "NOT A MEMBER", "mobile.channel_list.unreads": "UNREADS", + "mobile.channel_loader.still_loading": "Still trying to load your content...", "mobile.channel_members.add_members_alert": "You must select at least one member to add to the channel.", "mobile.client_upgrade": "Update App", "mobile.client_upgrade.can_upgrade_subtitle": "A new version is available for download.",