feat: allow to not trigger toast on copyToClipboardButton

because the about window doesn't have a full redux store setup, and the
toasts need redux currently
pull/3281/head
Audric Ackermann 5 months ago
parent 9507cded10
commit 3ab94a7e00
No known key found for this signature in database

@ -95,22 +95,26 @@ export const AboutView = () => {
className="version" className="version"
text={versionInfo} text={versionInfo}
buttonType={SessionButtonType.Simple} buttonType={SessionButtonType.Simple}
showToast={false}
/> />
<CopyToClipboardButton <CopyToClipboardButton
className="os" className="os"
text={systemInfo} text={systemInfo}
buttonType={SessionButtonType.Simple} buttonType={SessionButtonType.Simple}
showToast={false}
/> />
<CopyToClipboardButton <CopyToClipboardButton
className="commitHash" className="commitHash"
text={commitInfo} text={commitInfo}
buttonType={SessionButtonType.Simple} buttonType={SessionButtonType.Simple}
showToast={false}
/> />
{environmentStates.length ? ( {environmentStates.length ? (
<CopyToClipboardButton <CopyToClipboardButton
className="environment" className="environment"
text={environmentStates.join(' - ')} text={environmentStates.join(' - ')}
buttonType={SessionButtonType.Simple} buttonType={SessionButtonType.Simple}
showToast={false}
/> />
) : null} ) : null}
<a href="https://getsession.org">https://getsession.org</a> <a href="https://getsession.org">https://getsession.org</a>

@ -18,7 +18,6 @@ export enum SessionToastType {
type Props = { type Props = {
description: string; description: string;
id?: string; id?: string;
type?: SessionToastType; type?: SessionToastType;
icon?: SessionIconType; icon?: SessionIconType;
@ -28,7 +27,7 @@ type Props = {
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-primary-color);
text-overflow: ellipsis; text-overflow: ellipsis;
font-family: var(--font-default); font-family: var(--font-default);
padding-top: var(--margins-xs); padding-top: var(--margins-xs);

@ -11,12 +11,13 @@ type CopyProps = {
copyContent?: string; copyContent?: string;
onCopyComplete?: (copiedValue: string | undefined) => void; onCopyComplete?: (copiedValue: string | undefined) => void;
hotkey?: boolean; hotkey?: boolean;
showToast?: boolean;
}; };
type CopyToClipboardButtonProps = Omit<SessionButtonProps, 'children' | 'onClick'> & CopyProps; type CopyToClipboardButtonProps = Omit<SessionButtonProps, 'children' | 'onClick'> & CopyProps;
export const CopyToClipboardButton = (props: CopyToClipboardButtonProps) => { export const CopyToClipboardButton = (props: CopyToClipboardButtonProps) => {
const { copyContent, onCopyComplete, hotkey = false, text } = props; const { copyContent, onCopyComplete, hotkey = false, text, showToast = true } = props;
const [copied, setCopied] = useState(false); const [copied, setCopied] = useState(false);
const onClick = () => { const onClick = () => {
@ -27,8 +28,9 @@ export const CopyToClipboardButton = (props: CopyToClipboardButtonProps) => {
} }
clipboard.writeText(toCopy); clipboard.writeText(toCopy);
if (showToast) {
ToastUtils.pushCopiedToClipBoard(); ToastUtils.pushCopiedToClipBoard();
}
setCopied(true); setCopied(true);
if (onCopyComplete) { if (onCopyComplete) {
onCopyComplete(text); onCopyComplete(text);
@ -54,11 +56,13 @@ type CopyToClipboardIconProps = Omit<SessionIconButtonProps, 'children' | 'onCli
CopyProps; CopyProps;
export const CopyToClipboardIcon = (props: CopyToClipboardIconProps & { copyContent: string }) => { export const CopyToClipboardIcon = (props: CopyToClipboardIconProps & { copyContent: string }) => {
const { copyContent, onCopyComplete, hotkey = false } = props; const { copyContent, onCopyComplete, hotkey = false, showToast = true } = props;
const onClick = () => { const onClick = () => {
clipboard.writeText(copyContent); clipboard.writeText(copyContent);
ToastUtils.pushCopiedToClipBoard(); if (showToast) {
ToastUtils.pushCopiedToClipBoard();
}
if (onCopyComplete) { if (onCopyComplete) {
onCopyComplete(copyContent); onCopyComplete(copyContent);
} }

@ -1,5 +1,5 @@
import { compact, flatten, isEqual } from 'lodash'; import { compact, flatten, isEqual } from 'lodash';
import { useEffect, useState } from 'react'; import { SessionDataTestId, useEffect, useState } from 'react';
import { useDispatch } from 'react-redux'; import { useDispatch } from 'react-redux';
import useInterval from 'react-use/lib/useInterval'; import useInterval from 'react-use/lib/useInterval';
@ -317,7 +317,7 @@ export const OverlayRightPanelSettings = () => {
groupInfoActions.triggerFakeAvatarUpdate({ groupPk: selectedConvoKey }) as any groupInfoActions.triggerFakeAvatarUpdate({ groupPk: selectedConvoKey }) as any
); );
}} }}
dataTestId="edit-group-name" dataTestId={'' as SessionDataTestId}
/> />
<PanelIconButton <PanelIconButton
iconType={'group'} iconType={'group'}
@ -333,7 +333,7 @@ export const OverlayRightPanelSettings = () => {
}) as any }) as any
); );
}} }}
dataTestId="edit-group-name" dataTestId={'' as SessionDataTestId}
/> />
<PanelIconButton <PanelIconButton
iconType={'group'} iconType={'group'}
@ -349,7 +349,7 @@ export const OverlayRightPanelSettings = () => {
}) as any }) as any
); );
}} }}
dataTestId="edit-group-name" dataTestId={'' as SessionDataTestId}
/> />
</> </>
) : null} ) : null}

