Merge pull request #3347 from urbit/mp/chat/copy-notice

chat: restore 'copied' notice on copying names
This commit is contained in:
matildepark 2020-09-14 21:08:37 -04:00 committed by GitHub
commit f4b4a6b1fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,10 +1,9 @@
import React, { Component } from 'react'; import React from 'react';
import { OverlaySigil } from './overlay-sigil'; import { OverlaySigil } from './overlay-sigil';
import MessageContent from './message-content'; import MessageContent from './message-content';
import { uxToHex, cite, writeText } from '~/logic/lib/util'; import { uxToHex, cite, writeText } from '~/logic/lib/util';
import moment from 'moment'; import moment from 'moment';
export const Message = (props) => { export const Message = (props) => {
const { const {
msg, msg,
@ -23,7 +22,6 @@ export const Message = (props) => {
renderSigil ? 'hh:mm a' : 'hh:mm' renderSigil ? 'hh:mm a' : 'hh:mm'
); );
return ( return (
<div className={containerClass} <div className={containerClass}
style={{ style={{
@ -70,6 +68,17 @@ const renderWithSigil = (props, timestamp) => {
name = cite(props.msg.author); name = cite(props.msg.author);
} }
let nameSpan = null;
const copyNotice = (saveName) => {
if (nameSpan !== null) {
nameSpan.innerText = 'Copied';
setTimeout(() => {
nameSpan.innerText = saveName;
}, 800);
}
};
return ( return (
<div className="flex w-100"> <div className="flex w-100">
<OverlaySigil <OverlaySigil
@ -92,8 +101,10 @@ const renderWithSigil = (props, timestamp) => {
'mw5 db truncate pointer ' + 'mw5 db truncate pointer ' +
(showNickname ? '' : 'mono') (showNickname ? '' : 'mono')
} }
ref={(e) => nameSpan = e}
onClick={() => { onClick={() => {
writeText(props.msg.author); writeText(`~${props.msg.author}`);
copyNotice(name);
}} }}
title={`~${props.msg.author}`} title={`~${props.msg.author}`}
> >
@ -109,5 +120,5 @@ const renderWithSigil = (props, timestamp) => {
</div> </div>
</div> </div>
); );
} };