Skip to content
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

[Feat #23131] Display status on user page #24330

Merged
merged 9 commits into from
Aug 11, 2023
20 changes: 20 additions & 0 deletions src/pages/ProfilePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import * as Illustrations from '../components/Icon/Illustrations';
import variables from '../styles/variables';
import ROUTES from '../ROUTES';
import * as ValidationUtils from '../libs/ValidationUtils';
import Tooltip from '../components/Tooltip';

const matchType = PropTypes.shape({
params: PropTypes.shape({
Expand Down Expand Up @@ -133,6 +134,11 @@ function ProfilePage(props) {
// If the API returns an error for some reason there won't be any details and isLoading will get set to false, so we want to show a blocking screen
const shouldShowBlockingView = !hasMinimumDetails && !isLoading;

const statusEmojiCode = lodashGet(details, 'status.emojiCode', '');
const statusText = lodashGet(details, 'status.text', '');
const hasStatus = !!statusEmojiCode;
const statusContent = `${statusEmojiCode} ${statusText}`;

return (
<ScreenWrapper>
<HeaderWithBackButton
Expand Down Expand Up @@ -178,6 +184,20 @@ function ProfilePage(props) {
{displayName}
</Text>
)}
{hasStatus ? (
perunt marked this conversation as resolved.
Show resolved Hide resolved
<View style={[styles.mb6, styles.detailsPageSectionContainer, styles.w100]}>
<Text
style={[styles.textLabelSupporting, styles.mb1]}
numberOfLines={1}
>
{props.translate('statusPage.status')}
</Text>
<Tooltip text={statusContent}>
<Text numberOfLines={1}>{statusContent}</Text>
</Tooltip>
</View>
) : null}

{login ? (
<View style={[styles.mb6, styles.detailsPageSectionContainer, styles.w100]}>
<Text
Expand Down
6 changes: 3 additions & 3 deletions src/pages/settings/Profile/CustomStatus/StatusPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ function StatusPage({draftStatus, currentUserPersonalDetails}) {
const draftText = lodashGet(draftStatus, 'text');

const defaultEmoji = draftEmojiCode || currentUserEmojiCode;
const defaultText = draftText || currentUserStatusText;
const customStatus = defaultEmoji ? `${defaultEmoji} ${defaultText}` : '';
const defaultText = draftEmojiCode ? draftText : currentUserStatusText;
const customStatus = draftEmojiCode ? `${draftEmojiCode} ${draftText}` : `${currentUserEmojiCode || ''} ${currentUserStatusText || ''}` ;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a fix for saving an empty status

const hasDraftStatus = !!draftEmojiCode || !!draftText;

const updateStatus = useCallback(() => {
const endOfDay = moment().endOf('day').toDate();
User.updateCustomStatus({text: defaultText, emojiCode: defaultEmoji, clearAfter: endOfDay.toISOString()});

User.clearDraftCustomStatus();
Navigation.goBack(ROUTES.SETTINGS);
Navigation.goBack(ROUTES.SETTINGS_PROFILE);
}, [defaultText, defaultEmoji]);

const clearStatus = () => {
Expand Down