Merge pull request #413 from Hexastack/fix/refactor-hard-coded-values
Some checks are pending
Build and Push Docker Images / paths-filter (push) Waiting to run
Build and Push Docker Images / build-and-push (push) Blocked by required conditions

refactor: hard coded direction values with enum
This commit is contained in:
Med Marrouchi 2024-12-05 17:11:01 +01:00 committed by GitHub
commit 271d52f4fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 9 deletions

View File

@ -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");

View File

@ -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

View File

@ -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

View File

@ -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