refactor: more TS code

This commit is contained in:
Tristan Yang
2022-07-28 23:25:47 +08:00
parent e26b6f0fcc
commit 875f74c410
17 changed files with 67 additions and 47 deletions
@@ -14,7 +14,6 @@ const AniFadeIn = keyframes`
`;
const StyledWrapper = styled.div`
/* todo */
transition: all 0.5s ease;
width: 100vw;
height: 100vh;
@@ -129,7 +128,6 @@ const ImagePreviewModal: FC<Props> = ({ download = true, data, closeModal }) =>
download={name}
type={type}
href={downloadLink || originUrl}
// target="_blank"
rel="noreferrer"
>
Download original
+1 -1
View File
@@ -166,7 +166,7 @@ const ManageMembers: FC<Props> = ({ cid }) => {
if (!currUser) return null;
const { name, email, is_admin } = currUser;
const owner = channel && channel.owner == uid;
const switchRoleVisible = loginUser.is_admin && loginUser.uid !== uid;
const switchRoleVisible = loginUser?.is_admin && loginUser.uid !== uid;
const dotsVisible = email || loginUser?.is_admin;
const canRemove = loginUser?.is_admin && loginUser?.uid != uid;
const canRemoveFromChannel =
+3 -6
View File
@@ -1,6 +1,7 @@
import { useEffect, useState, useRef, FC } from "react";
import "prismjs/themes/prism.css";
import "@toast-ui/editor-plugin-code-syntax-highlight/dist/toastui-editor-plugin-code-syntax-highlight.css";
//@ts-ignore
import codeSyntaxHighlight from "@toast-ui/editor-plugin-code-syntax-highlight/dist/toastui-editor-plugin-code-syntax-highlight-all.js";
import { Viewer } from "@toast-ui/react-editor";
@@ -22,7 +23,7 @@ interface IProps {
content: string;
}
const MarkdownRender: FC<IProps> = ({ content }) => {
const mdContainer = useRef<HTMLDivElement>();
const mdContainer = useRef<HTMLDivElement | null>(null);
const [previewImage, setPreviewImage] = useState<PreviewImageData | null>(null);
useEffect(() => {
@@ -61,11 +62,7 @@ const MarkdownRender: FC<IProps> = ({ content }) => {
<ImagePreviewModal download={false} data={previewImage} closeModal={closePreviewModal} />
)}
<Styled ref={mdContainer}>
<Viewer
initialValue={content}
// eslint-disable-next-line no-undef
plugins={[codeSyntaxHighlight]}
></Viewer>
<Viewer initialValue={content} plugins={[codeSyntaxHighlight]}></Viewer>
</Styled>
</>
);
+1 -1
View File
@@ -23,7 +23,7 @@ interface IProps {
context?: "user" | "channel";
read?: boolean;
mid: number;
updateReadIndex: (any) => void;
updateReadIndex: (param: any) => void;
}
const Message: FC<IProps> = ({
readOnly = false,