From 516ee8204b45c351e9c3feb29530959283f226e6 Mon Sep 17 00:00:00 2001 From: Tristan Yang Date: Wed, 29 Jun 2022 22:03:04 +0800 Subject: [PATCH] feat: recover public channel --- src/common/component/AddEntriesMenu.tsx | 6 ++++-- src/common/component/ChannelModal/index.tsx | 17 +++++++++-------- src/routes/chat/DMChat/index.tsx | 8 ++++---- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/common/component/AddEntriesMenu.tsx b/src/common/component/AddEntriesMenu.tsx index c72dc106..27cdc158 100644 --- a/src/common/component/AddEntriesMenu.tsx +++ b/src/common/component/AddEntriesMenu.tsx @@ -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() { <> {/* temp remove public channel */} - {/* {currentUser?.is_admin && ( + {currentUser?.is_admin && (
  • New Channel
  • - )} */} + )}
  • New Private Channel diff --git a/src/common/component/ChannelModal/index.tsx b/src/common/component/ChannelModal/index.tsx index d6306bf7..d4243952 100644 --- a/src/common/component/ChannelModal/index.tsx +++ b/src/common/component/ChannelModal/index.tsx @@ -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 = ({ 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 = ({ personal = false, closeModal }) => { - {/*
    +
    Private Channel -
    */} +