fix: remove titles from toasts

as they have been removed from the guideline
pull/2963/head
Audric Ackermann 2 years ago
parent 8274712528
commit f9502b4bbe

@ -83,7 +83,6 @@
"replyingToMessage": "Replying to:", "replyingToMessage": "Replying to:",
"originalMessageNotFound": "Original message not found", "originalMessageNotFound": "Original message not found",
"you": "You", "you": "You",
"audioPermissionNeededTitle": "Microphone Access Required",
"audioPermissionNeeded": "You can enable microphone access under: Settings (Gear icon) => Privacy", "audioPermissionNeeded": "You can enable microphone access under: Settings (Gear icon) => Privacy",
"image": "Image", "image": "Image",
"audio": "Audio", "audio": "Audio",
@ -332,9 +331,6 @@
"setPasswordInvalid": "Passwords do not match", "setPasswordInvalid": "Passwords do not match",
"changePasswordInvalid": "The old password you entered is incorrect", "changePasswordInvalid": "The old password you entered is incorrect",
"removePasswordInvalid": "Incorrect password", "removePasswordInvalid": "Incorrect password",
"setPasswordTitle": "Password Set",
"changePasswordTitle": "Password Changed",
"removePasswordTitle": "Password Removed",
"setPasswordToastDescription": "Your password has been set. Please keep it safe.", "setPasswordToastDescription": "Your password has been set. Please keep it safe.",
"changePasswordToastDescription": "Your password has been changed. Please keep it safe.", "changePasswordToastDescription": "Your password has been changed. Please keep it safe.",
"removePasswordToastDescription": "Your password has been removed.", "removePasswordToastDescription": "Your password has been removed.",
@ -362,7 +358,6 @@
"noContactsToAdd": "No contacts to add", "noContactsToAdd": "No contacts to add",
"noMembersInThisGroup": "No other members in this group", "noMembersInThisGroup": "No other members in this group",
"noModeratorsToRemove": "no admins to remove", "noModeratorsToRemove": "no admins to remove",
"onlyAdminCanRemoveMembers": "You are not the creator",
"onlyAdminCanRemoveMembersDesc": "Only the creator of the group can remove users", "onlyAdminCanRemoveMembersDesc": "Only the creator of the group can remove users",
"createAccount": "Create account", "createAccount": "Create account",
"startInTrayTitle": "Keep in System Tray", "startInTrayTitle": "Keep in System Tray",
@ -486,12 +481,9 @@
"endCall": "End call", "endCall": "End call",
"permissionsSettingsTitle": "Permissions", "permissionsSettingsTitle": "Permissions",
"helpSettingsTitle": "Help", "helpSettingsTitle": "Help",
"cameraPermissionNeededTitle": "Voice/Video Call permissions required",
"cameraPermissionNeeded": "You can enable the 'Voice and video calls' permission in the Privacy Settings.", "cameraPermissionNeeded": "You can enable the 'Voice and video calls' permission in the Privacy Settings.",
"unableToCall": "Cancel your ongoing call first", "unableToCall": "Cancel your ongoing call first",
"unableToCallTitle": "Cannot start new call",
"callMissed": "Missed call from $name$", "callMissed": "Missed call from $name$",
"callMissedTitle": "Call missed",
"noCameraFound": "No camera found", "noCameraFound": "No camera found",
"noAudioInputFound": "No audio input found", "noAudioInputFound": "No audio input found",
"noAudioOutputFound": "No audio output found", "noAudioOutputFound": "No audio output found",

