fix: remove unused code

This commit is contained in:
fantasticit 2022-04-05 13:45:13 +08:00
parent a4923f7834
commit 56fa309285
2 changed files with 1 additions and 55 deletions

View File

@ -8,7 +8,7 @@ const suggestion = {
items: async ({ query }) => { items: async ({ query }) => {
const res = await getUsers(); const res = await getUsers();
const data = res.map((item) => item.name); const data = res.map((item) => item.name);
return data.filter((item) => item.toLowerCase().startsWith(query.toLowerCase())).slice(0, 5); return data.filter((item) => item.toLowerCase().startsWith(query.toLowerCase()));
}, },
render: () => { render: () => {

View File

@ -1,11 +1,7 @@
import React, { useState, useEffect, forwardRef, useImperativeHandle, useRef } from 'react'; import React, { useState, useEffect, forwardRef, useImperativeHandle, useRef } from 'react';
import { Modal, Typography } from '@douyinfe/semi-ui';
import { useRouter } from 'next/router';
import { Editor } from '@tiptap/core'; import { Editor } from '@tiptap/core';
import cls from 'classnames'; import cls from 'classnames';
import scrollIntoView from 'scroll-into-view-if-needed'; import scrollIntoView from 'scroll-into-view-if-needed';
import { useUser } from 'data/user';
import { useCollaborationDocument } from 'data/document';
import styles from './index.module.scss'; import styles from './index.module.scss';
interface IProps { interface IProps {
@ -14,64 +10,14 @@ interface IProps {
command: any; command: any;
} }
const { Title, Text } = Typography;
export const MentionList: React.FC<IProps> = forwardRef((props, ref) => { export const MentionList: React.FC<IProps> = forwardRef((props, ref) => {
const $container = useRef<HTMLDivElement>(); const $container = useRef<HTMLDivElement>();
const router = useRouter();
const { user: currentUser } = useUser();
const { users, addUser, updateUser } = useCollaborationDocument(router.query.documentId);
const [selectedIndex, setSelectedIndex] = useState(0); const [selectedIndex, setSelectedIndex] = useState(0);
const selectItem = (index) => { const selectItem = (index) => {
const userName = props.items[index]; const userName = props.items[index];
if (!userName) return; if (!userName) return;
props.command({ id: userName }); props.command({ id: userName });
// const currentUserAuth = users.find((user) => {
// return user.user.name === currentUser.name;
// });
// const isCurrentUserCreateUser = currentUserAuth.auth.createUserId === currentUser.id;
// const target = users.find((user) => {
// return user.user.name === userName;
// });
// if (isCurrentUserCreateUser) {
// if (!target) {
// Modal.confirm({
// title: <Title heading={5}>权限操作</Title>,
// content: <Text>当前用户尚未加入该文档,是否添加他?</Text>,
// onCancel: () => {},
// onOk: async () => {
// addUser(userName).then((res) => {
// console.log('用户已经添加', res);
// props.command({ id: userName });
// });
// },
// });
// } else {
// if (!target.auth.readable) {
// Modal.confirm({
// title: <Title heading={5}>权限操作</Title>,
// content: <Text>当前用户无法阅读该文档,是否添加阅读权限?</Text>,
// onCancel: () => {},
// onOk: async () => {
// updateUser({
// userName,
// readable: true,
// editable: target.auth.editable,
// }).then((res) => {
// props.command({ id: userName });
// });
// },
// });
// } else {
// props.command({ id: userName });
// }
// }
// } else {
// }
}; };
const upHandler = () => { const upHandler = () => {