reformat chat

fix timestamps
This commit is contained in:
HF 2022-02-09 20:11:54 +01:00
parent 3e6f02f48a
commit 874a44fbd9
7 changed files with 56 additions and 16 deletions

View File

@ -7,7 +7,11 @@ import { useSelector, useDispatch } from 'react-redux';
import { showContextMenu } from '../actions'; import { showContextMenu } from '../actions';
import { MarkdownParagraph } from './Markdown'; import { MarkdownParagraph } from './Markdown';
import { colorFromText, setBrightness } from '../core/utils'; import {
colorFromText,
setBrightness,
getDateTimeString,
} from '../core/utils';
import { parseParagraph } from '../core/MarkdownParser'; import { parseParagraph } from '../core/MarkdownParser';
@ -17,6 +21,7 @@ function ChatMessage({
country, country,
windowId, windowId,
msg, msg,
ts,
}) { }) {
if (!name) { if (!name) {
return null; return null;
@ -43,7 +48,7 @@ function ChatMessage({
const pArray = parseParagraph(msg); const pArray = parseParagraph(msg);
return ( return (
<div className="chatmsg"> <li className="chatmsg">
<div className="chatname"> <div className="chatname">
{ {
(!isInfo && !isEvent) (!isInfo && !isEvent)
@ -81,14 +86,17 @@ function ChatMessage({
{name} {name}
</span> </span>
:&nbsp; :&nbsp;
<span className="chatts">
{getDateTimeString(ts)}
</span>
</> </>
) )
} }
</div> </div>
<span className={className}> <div className={className}>
<MarkdownParagraph pArray={pArray} /> <MarkdownParagraph pArray={pArray} />
</span> </div>
</div> </li>
); );
} }

View File

@ -369,6 +369,7 @@ function parseOpts(inOpts) {
export function parseParagraph(text, inOpts) { export function parseParagraph(text, inOpts) {
const opts = parseOpts(inOpts); const opts = parseOpts(inOpts);
const mText = new MString(text); const mText = new MString(text);
console.log('parse', text);
return parseMParagraph(mText, opts); return parseMParagraph(mText, opts);
} }

View File

@ -374,3 +374,17 @@ export function getExt(link) {
} }
return link.slice(posDot, paramStart); return link.slice(posDot, paramStart);
} }
/*
* convert timestamp to human readable date/time string
* @param timestamp Unix timestamp in seconds
* @return descriptive string of time
*/
export function getDateTimeString(timestamp) {
const curDate = new Date();
const date = new Date(timestamp * 1000);
if (date.getDate() !== curDate.getDate()) {
return date.toLocaleString();
}
return date.toLocaleTimeString();
}

View File

@ -667,18 +667,26 @@ tr:nth-child(even) {
.chatname { .chatname {
font-size: 13px; font-size: 13px;
white-space: nowrap; white-space: nowrap;
display: inline-block; display: flex;
}
.chatts {
color: #83839f;
font-size: 10px;
flex-grow: 1;
text-align: right;
} }
.chatmsg { .chatmsg {
color: #030303;
font-size: 13px; font-size: 13px;
user-select: text; user-select: text;
margin: 0; margin: 0;
display: flex; }
flex-direction: row; .chatmsg:hover {
background-color: #ececec;
} }
.msg { .msg {
flex: 1; color: #2d2d2d;
padding-left: 15px;
color:
} }
.msg.info { .msg.info {
color: #cc0000; color: #cc0000;

View File

@ -136,8 +136,11 @@ tr:nth-child(even) {
background-color: rgba(187, 187, 187, 0.75); background-color: rgba(187, 187, 187, 0.75);
} }
.chatmsg { .chatmsg:hover {
color: white; background-color: #474747;
}
.msg {
color: #f3f3f3;
} }
.msg.info{ .msg.info{
color: #ff91a6; color: #ff91a6;

View File

@ -141,8 +141,11 @@ tr:nth-child(even) {
background-color: rgba(187, 187, 187, 0.75); background-color: rgba(187, 187, 187, 0.75);
} }
.chatmsg { .chatmsg:hover {
color: #fffcf7; background-color: #474747;
}
.msg {
color: #f3f3f3;
} }
.msg.info{ .msg.info{
color: #ff91a6; color: #ff91a6;

View File

@ -121,8 +121,11 @@ tr:nth-child(even) {
background-color: rgba(187, 187, 187, 0.75); background-color: rgba(187, 187, 187, 0.75);
} }
.chatmsg { .chatmsg:hover {
color: white; background-color: #474747;
}
.msg {
color: #f3f3f3;
} }
.msg.info{ .msg.info{
color: #ff91a6; color: #ff91a6;