@ -189,6 +189,12 @@ export function UpdateGroupNameDialog(props: { conversationId: string }) {
type="text" type="text"
value={newGroupName} value={newGroupName}
placeholder={window.i18n('groupNameEnter')} placeholder={window.i18n('groupNameEnter')}
onKeyDown={e => {
if (e.key === 'Enter') {
onClickOK();
e.preventDefault();
}
}}
onChange={e => setNewGroupName(e.target.value)} onChange={e => setNewGroupName(e.target.value)}
tabIndex={0} tabIndex={0}
required={true} required={true}

@ -222,7 +222,8 @@ export async function deleteMessagesFromSwarmAndCompletelyLocally(
conversation: ConversationModel, conversation: ConversationModel,
messages: Array<MessageModel> messages: Array<MessageModel>
) { ) {
const pubkey = conversation.id; // If this is a private chat, we can only delete messages on our own swarm, so use our "side" of the conversation
const pubkey = conversation.isPrivate() ? UserUtils.getOurPubKeyStrFromCache() : conversation.id;
if (!PubKey.is03Pubkey(pubkey) && !PubKey.is05Pubkey(pubkey)) { if (!PubKey.is03Pubkey(pubkey) && !PubKey.is05Pubkey(pubkey)) {
throw new Error('deleteMessagesFromSwarmAndCompletelyLocally needs a 03 or 05 pk'); throw new Error('deleteMessagesFromSwarmAndCompletelyLocally needs a 03 or 05 pk');
} }

@ -18,6 +18,7 @@ import { ProfileManager } from '../../../profile_manager/ProfileManager';
import { UserUtils } from '../../../utils'; import { UserUtils } from '../../../utils';
import { GroupSync } from '../../../utils/job_runners/jobs/GroupSyncJob'; import { GroupSync } from '../../../utils/job_runners/jobs/GroupSyncJob';
import { destroyMessagesAndUpdateRedux } from '../../../disappearing_messages'; import { destroyMessagesAndUpdateRedux } from '../../../disappearing_messages';
import { ConversationTypeEnum } from '../../../../models/types';
/** /**
* This is a basic optimization to avoid running the logic when the `deleteBeforeSeconds` * This is a basic optimization to avoid running the logic when the `deleteBeforeSeconds`
@ -163,11 +164,18 @@ async function handleMetaMergeResults(groupPk: GroupPubkeyType) {
const member = members[index]; const member = members[index];
// if our DB doesn't have details about this user, set them. Otherwise we don't want to overwrite our changes with those // if our DB doesn't have details about this user, set them. Otherwise we don't want to overwrite our changes with those
// because they are most likely out of date from what we get from the user himself. // because they are most likely out of date from what we get from the user himself.
const memberConvo = ConvoHub.use().get(member.pubkeyHex); let memberConvoInDB = ConvoHub.use().get(member.pubkeyHex);
if (!memberConvo) { if (memberConvoInDB) {
continue; continue;
} }
if (member.name && member.name !== memberConvo.getRealSessionUsername()) { if (!memberConvoInDB) {
// eslint-disable-next-line no-await-in-loop
memberConvoInDB = await ConvoHub.use().getOrCreateAndWait(
member.pubkeyHex,
ConversationTypeEnum.PRIVATE
);
}
if (member.name && member.name !== memberConvoInDB.getRealSessionUsername()) {
// eslint-disable-next-line no-await-in-loop // eslint-disable-next-line no-await-in-loop
await ProfileManager.updateProfileOfContact( await ProfileManager.updateProfileOfContact(
member.pubkeyHex, member.pubkeyHex,

@ -303,6 +303,7 @@ export const GroupInvite = {
GroupInviteJob, GroupInviteJob,
addJob, addJob,
}; };
function updateFailedStateForMember(groupPk: GroupPubkeyType, member: PubkeyType, failed: boolean) { function updateFailedStateForMember(groupPk: GroupPubkeyType, member: PubkeyType, failed: boolean) {
let thisGroupFailure = invitesFailed.get(groupPk); let thisGroupFailure = invitesFailed.get(groupPk);

@ -54,6 +54,7 @@ import {
WithFromMemberLeftMessage, WithFromMemberLeftMessage,
WithRemoveMembers, WithRemoveMembers,
} from '../../session/types/with'; } from '../../session/types/with';
import { updateGroupNameModal } from './modalDialog';
export type GroupState = { export type GroupState = {
infos: Record<GroupPubkeyType, GroupInfoGet>; infos: Record<GroupPubkeyType, GroupInfoGet>;
@ -1152,6 +1153,7 @@ const currentDeviceGroupNameChange = createAsyncThunk(
await checkWeAreAdminOrThrow(groupPk, 'currentDeviceGroupNameChange'); await checkWeAreAdminOrThrow(groupPk, 'currentDeviceGroupNameChange');
await handleNameChangeFromUI({ groupPk, ...args }); await handleNameChangeFromUI({ groupPk, ...args });
window.inboxStore?.dispatch(updateGroupNameModal(null));
return { return {
groupPk, groupPk,

Loading…
Cancel
Save