mirror of
https://github.com/hexastack/hexabot
synced 2025-01-22 10:35:37 +00:00
Merge pull request #413 from Hexastack/fix/refactor-hard-coded-values
refactor: hard coded direction values with enum
This commit is contained in:
commit
271d52f4fa
@ -10,7 +10,7 @@ import React from "react";
|
||||
|
||||
import { useTranslation } from "../../hooks/useTranslation";
|
||||
import { useColors } from "../../providers/ColorProvider";
|
||||
import { TMessage } from "../../types/message.types";
|
||||
import { Direction, TMessage } from "../../types/message.types";
|
||||
import FileIcon from "../icons/FileIcon";
|
||||
|
||||
import "./FileMessage.scss";
|
||||
@ -22,7 +22,7 @@ interface FileMessageProps {
|
||||
const FileMessage: React.FC<FileMessageProps> = ({ message }) => {
|
||||
const { t } = useTranslation();
|
||||
const { colors: allColors } = useColors();
|
||||
const colors = allColors[message.direction || "received"];
|
||||
const colors = allColors[message.direction || Direction.received];
|
||||
|
||||
if (!("type" in message.data)) {
|
||||
throw new Error("Unable to detect type for file message");
|
||||
|
@ -10,7 +10,7 @@ import React, { useEffect, useRef, useState } from "react";
|
||||
|
||||
import { useColors } from "../../providers/ColorProvider";
|
||||
import { useWidget } from "../../providers/WidgetProvider";
|
||||
import { TMessage } from "../../types/message.types";
|
||||
import { Direction, TMessage } from "../../types/message.types";
|
||||
|
||||
import "./GeolocationMessage.scss";
|
||||
|
||||
@ -58,7 +58,7 @@ const GeolocationMessage: React.FC<GeolocationMessageProps> = ({ message }) => {
|
||||
},${coordinates.lat - 0.1},${coordinates.lng + 0.1},${
|
||||
coordinates.lat + 0.1
|
||||
}&layer=mapnik&marker=${coordinates.lat},${coordinates.lng}`;
|
||||
const colors = allColors[message.direction || "received"];
|
||||
const colors = allColors[message.direction || Direction.received];
|
||||
|
||||
return (
|
||||
<div
|
||||
|
@ -9,7 +9,7 @@
|
||||
import React from "react";
|
||||
|
||||
import { useColors } from "../../providers/ColorProvider";
|
||||
import { TMessage } from "../../types/message.types";
|
||||
import { Direction, TMessage } from "../../types/message.types";
|
||||
|
||||
import ButtonsMessage from "./ButtonMessage";
|
||||
|
||||
@ -39,7 +39,7 @@ const ListMessage: React.FC<ListMessageProps> = ({ messageList }) => {
|
||||
throw new Error("Unable to find elements");
|
||||
}
|
||||
|
||||
const colors = allColors[messageList.direction || "received"];
|
||||
const colors = allColors[messageList.direction || Direction.received];
|
||||
|
||||
return (
|
||||
<div
|
||||
|
@ -10,7 +10,7 @@ import Autolinker from "autolinker";
|
||||
import React, { useEffect, useRef } from "react";
|
||||
|
||||
import { useColors } from "../../providers/ColorProvider";
|
||||
import { TMessage } from "../../types/message.types";
|
||||
import { Direction, TMessage } from "../../types/message.types";
|
||||
|
||||
import "./TextMessage.scss";
|
||||
|
||||
@ -28,7 +28,7 @@ const TextMessage: React.FC<TextMessageProps> = ({ message }) => {
|
||||
}, [message]);
|
||||
|
||||
const autoLink = () => {
|
||||
if (message.direction === "received" && messageTextRef.current) {
|
||||
if (message.direction === Direction.received && messageTextRef.current) {
|
||||
const text = messageTextRef.current.innerText;
|
||||
|
||||
messageTextRef.current.innerHTML = Autolinker.link(text, {
|
||||
@ -42,7 +42,7 @@ const TextMessage: React.FC<TextMessageProps> = ({ message }) => {
|
||||
throw new Error("Unable to find text.");
|
||||
}
|
||||
|
||||
const colors = allColors[message.direction || "received"];
|
||||
const colors = allColors[message.direction || Direction.received];
|
||||
|
||||
return (
|
||||
<div
|
||||
|
Loading…
Reference in New Issue
Block a user