Username and username link integrity check

This commit is contained in:
Fedor Indutny 2023-11-03 23:05:11 +01:00 committed by GitHub
parent 1be90fff3d
commit 3664063d71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 636 additions and 35 deletions

View file

@ -35,6 +35,7 @@ import type { PropsType as UnsupportedOSDialogPropsType } from '../state/smart/U
import { ConversationList } from './ConversationList';
import { ContactCheckboxDisabledReason } from './conversationList/ContactCheckbox';
import type { PropsType as DialogExpiredBuildPropsType } from './DialogExpiredBuild';
import { LeftPaneBanner } from './LeftPaneBanner';
import type {
DeleteAvatarFromDiskActionType,
@ -69,6 +70,8 @@ export type PropsType = {
hasUpdateDialog: boolean;
isUpdateDownloaded: boolean;
unsupportedOSDialogType: 'error' | 'warning' | undefined;
usernameCorrupted: boolean;
usernameLinkCorrupted: boolean;
// These help prevent invalid states. For example, we don't need the list of pinned
// conversations if we're trying to start a new conversation. Ideally these would be
@ -135,6 +138,7 @@ export type PropsType = {
toggleComposeEditingAvatar: () => unknown;
toggleConversationInChooseMembers: (conversationId: string) => void;
toggleNavTabsCollapse: (navTabsCollapsed: boolean) => void;
toggleProfileEditor: () => void;
updateSearchTerm: (_: string) => void;
// Render Props
@ -201,6 +205,7 @@ export function LeftPane({
selectedConversationId,
targetedMessageId,
toggleNavTabsCollapse,
toggleProfileEditor,
setChallengeStatus,
setComposeGroupAvatar,
setComposeGroupExpireTimer,
@ -219,6 +224,8 @@ export function LeftPane({
toggleComposeEditingAvatar,
toggleConversationInChooseMembers,
unsupportedOSDialogType,
usernameCorrupted,
usernameLinkCorrupted,
updateSearchTerm,
}: PropsType): JSX.Element {
const previousModeSpecificProps = usePrevious(
@ -544,6 +551,31 @@ export function LeftPane({
}
}
let maybeBanner: JSX.Element | undefined;
if (usernameCorrupted) {
maybeBanner = (
<LeftPaneBanner
actionText={i18n('icu:LeftPane--corrupted-username--action-text')}
onClick={toggleProfileEditor}
>
{i18n('icu:LeftPane--corrupted-username--text')}
</LeftPaneBanner>
);
} else if (usernameLinkCorrupted) {
maybeBanner = (
<LeftPaneBanner
actionText={i18n('icu:LeftPane--corrupted-username-link--action-text')}
onClick={toggleProfileEditor}
>
{i18n('icu:LeftPane--corrupted-username-link--text')}
</LeftPaneBanner>
);
}
if (maybeBanner) {
dialogs.push({ key: 'banner', dialog: maybeBanner });
}
return (
<NavSidebar
title="Chats"