forked from Ivasoft/mattermost-mobile
* Servers logout and websocket state * addNewServer uility and rename file * add LaunchType for add new server * added time to LaunchProps type * Remove unnecessary props for launchToHome * Fix local action updateLastPostAt * Batch fetchProfilesPerChannels requests in chunks of 50 * WS handleUserAddedToChannelEvent to return early if no channelId is set * WS handleNewPostEvent to batch update last_post_at * add common actions to sync other servers * Entry actions to sync other servers data * Do not attempt to fetch notification data if payload does not contain a channelId * Set database as default at the end of the login flow * Handle logout when other servers remain * Handle Server options * Show alert when logging out from the account screen * Add workaround to have Lottie animate the loading component * Fix badge position in ServerIcon component * Server screen to support adding new server * Fix login screen to display error when credentials do not match * add localization strings * fix DatabaseProvider to update on server switch * Fix home icon and server icon subscriptions and badge display * Add dependencies to onLogout callback * feedback * Only updateLastPostAt if needed
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import LottieView from 'lottie-react-native';
|
|
import React, {useEffect, useRef} from 'react';
|
|
import {StyleSheet, View, ViewStyle} from 'react-native';
|
|
|
|
type LoadingProps = {
|
|
containerStyle?: ViewStyle;
|
|
style?: ViewStyle;
|
|
color?: string;
|
|
}
|
|
|
|
const Loading = ({containerStyle, style, color}: LoadingProps) => {
|
|
const lottieRef = useRef<LottieView|null>(null);
|
|
|
|
// This is a workaround as it seems that autoPlay does not work properly on
|
|
// newer versions of RN
|
|
useEffect(() => {
|
|
const animationFrame = requestAnimationFrame(() => {
|
|
lottieRef.current?.reset();
|
|
lottieRef.current?.play();
|
|
});
|
|
|
|
return () => cancelAnimationFrame(animationFrame);
|
|
}, []);
|
|
|
|
return (
|
|
<View style={containerStyle}>
|
|
<LottieView
|
|
autoPlay={true}
|
|
colorFilters={color ? [{color, keypath: 'Shape Layer 1'}] : undefined}
|
|
loop={true}
|
|
ref={lottieRef}
|
|
source={require('./spinner.json')}
|
|
style={[styles.lottie, style]}
|
|
/>
|
|
</View>
|
|
);
|
|
};
|
|
|
|
const styles = StyleSheet.create({
|
|
lottie: {
|
|
height: 32,
|
|
width: 32,
|
|
},
|
|
});
|
|
|
|
export default Loading;
|