feat: recover public channel

This commit is contained in:
Tristan Yang
2022-06-29 22:03:04 +08:00
parent bdcc9d2c87
commit 516ee8204b
3 changed files with 17 additions and 14 deletions
+4 -2
View File
@@ -1,6 +1,7 @@
import { useState } from "react";
import styled from "styled-components";
import { hideAll } from "tippy.js";
import { useAppSelector } from "../../app/store";
import IconInvite from "../../assets/icons/add.person.svg";
import IconMention from "../../assets/icons/mention.svg";
import ChannelIcon from "./ChannelIcon";
@@ -41,6 +42,7 @@ const Styled = styled.ul`
}
`;
export default function AddEntriesMenu() {
const currentUser = useAppSelector((store) => store.authData.user);
const [isPrivate, setIsPrivate] = useState(false);
const [inviteModalVisible, setInviteModalVisible] = useState(false);
@@ -74,12 +76,12 @@ export default function AddEntriesMenu() {
<>
<Styled>
{/* temp remove public channel */}
{/* {currentUser?.is_admin && (
{currentUser?.is_admin && (
<li className="item" onClick={handleOpenChannelModal.bind(null, false)}>
<ChannelIcon className="icon" />
New Channel
</li>
)} */}
)}
<li className="item" onClick={handleOpenChannelModal.bind(null, true)}>
<ChannelIcon personal={true} className="icon" />
New Private Channel
+9 -8
View File
@@ -7,6 +7,7 @@ import ChannelIcon from "../ChannelIcon";
import Contact from "../Contact";
import StyledWrapper from "./styled";
import StyledCheckbox from "../styled/Checkbox";
import StyledToggle from "../../component/styled/Toggle";
import useFilteredUsers from "../../hook/useFilteredUsers";
import { useCreateChannelMutation } from "../../../app/services/channel";
import { useAppSelector } from "../../../app/store";
@@ -33,12 +34,12 @@ const ChannelModal: FC<Props> = ({ personal = false, closeModal }) => {
const [createChannel, { isSuccess, isError, isLoading, data: newChannelId }] =
useCreateChannelMutation();
// const handleToggle = () => {
// const { is_public } = data;
// setData((prev) => {
// return { ...prev, is_public: !is_public };
// });
// };
const handleToggle = () => {
const { is_public } = data;
setData((prev) => {
return { ...prev, is_public: !is_public };
});
};
const handleCreate = () => {
// todo: add field validation (maxLength, text format, trim)
if (!data.name) {
@@ -141,14 +142,14 @@ const ChannelModal: FC<Props> = ({ personal = false, closeModal }) => {
<ChannelIcon personal={!is_public} className="icon" />
</div>
</div>
{/* <div className="private">
<div className="private">
<span className="txt normal">Private Channel</span>
<StyledToggle
data-checked={!is_public}
data-disabled={!loginUser?.is_admin}
onClick={handleToggle}
/>
</div> */}
</div>
<div className="btns">
<Button onClick={closeModal} className="normal cancel">
Cancel
+4 -4
View File
@@ -5,7 +5,7 @@ import FavList from "../FavList";
import Tooltip from "../../../common/component/Tooltip";
import FavIcon from "../../../assets/icons/bookmark.svg";
// import searchIcon from "../../../assets/icons/search.svg?url";
import IconHeadphone from "../../../assets/icons/headphone.svg";
// import IconHeadphone from "../../../assets/icons/headphone.svg";
// import useChatScroll from "../../../common/hook/useChatScroll";
import { useReadMessageMutation } from "../../../app/services/message";
import Contact from "../../../common/component/Contact";
@@ -16,7 +16,7 @@ import { renderMessageFragment } from "../utils";
import useMessageFeed from "../../../common/hook/useMessageFeed";
import { useAppSelector } from "../../../app/store";
export default function DMChat({ uid = "", dropFiles = [] }) {
export default function DMChat({ uid = 0, dropFiles = [] }) {
const {
list: msgIds,
appends,
@@ -51,10 +51,10 @@ export default function DMChat({ uid = "", dropFiles = [] }) {
aside={
<>
<ul className="tools">
<li className="tool">
{/*<li className="tool">
<IconHeadphone />
</li>
{/* <li className="tool">
<li className="tool">
<img src={alertIcon} alt="opt icon" />
</li> */}
<Tooltip tip="Saved Items" placement="left">