From 759e231406ff393eee8fa9b15d7a2ee7af98ea1c Mon Sep 17 00:00:00 2001 From: haorwen Date: Sun, 18 Jan 2026 23:01:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B0=83=E7=94=A8=E4=B8=8D=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E6=8E=A5=E5=8F=A3=E5=AF=BC=E8=87=B4404?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- .../AdminNotificationChannels/index.tsx | 17 +++++++++++++++-- src/routes/setting/NotificationSettings.tsx | 18 +++++++++++++++--- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 7300697c..3ecf520a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vocechat-web", - "version": "0.9.52", + "version": "0.9.53", "homepage": "https://voce.chat", "dependencies": { "@metamask/onboarding": "^1.0.1", diff --git a/src/routes/setting/AdminNotificationChannels/index.tsx b/src/routes/setting/AdminNotificationChannels/index.tsx index 879fdeed..866df328 100644 --- a/src/routes/setting/AdminNotificationChannels/index.tsx +++ b/src/routes/setting/AdminNotificationChannels/index.tsx @@ -1,22 +1,35 @@ -import { useState } from "react"; +import { useState, useMemo } from "react"; import toast from "react-hot-toast"; import { useTranslation } from "react-i18next"; +import { shallowEqual } from "react-redux"; import { useGetEnabledChannelTypesQuery, useToggleChannelTypeMutation, useDeleteChannelTypeMutation, } from "@/app/services/notification"; +import { useAppSelector } from "@/app/store"; import { ConfigTip } from "@/components/ConfigTip"; import Button from "@/components/styled/Button"; import Toggle from "@/components/styled/Toggle"; import { EnabledChannelType, ChannelType } from "@/types/notification"; import { channelSchemas } from "./channelSchemas"; import ServerVersionChecker from "@/components/ServerVersionChecker"; +import { compareVersion } from "@/utils"; export default function AdminNotificationChannels() { const { t } = useTranslation("setting", { keyPrefix: "admin_notification_channels" }); - const { data: channelTypes = [], isLoading } = useGetEnabledChannelTypesQuery(); + + // Check version first + const currentVersion = useAppSelector((store) => store.server.version, shallowEqual); + const isVersionSupported = useMemo(() => { + return currentVersion && compareVersion(currentVersion, "0.5.11") >= 0; + }, [currentVersion]); + + // Fetch data only if version is supported + const { data: channelTypes = [], isLoading } = useGetEnabledChannelTypesQuery(undefined, { + skip: !isVersionSupported, + }); const [toggleChannelType] = useToggleChannelTypeMutation(); const [deleteChannelType] = useDeleteChannelTypeMutation(); diff --git a/src/routes/setting/NotificationSettings.tsx b/src/routes/setting/NotificationSettings.tsx index 6b520586..8b04b726 100644 --- a/src/routes/setting/NotificationSettings.tsx +++ b/src/routes/setting/NotificationSettings.tsx @@ -23,6 +23,8 @@ import Toggle from "@/components/styled/Toggle"; import { UserNotificationChannel, ChannelType, CreateUserChannelDTO } from "@/types/notification"; import { getChannelSchema } from "./AdminNotificationChannels/channelSchemas"; import ServerVersionChecker from "@/components/ServerVersionChecker"; +import { compareVersion } from "@/utils"; +import { useMemo } from "react"; export default function NotificationSettings() { const { t } = useTranslation("setting", { keyPrefix: "notification" }); @@ -30,9 +32,19 @@ export default function NotificationSettings() { const [creatingType, setCreatingType] = useState(null); const [formData, setFormData] = useState>({}); - // Fetch data - const { data: availableTypes = [], isLoading: typesLoading } = useGetAvailableChannelTypesQuery(); - const { data: userChannels = [], isLoading: channelsLoading } = useGetUserChannelsQuery(); + // Check version first + const currentVersion = useAppSelector((store) => store.server.version, shallowEqual); + const isVersionSupported = useMemo(() => { + return currentVersion && compareVersion(currentVersion, "0.5.11") >= 0; + }, [currentVersion]); + + // Fetch data only if version is supported + const { data: availableTypes = [], isLoading: typesLoading } = useGetAvailableChannelTypesQuery(undefined, { + skip: !isVersionSupported, + }); + const { data: userChannels = [], isLoading: channelsLoading } = useGetUserChannelsQuery(undefined, { + skip: !isVersionSupported, + }); const channels = useAppSelector((store) => Object.values(store.channels.byId), shallowEqual); // Mutations