Files
mattermost-mobile/app/screens/server/header.tsx
Elias Nahum d35eac8bd3 Gekidou servers (#5960)
* 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
2022-02-14 16:39:29 -03:00

92 lines
2.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import {View} from 'react-native';
import FormattedText from '@components/formatted_text';
import {useIsTablet} from '@hooks/device';
import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme';
import {typography} from '@utils/typography';
type Props = {
additionalServer: boolean;
theme: Theme;
};
const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => ({
textContainer: {
marginBottom: 32,
maxWidth: 600,
width: '100%',
paddingHorizontal: 20,
},
welcome: {
marginTop: 12,
color: changeOpacity(theme.centerChannelColor, 0.64),
...typography('Heading', 400, 'SemiBold'),
},
connect: {
width: 270,
letterSpacing: -1,
color: theme.centerChannelColor,
marginVertical: 12,
...typography('Heading', 1000, 'SemiBold'),
},
connectTablet: {
width: undefined,
},
description: {
color: changeOpacity(theme.centerChannelColor, 0.64),
...typography('Body', 200, 'Regular'),
},
}));
const ServerHeader = ({additionalServer, theme}: Props) => {
const isTablet = useIsTablet();
const styles = getStyleSheet(theme);
let title;
if (additionalServer) {
title = (
<FormattedText
defaultMessage='Add a server'
id='servers.create_button'
style={[styles.connect, isTablet ? styles.connectTablet : undefined]}
testID='mobile.components.select_server_view.add_server'
/>
);
} else {
title = (
<FormattedText
defaultMessage='Lets Connect to a Server'
id='mobile.components.select_server_view.msg_connect'
style={[styles.connect, isTablet ? styles.connectTablet : undefined]}
testID='mobile.components.select_server_view.msg_connect'
/>
);
}
return (
<View style={styles.textContainer}>
{!additionalServer &&
<FormattedText
defaultMessage='Welcome'
id='mobile.components.select_server_view.msg_welcome'
testID='mobile.components.select_server_view.msg_welcome'
style={styles.welcome}
/>
}
{title}
<FormattedText
defaultMessage="A Server is your team's communication hub which is accessed through a unique URL"
id='mobile.components.select_server_view.msg_description'
style={styles.description}
testID='mobile.components.select_server_view.msg_description'
/>
</View>
);
};
export default ServerHeader;