message grouping

This commit is contained in:
Andrew Gundersen 2021-03-13 11:59:37 -06:00
commit feccda8ec9
6 changed files with 110 additions and 37 deletions

View file

@ -2,13 +2,13 @@ import { RenderMessage, ClientMessage } from "@/types/message/index";
import { v4 as uuidv4 } from 'uuid';
// Create a RenderMessage object directly from json string.
export function initRenderMessageFromString(message_str: string) {
export function initRenderMessageFromString(messageStr: string) {
// Parse the string.
const m = JSON.parse(message_str);
const m = JSON.parse(messageStr);
// Auto set uid and time.
let currentdate = new Date();
const currentdate = new Date();
const message: RenderMessage = {
content: m.content,
@ -16,7 +16,7 @@ export function initRenderMessageFromString(message_str: string) {
modifier: m.modifier,
time: currentdate.getTime(),
uid: uuidv4(),
isChild: false
isChild: "none"
}
return message
@ -26,7 +26,7 @@ export function initRenderMessageFromString(message_str: string) {
export function initRenderMessage(text: string, audio: string, context: string, modifier: string) {
// Auto set uid and time.
let currentdate = new Date();
const currentdate = new Date();
const message: RenderMessage = {
content: {
@ -37,7 +37,7 @@ export function initRenderMessage(text: string, audio: string, context: string,
modifier: modifier,
time: currentdate.getTime(),
uid: uuidv4(),
isChild: false
isChild: "none"
}
return message