From 30064e5740e565bff8fd294189f9fc6bad0deb96 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Tue, 10 Dec 2024 16:47:44 +1100 Subject: [PATCH] fix: show toast in the about window --- ts/components/AboutView.tsx | 4 ---- ts/components/basic/SessionToast.tsx | 19 +++---------------- .../buttons/CopyToClipboardButton.tsx | 15 ++++++--------- ts/hooks/useParamSelector.ts | 13 ------------- 4 files changed, 9 insertions(+), 42 deletions(-) diff --git a/ts/components/AboutView.tsx b/ts/components/AboutView.tsx index 58ae1ec98..a42e8b5d5 100644 --- a/ts/components/AboutView.tsx +++ b/ts/components/AboutView.tsx @@ -95,26 +95,22 @@ export const AboutView = () => { className="version" text={versionInfo} buttonType={SessionButtonType.Simple} - showToast={false} /> {environmentStates.length ? ( ) : null} https://getsession.org diff --git a/ts/components/basic/SessionToast.tsx b/ts/components/basic/SessionToast.tsx index aed2bf3df..d90475c7f 100644 --- a/ts/components/basic/SessionToast.tsx +++ b/ts/components/basic/SessionToast.tsx @@ -1,10 +1,9 @@ -import { clone, noop } from 'lodash'; +import { noop } from 'lodash'; import styled from 'styled-components'; import { Flex } from './Flex'; -import { useConversationsUsernameWithQuoteOrShortPk } from '../../hooks/useParamSelector'; import { SessionIcon, SessionIconType } from '../icon'; import { SessionHtmlRenderer } from './SessionHTMLRenderer'; @@ -39,25 +38,13 @@ const IconDiv = styled.div` margin: 0 var(--margins-sm) 0 var(--margins-xs); `; -function useReplacePkInTextWithNames(description: string) { - const pubkeysToLookup = [...description.matchAll(/0[3,5][0-9a-fA-F]{64}/g)]; - const memberNames = useConversationsUsernameWithQuoteOrShortPk(pubkeysToLookup.map(m => m[0])); - let replacedWithNames = clone(description); - for (let index = 0; index < memberNames.length; index++) { - const name = memberNames[index]; - const pk = pubkeysToLookup[index][0]; - replacedWithNames = replacedWithNames.replace(pk, name); - } - - return replacedWithNames; -} function DescriptionPubkeysReplaced({ description }: { description: string }) { - const replacedWithNames = useReplacePkInTextWithNames(description); + // const replacedWithNames = useReplacePkInTextWithNames(description); return ( - + ); } diff --git a/ts/components/buttons/CopyToClipboardButton.tsx b/ts/components/buttons/CopyToClipboardButton.tsx index a9a308395..113251cca 100644 --- a/ts/components/buttons/CopyToClipboardButton.tsx +++ b/ts/components/buttons/CopyToClipboardButton.tsx @@ -11,13 +11,12 @@ type CopyProps = { copyContent?: string; onCopyComplete?: (copiedValue: string | undefined) => void; hotkey?: boolean; - showToast?: boolean; }; type CopyToClipboardButtonProps = Omit & CopyProps; export const CopyToClipboardButton = (props: CopyToClipboardButtonProps) => { - const { copyContent, onCopyComplete, hotkey = false, text, showToast = true } = props; + const { copyContent, onCopyComplete, hotkey = false, text } = props; const [copied, setCopied] = useState(false); const onClick = () => { @@ -28,9 +27,8 @@ export const CopyToClipboardButton = (props: CopyToClipboardButtonProps) => { } clipboard.writeText(toCopy); - if (showToast) { - ToastUtils.pushCopiedToClipBoard(); - } + ToastUtils.pushCopiedToClipBoard(); + setCopied(true); if (onCopyComplete) { onCopyComplete(text); @@ -56,13 +54,12 @@ type CopyToClipboardIconProps = Omit { - const { copyContent, onCopyComplete, hotkey = false, showToast = true } = props; + const { copyContent, onCopyComplete, hotkey = false } = props; const onClick = () => { clipboard.writeText(copyContent); - if (showToast) { - ToastUtils.pushCopiedToClipBoard(); - } + ToastUtils.pushCopiedToClipBoard(); + if (onCopyComplete) { onCopyComplete(copyContent); } diff --git a/ts/hooks/useParamSelector.ts b/ts/hooks/useParamSelector.ts index a4003f0c6..60224f12b 100644 --- a/ts/hooks/useParamSelector.ts +++ b/ts/hooks/useParamSelector.ts @@ -115,19 +115,6 @@ export function useConversationsUsernameWithQuoteOrFullPubkey(pubkeys: Array) { - return useSelector((state: StateType) => { - return pubkeys.map(pubkey => { - const nameGot = usernameForQuoteOrFullPk(pubkey, state); - - return nameGot?.length ? nameGot : PubKey.shorten(pubkey); - }); - }); -} - export function useConversationsNicknameRealNameOrShortenPubkey(pubkeys: Array) { return useSelector((state: StateType) => { return pubkeys.map(pk => {