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"
text={versionInfo}
buttonType={SessionButtonType.Simple}
showToast={false}
/>
<CopyToClipboardButton
className="os"
text={systemInfo}
buttonType={SessionButtonType.Simple}
showToast={false}
/>
<CopyToClipboardButton
className="commitHash"
text={commitInfo}
buttonType={SessionButtonType.Simple}
showToast={false}
/>
{environmentStates.length ? (
<CopyToClipboardButton
className="environment"
text={environmentStates.join(' - ')}
buttonType={SessionButtonType.Simple}
showToast={false}
/>
) : null}
<a href="https://getsession.org">https://getsession.org</a>

@ -18,7 +18,6 @@ export enum SessionToastType {
type Props = {
description: string;
id?: string;
type?: SessionToastType;
icon?: SessionIconType;
@ -28,7 +27,7 @@ type Props = {
const DescriptionDiv = styled.div`
font-size: var(--font-size-sm);
color: var(--text-secondary-color);
color: var(--text-primary-color);
text-overflow: ellipsis;
font-family: var(--font-default);
padding-top: var(--margins-xs);

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

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

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

@ -222,7 +222,8 @@ export async function deleteMessagesFromSwarmAndCompletelyLocally(
conversation: ConversationModel,
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)) {
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 { GroupSync } from '../../../utils/job_runners/jobs/GroupSyncJob';
import { destroyMessagesAndUpdateRedux } from '../../../disappearing_messages';
import { ConversationTypeEnum } from '../../../../models/types';
/**
* 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];
// 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.
const memberConvo = ConvoHub.use().get(member.pubkeyHex);
if (!memberConvo) {
let memberConvoInDB = ConvoHub.use().get(member.pubkeyHex);
if (memberConvoInDB) {
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
await ProfileManager.updateProfileOfContact(
member.pubkeyHex,

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

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

Loading…
Cancel
Save