fix: 调用不存在接口导致404
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "vocechat-web",
|
"name": "vocechat-web",
|
||||||
"version": "0.9.52",
|
"version": "0.9.53",
|
||||||
"homepage": "https://voce.chat",
|
"homepage": "https://voce.chat",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@metamask/onboarding": "^1.0.1",
|
"@metamask/onboarding": "^1.0.1",
|
||||||
|
|||||||
@@ -1,22 +1,35 @@
|
|||||||
import { useState } from "react";
|
import { useState, useMemo } from "react";
|
||||||
import toast from "react-hot-toast";
|
import toast from "react-hot-toast";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { shallowEqual } from "react-redux";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
useGetEnabledChannelTypesQuery,
|
useGetEnabledChannelTypesQuery,
|
||||||
useToggleChannelTypeMutation,
|
useToggleChannelTypeMutation,
|
||||||
useDeleteChannelTypeMutation,
|
useDeleteChannelTypeMutation,
|
||||||
} from "@/app/services/notification";
|
} from "@/app/services/notification";
|
||||||
|
import { useAppSelector } from "@/app/store";
|
||||||
import { ConfigTip } from "@/components/ConfigTip";
|
import { ConfigTip } from "@/components/ConfigTip";
|
||||||
import Button from "@/components/styled/Button";
|
import Button from "@/components/styled/Button";
|
||||||
import Toggle from "@/components/styled/Toggle";
|
import Toggle from "@/components/styled/Toggle";
|
||||||
import { EnabledChannelType, ChannelType } from "@/types/notification";
|
import { EnabledChannelType, ChannelType } from "@/types/notification";
|
||||||
import { channelSchemas } from "./channelSchemas";
|
import { channelSchemas } from "./channelSchemas";
|
||||||
import ServerVersionChecker from "@/components/ServerVersionChecker";
|
import ServerVersionChecker from "@/components/ServerVersionChecker";
|
||||||
|
import { compareVersion } from "@/utils";
|
||||||
|
|
||||||
export default function AdminNotificationChannels() {
|
export default function AdminNotificationChannels() {
|
||||||
const { t } = useTranslation("setting", { keyPrefix: "admin_notification_channels" });
|
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 [toggleChannelType] = useToggleChannelTypeMutation();
|
||||||
const [deleteChannelType] = useDeleteChannelTypeMutation();
|
const [deleteChannelType] = useDeleteChannelTypeMutation();
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ import Toggle from "@/components/styled/Toggle";
|
|||||||
import { UserNotificationChannel, ChannelType, CreateUserChannelDTO } from "@/types/notification";
|
import { UserNotificationChannel, ChannelType, CreateUserChannelDTO } from "@/types/notification";
|
||||||
import { getChannelSchema } from "./AdminNotificationChannels/channelSchemas";
|
import { getChannelSchema } from "./AdminNotificationChannels/channelSchemas";
|
||||||
import ServerVersionChecker from "@/components/ServerVersionChecker";
|
import ServerVersionChecker from "@/components/ServerVersionChecker";
|
||||||
|
import { compareVersion } from "@/utils";
|
||||||
|
import { useMemo } from "react";
|
||||||
|
|
||||||
export default function NotificationSettings() {
|
export default function NotificationSettings() {
|
||||||
const { t } = useTranslation("setting", { keyPrefix: "notification" });
|
const { t } = useTranslation("setting", { keyPrefix: "notification" });
|
||||||
@@ -30,9 +32,19 @@ export default function NotificationSettings() {
|
|||||||
const [creatingType, setCreatingType] = useState<ChannelType | null>(null);
|
const [creatingType, setCreatingType] = useState<ChannelType | null>(null);
|
||||||
const [formData, setFormData] = useState<Partial<CreateUserChannelDTO>>({});
|
const [formData, setFormData] = useState<Partial<CreateUserChannelDTO>>({});
|
||||||
|
|
||||||
// Fetch data
|
// Check version first
|
||||||
const { data: availableTypes = [], isLoading: typesLoading } = useGetAvailableChannelTypesQuery();
|
const currentVersion = useAppSelector((store) => store.server.version, shallowEqual);
|
||||||
const { data: userChannels = [], isLoading: channelsLoading } = useGetUserChannelsQuery();
|
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);
|
const channels = useAppSelector((store) => Object.values(store.channels.byId), shallowEqual);
|
||||||
|
|
||||||
// Mutations
|
// Mutations
|
||||||
|
|||||||
Reference in New Issue
Block a user