fix: show toast in the about window

pull/3281/head
Audric Ackermann 4 months ago
parent 605683c5b2
commit 30064e5740
No known key found for this signature in database

@ -95,26 +95,22 @@ 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>

@ -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 (
<DescriptionDiv>
<SessionHtmlRenderer html={replacedWithNames} />
<SessionHtmlRenderer html={description} />
</DescriptionDiv>
);
}

@ -11,13 +11,12 @@ 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, 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<SessionIconButtonProps, 'children' | 'onCli
CopyProps;
export const CopyToClipboardIcon = (props: CopyToClipboardIconProps & { copyContent: string }) => {
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);
}

@ -115,19 +115,6 @@ export function useConversationsUsernameWithQuoteOrFullPubkey(pubkeys: Array<str
});
}
/**
* Returns either the nickname, the profileName, a shortened pubkey, or "you" for our own pubkey
*/
export function useConversationsUsernameWithQuoteOrShortPk(pubkeys: Array<string>) {
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<string>) {
return useSelector((state: StateType) => {
return pubkeys.map(pk => {

Loading…
Cancel
Save