refactor: agora settings and functions

This commit is contained in:
Tristan Yang
2023-04-23 11:14:31 +08:00
parent 9f0b419f43
commit 9dc6bcd483
7 changed files with 53 additions and 46 deletions
+4 -2
View File
@@ -19,6 +19,7 @@ import Members from "./Members";
import VoiceChat from "../VoiceChat";
import { updateChannelVisibleAside } from "../../../app/slices/footprint";
import Dashboard from "../VoiceChat/Dashboard";
import ServerVersionChecker from "../../../common/component/ServerVersionChecker";
type Props = {
cid?: number;
dropFiles?: File[];
@@ -90,8 +91,9 @@ function ChannelChat({ cid = 0, dropFiles = [] }: Props) {
</li>
</Tippy>
</Tooltip>
{/* 音频 暂时只有admin有入口 */}
<VoiceChat context={`channel`} id={cid} />
<ServerVersionChecker version="0.3.5" empty={true}>
<VoiceChat context={`channel`} id={cid} />
</ServerVersionChecker>
<Tooltip tip={t("fav")} placement="left">
<Tippy
placement="left-start"
+3 -4
View File
@@ -8,7 +8,7 @@ import { useAppSelector } from '../../../app/store';
import IconHeadphone from '../../../assets/icons/headphone.svg';
import Tooltip from '../../../common/component/Tooltip';
import { useVoice } from '../../../common/component/Voice';
import { useGetAgoraConfigQuery } from '../../../app/services/server';
import { useGetAgoraStatusQuery } from '../../../app/services/server';
type Props = {
context?: "channel" | "dm"
@@ -26,7 +26,7 @@ const VoiceChat = ({ id, context = "channel" }: Props) => {
visibleAside: context == "channel" ? store.footprint.channelAsides[id] : null,
};
});
const { data: agoraConfig } = useGetAgoraConfigQuery(undefined, { skip: !loginUser?.is_admin });
const { data: enabled } = useGetAgoraStatusQuery();
const { t } = useTranslation("chat");
const toggleDashboard = () => {
if (context == "channel") {
@@ -50,8 +50,7 @@ const VoiceChat = ({ id, context = "channel" }: Props) => {
}));
}
};
// 只有admin才能看到入口,后续会改
if (!loginUser || !loginUser.is_admin || !agoraConfig?.enabled) return null;
if (!loginUser || !enabled) return null;
const visible = visibleAside == "voice";
const memberCount = voiceList.find((v) => v.context == context && v.id == id)?.memberCount ?? 0;
const badgeClass = `absolute -top-2 -right-2 w-4 h-4 rounded-full bg-primary-400 text-white `;