@ -17,23 +17,15 @@ export enum SessionToastType {
} }
type Props = { type Props = {
title: string; description: string;
id?: string; id?: string;
type?: SessionToastType; type?: SessionToastType;
icon?: SessionIconType; icon?: SessionIconType;
description?: string;
closeToast?: any; closeToast?: any;
onToastClick?: () => void; onToastClick?: () => void;
}; };
const TitleDiv = styled.div`
font-size: var(--font-size-md);
line-height: var(--font-size-md);
font-family: var(--font-default);
color: var(--text-primary-color);
text-overflow: ellipsis;
`;
const DescriptionDiv = styled.div` const DescriptionDiv = styled.div`
font-size: var(--font-size-sm); font-size: var(--font-size-sm);
color: var(--text-secondary-color); color: var(--text-secondary-color);
@ -72,7 +64,7 @@ function DescriptionPubkeysReplaced({ description }: { description: string }) {
} }
export const SessionToast = (props: Props) => { export const SessionToast = (props: Props) => {
const { title, description, type, icon } = props; const { description, type, icon } = props;
const toastDesc = description || ''; const toastDesc = description || '';
const toastIconSize = toastDesc ? 'huge' : 'medium'; const toastIconSize = toastDesc ? 'huge' : 'medium';
@ -117,8 +109,7 @@ export const SessionToast = (props: Props) => {
flexDirection="column" flexDirection="column"
className="session-toast" className="session-toast"
> >
<TitleDiv>{title}</TitleDiv> <DescriptionPubkeysReplaced description={toastDesc} />
{toastDesc && <DescriptionPubkeysReplaced description={toastDesc} />}
</Flex> </Flex>
</Flex> </Flex>
); );

@ -1,16 +1,16 @@
/* eslint-disable @typescript-eslint/no-misused-promises */ /* eslint-disable @typescript-eslint/no-misused-promises */
import React from 'react';
import autoBind from 'auto-bind'; import autoBind from 'auto-bind';
import React from 'react';
import { ToastUtils } from '../../session/utils';
import { Data } from '../../data/data'; import { Data } from '../../data/data';
import { SpacerSM } from '../basic/Text'; import { ToastUtils } from '../../session/utils';
import { sessionPassword } from '../../state/ducks/modalDialog'; import { sessionPassword } from '../../state/ducks/modalDialog';
import { LocalizerKeys } from '../../types/LocalizerKeys'; import { LocalizerKeys } from '../../types/LocalizerKeys';
import { SessionButton, SessionButtonColor, SessionButtonType } from '../basic/SessionButton';
import { SessionWrapperModal } from '../SessionWrapperModal';
import { matchesHash, validatePassword } from '../../util/passwordUtils';
import { assertUnreachable } from '../../types/sqlSharedTypes'; import { assertUnreachable } from '../../types/sqlSharedTypes';
import { matchesHash, validatePassword } from '../../util/passwordUtils';
import { SessionWrapperModal } from '../SessionWrapperModal';
import { SessionButton, SessionButtonColor, SessionButtonType } from '../basic/SessionButton';
import { SpacerSM } from '../basic/Text';
export type PasswordAction = 'set' | 'change' | 'remove' | 'enter'; export type PasswordAction = 'set' | 'change' | 'remove' | 'enter';
@ -197,7 +197,6 @@ export class SessionPasswordDialog extends React.Component<Props, State> {
await window.setPassword(enteredPassword, null); await window.setPassword(enteredPassword, null);
ToastUtils.pushToastSuccess( ToastUtils.pushToastSuccess(
'setPasswordSuccessToast', 'setPasswordSuccessToast',
window.i18n('setPasswordTitle'),
window.i18n('setPasswordToastDescription') window.i18n('setPasswordToastDescription')
); );
@ -237,7 +236,6 @@ export class SessionPasswordDialog extends React.Component<Props, State> {
ToastUtils.pushToastSuccess( ToastUtils.pushToastSuccess(
'setPasswordSuccessToast', 'setPasswordSuccessToast',
window.i18n('changePasswordTitle'),
window.i18n('changePasswordToastDescription') window.i18n('changePasswordToastDescription')
); );
@ -259,7 +257,6 @@ export class SessionPasswordDialog extends React.Component<Props, State> {
ToastUtils.pushToastWarning( ToastUtils.pushToastWarning(
'setPasswordSuccessToast', 'setPasswordSuccessToast',
window.i18n('removePasswordTitle'),
window.i18n('removePasswordToastDescription') window.i18n('removePasswordToastDescription')
); );

@ -6,30 +6,28 @@ import { SessionSettingCategory } from '../../components/settings/SessionSetting
import { SectionType, showLeftPaneSection, showSettingsSection } from '../../state/ducks/section'; import { SectionType, showLeftPaneSection, showSettingsSection } from '../../state/ducks/section';
// if you push a toast manually with toast...() be sure to set the type attribute of the SessionToast component // if you push a toast manually with toast...() be sure to set the type attribute of the SessionToast component
export function pushToastError(id: string, title: string, description?: string) { export function pushToastError(id: string, description: string) {
toast.error( toast.error(<SessionToast description={description} type={SessionToastType.Error} />, {
<SessionToast title={title} description={description} type={SessionToastType.Error} />, toastId: id,
{ toastId: id, updateId: id } updateId: id,
); });
} }
export function pushToastWarning(id: string, title: string, description?: string) { export function pushToastWarning(id: string, description: string) {
toast.warning( toast.warning(<SessionToast description={description} type={SessionToastType.Warning} />, {
<SessionToast title={title} description={description} type={SessionToastType.Warning} />, toastId: id,
{ toastId: id, updateId: id } updateId: id,
); });
} }
export function pushToastInfo( export function pushToastInfo(
id: string, id: string,
title: string, description: string,
description?: string,
onToastClick?: () => void, onToastClick?: () => void,
delay?: number delay?: number
) { ) {
toast.info( toast.info(
<SessionToast <SessionToast
title={title}
description={description} description={description}
type={SessionToastType.Info} type={SessionToastType.Info}
onToastClick={onToastClick} onToastClick={onToastClick}
@ -38,19 +36,9 @@ export function pushToastInfo(
); );
} }
export function pushToastSuccess( export function pushToastSuccess(id: string, description: string, icon?: SessionIconType) {
id: string,
title: string,
description?: string,
icon?: SessionIconType
) {
toast.success( toast.success(
<SessionToast <SessionToast description={description} type={SessionToastType.Success} icon={icon} />,
title={title}
description={description}
type={SessionToastType.Success}
icon={icon}
/>,
{ toastId: id, updateId: id } { toastId: id, updateId: id }
); );
} }
@ -64,7 +52,7 @@ export function pushLoadAttachmentFailure(message?: string) {
} }
export function pushFileSizeError(limit: number, units: string) { export function pushFileSizeError(limit: number, units: string) {
pushToastError('fileSizeWarning', window.i18n('fileSizeWarning'), `Max size: ${limit} ${units}`); pushToastError('fileSizeWarning', `${window.i18n('fileSizeWarning')}: ${limit} ${units}`);
} }
export function pushFileSizeErrorAsByte(bytesCount: number) { export function pushFileSizeErrorAsByte(bytesCount: number) {
@ -130,15 +118,11 @@ export function pushMessageDeleteForbidden() {
} }
export function pushUnableToCall() { export function pushUnableToCall() {
pushToastError('unableToCall', window.i18n('unableToCallTitle'), window.i18n('unableToCall')); pushToastError('unableToCall', window.i18n('unableToCall'));
} }
export function pushedMissedCall(conversationName: string) { export function pushedMissedCall(conversationName: string) {
pushToastInfo( pushToastInfo('missedCall', window.i18n('callMissed', [conversationName]));
'missedCall',
window.i18n('callMissedTitle'),
window.i18n('callMissed', [conversationName])
);
} }
const openPermissionsSettings = () => { const openPermissionsSettings = () => {
@ -150,7 +134,6 @@ export function pushedMissedCallCauseOfPermission(conversationName: string) {
const id = 'missedCallPermission'; const id = 'missedCallPermission';
toast.info( toast.info(
<SessionToast <SessionToast
title={window.i18n('callMissedTitle')}
description={window.i18n('callMissedCausePermission', [conversationName])} description={window.i18n('callMissedCausePermission', [conversationName])}
type={SessionToastType.Info} type={SessionToastType.Info}
onToastClick={openPermissionsSettings} onToastClick={openPermissionsSettings}
@ -160,17 +143,12 @@ export function pushedMissedCallCauseOfPermission(conversationName: string) {
} }
export function pushedMissedCallNotApproved(displayName: string) { export function pushedMissedCallNotApproved(displayName: string) {
pushToastInfo( pushToastInfo('missedCall', window.i18n('callMissedNotApproved', [displayName]));
'missedCall',
window.i18n('callMissedTitle'),
window.i18n('callMissedNotApproved', [displayName])
);
} }
export function pushVideoCallPermissionNeeded() { export function pushVideoCallPermissionNeeded() {
pushToastInfo( pushToastInfo(
'videoCallPermissionNeeded', 'videoCallPermissionNeeded',
window.i18n('cameraPermissionNeededTitle'),
window.i18n('cameraPermissionNeeded'), window.i18n('cameraPermissionNeeded'),
openPermissionsSettings openPermissionsSettings
); );
@ -179,7 +157,6 @@ export function pushVideoCallPermissionNeeded() {
export function pushAudioPermissionNeeded() { export function pushAudioPermissionNeeded() {
pushToastInfo( pushToastInfo(
'audioPermissionNeeded', 'audioPermissionNeeded',
window.i18n('audioPermissionNeededTitle'),
window.i18n('audioPermissionNeeded'), window.i18n('audioPermissionNeeded'),
openPermissionsSettings openPermissionsSettings
); );
@ -210,28 +187,15 @@ export function someDeletionsFailed() {
} }
export function pushDeleted(messageCount: number) { export function pushDeleted(messageCount: number) {
pushToastSuccess( pushToastSuccess('deleted', window.i18n('deleted', [messageCount.toString()]), 'check');
'deleted',
window.i18n('deleted', [messageCount.toString()]),
undefined,
'check'
);
} }
export function pushCannotRemoveCreatorFromGroup() { export function pushCannotRemoveCreatorFromGroup() {
pushToastWarning( pushToastWarning('cannotRemoveCreatorFromGroup', window.i18n('cannotRemoveCreatorFromGroupDesc'));
'cannotRemoveCreatorFromGroup',
window.i18n('cannotRemoveCreatorFromGroup'),
window.i18n('cannotRemoveCreatorFromGroupDesc')
);
} }
export function pushOnlyAdminCanRemove() { export function pushOnlyAdminCanRemove() {
pushToastInfo( pushToastInfo('onlyAdminCanRemoveMembers', window.i18n('onlyAdminCanRemoveMembersDesc'));
'onlyAdminCanRemoveMembers',
window.i18n('onlyAdminCanRemoveMembers'),
window.i18n('onlyAdminCanRemoveMembersDesc')
);
} }
export function pushFailedToAddAsModerator() { export function pushFailedToAddAsModerator() {
@ -275,5 +239,5 @@ export function pushMustBeApproved() {
} }
export function pushRateLimitHitReactions() { export function pushRateLimitHitReactions() {
pushToastInfo('reactRateLimit', '', window?.i18n?.('rateLimitReactMessage')); // because otherwise test fails pushToastInfo('reactRateLimit', window?.i18n?.('rateLimitReactMessage')); // "?." are needed for unit tests env
} }

@ -64,21 +64,18 @@ function displayFailedInvitesForGroup(groupPk: GroupPubkeyType) {
case 1: case 1:
ToastUtils.pushToastWarning( ToastUtils.pushToastWarning(
`invite-failed${groupPk}`, `invite-failed${groupPk}`,
window.i18n('inviteFailed'),
window.i18n('groupInviteFailedOne', [...thisGroupFailures.failedMembers, groupPk]) window.i18n('groupInviteFailedOne', [...thisGroupFailures.failedMembers, groupPk])
); );
break; break;
case 2: case 2:
ToastUtils.pushToastWarning( ToastUtils.pushToastWarning(
`invite-failed${groupPk}`, `invite-failed${groupPk}`,
window.i18n('inviteFailed'),
window.i18n('groupInviteFailedTwo', [...thisGroupFailures.failedMembers, groupPk]) window.i18n('groupInviteFailedTwo', [...thisGroupFailures.failedMembers, groupPk])
); );
break; break;
default: default:
ToastUtils.pushToastWarning( ToastUtils.pushToastWarning(
`invite-failed${groupPk}`, `invite-failed${groupPk}`,
window.i18n('inviteFailed'),
window.i18n('groupInviteFailedOthers', [ window.i18n('groupInviteFailedOthers', [
thisGroupFailures.failedMembers[0], thisGroupFailures.failedMembers[0],
`${thisGroupFailures.failedMembers.length - 1}`, `${thisGroupFailures.failedMembers.length - 1}`,

@ -128,8 +128,7 @@ export async function autoScaleAvatarBlob(file: File) {
} catch (e) { } catch (e) {
ToastUtils.pushToastError( ToastUtils.pushToastError(
'pickFileForAvatar', 'pickFileForAvatar',
'An error happened while picking/resizing the image', `An error happened while picking/resizing the image: "${e.message || ''}"`
e.message || ''
); );
window.log.error(e); window.log.error(e);
return null; return null;

Loading…
Cancel
Save