refactor: more TS code
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
// @ts-nocheck
|
||||
import { useEffect, useState, FC } from "react";
|
||||
import { NavLink, useNavigate, useMatch } from "react-router-dom";
|
||||
import { useDrop } from "react-dnd";
|
||||
@@ -20,7 +21,7 @@ interface IProps {
|
||||
uid: number;
|
||||
mid?: number;
|
||||
unreads: number;
|
||||
setFiles: () => void;
|
||||
setFiles: (files: File[]) => void;
|
||||
}
|
||||
const NavItem: FC<IProps> = ({ uid, mid = 0, unreads, setFiles }) => {
|
||||
const [previewMsg, setPreviewMsg] = useState<ArchiveMessage>();
|
||||
|
||||
@@ -9,7 +9,12 @@ interface Props {
|
||||
}
|
||||
|
||||
const DMList: FC<Props> = ({ uids, setDropFiles }) => {
|
||||
const { userMessage, messageData, readUsers, loginUid } = useAppSelector((store) => {
|
||||
const {
|
||||
userMessage,
|
||||
messageData,
|
||||
readUsers,
|
||||
loginUid = 0
|
||||
} = useAppSelector((store) => {
|
||||
return {
|
||||
loginUid: store.authData.user?.uid,
|
||||
readUsers: store.footprint.readUsers,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useState } from "react";
|
||||
import { FC, useState } from "react";
|
||||
import styled from "styled-components";
|
||||
import { useKey } from "rooks";
|
||||
import toast from "react-hot-toast";
|
||||
@@ -16,7 +16,6 @@ import { useAppDispatch, useAppSelector } from "../../../app/store";
|
||||
const Styled = styled.div`
|
||||
position: relative;
|
||||
padding: 16px;
|
||||
/* padding-bottom: 0; */
|
||||
display: flex;
|
||||
gap: 32px;
|
||||
align-items: center;
|
||||
@@ -41,8 +40,11 @@ const Styled = styled.div`
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
`;
|
||||
|
||||
export default function Operations({ context, id }) {
|
||||
type Props = {
|
||||
context: "user" | "channel";
|
||||
id: number;
|
||||
};
|
||||
const Operations: FC<Props> = ({ context, id }) => {
|
||||
const [deleteModalVisible, setDeleteModalVisible] = useState(false);
|
||||
const { canDelete } = useDeleteMessage();
|
||||
const { addFavorite } = useFavMessage({});
|
||||
@@ -103,4 +105,5 @@ export default function Operations({ context, id }) {
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
};
|
||||
export default Operations;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @ts-nocheck
|
||||
import { useState, useEffect, FC } from "react";
|
||||
import dayjs from "dayjs";
|
||||
import { useDrop } from "react-dnd";
|
||||
|
||||
@@ -137,13 +137,14 @@ const MessageWrapper = ({ selectMode = false, context, id, mid, children, ...res
|
||||
<StyledWrapper className={selectMode ? "select" : ""} {...rest}>
|
||||
<Checkbox className="check" checked={selected} />
|
||||
{children}
|
||||
{selectMode && <div className="overlay" onClick={selectMode ? toggleSelect : null}></div>}
|
||||
{selectMode && (
|
||||
<div className="overlay" onClick={selectMode ? toggleSelect : undefined}></div>
|
||||
)}
|
||||
</StyledWrapper>
|
||||
);
|
||||
};
|
||||
type Params = {
|
||||
selectMode: boolean;
|
||||
isFirst: boolean;
|
||||
read: boolean;
|
||||
updateReadIndex: (param: any) => void;
|
||||
prev: object | null;
|
||||
@@ -153,14 +154,13 @@ type Params = {
|
||||
};
|
||||
export const renderMessageFragment = ({
|
||||
selectMode = false,
|
||||
isFirst = false,
|
||||
read = true,
|
||||
updateReadIndex,
|
||||
prev = null,
|
||||
curr = null,
|
||||
contextId = 0,
|
||||
context = "user"
|
||||
}: Partial<Params>) => {
|
||||
}: Params) => {
|
||||
if (!curr) return null;
|
||||
let { created_at, mid } = curr;
|
||||
const local_id = curr.properties?.local_id;
|
||||
@@ -189,7 +189,6 @@ export const renderMessageFragment = ({
|
||||
>
|
||||
<Message
|
||||
readOnly={selectMode}
|
||||
isFirst={isFirst}
|
||||
updateReadIndex={updateReadIndex}
|
||||
read={read}
|
||||
context={context}
|
||||
|
||||
Reference in New Issue
Block a user