mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-09-07 01:56:53 +00:00
fix: prevent duplicate channel action toasts (#5015)
* fix: prevent duplicate channel action toasts * fix: localize api error fallbacks
This commit is contained in:
@@ -19,9 +19,14 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
import { useRef, useState, useCallback } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { toast } from 'sonner'
|
||||
import { api } from '@/lib/api'
|
||||
import { api, type ApiRequestConfig } from '@/lib/api'
|
||||
import { normalizeModelList } from '../lib/upstream-update-utils'
|
||||
|
||||
const upstreamUpdateRequestConfig = {
|
||||
skipBusinessError: true,
|
||||
skipErrorHandler: true,
|
||||
} satisfies ApiRequestConfig
|
||||
|
||||
function getManualIgnoredModelCount(settings: unknown): number {
|
||||
let parsed: Record<string, unknown> | null = null
|
||||
if (settings && typeof settings === 'object')
|
||||
@@ -117,7 +122,7 @@ export function useChannelUpstreamUpdates(refresh: () => Promise<void>) {
|
||||
ignore_models: ignoreModels,
|
||||
remove_models: normalizeModelList(selectedRemove),
|
||||
},
|
||||
{ skipErrorHandler: true } as Record<string, unknown>
|
||||
upstreamUpdateRequestConfig
|
||||
)
|
||||
const { success, message, data } = res.data || {}
|
||||
if (!success) {
|
||||
@@ -162,7 +167,7 @@ export function useChannelUpstreamUpdates(refresh: () => Promise<void>) {
|
||||
const res = await api.post(
|
||||
'/api/channel/upstream_updates/apply_all',
|
||||
{},
|
||||
{ skipErrorHandler: true } as Record<string, unknown>
|
||||
upstreamUpdateRequestConfig
|
||||
)
|
||||
const { success, message, data } = res.data || {}
|
||||
if (!success) {
|
||||
@@ -206,7 +211,7 @@ export function useChannelUpstreamUpdates(refresh: () => Promise<void>) {
|
||||
const res = await api.post(
|
||||
'/api/channel/upstream_updates/detect',
|
||||
{ id: ch.id },
|
||||
{ skipErrorHandler: true } as Record<string, unknown>
|
||||
upstreamUpdateRequestConfig
|
||||
)
|
||||
const { success, message, data } = res.data || {}
|
||||
if (!success) {
|
||||
@@ -244,7 +249,7 @@ export function useChannelUpstreamUpdates(refresh: () => Promise<void>) {
|
||||
const res = await api.post(
|
||||
'/api/channel/upstream_updates/detect_all',
|
||||
{},
|
||||
{ skipErrorHandler: true } as Record<string, unknown>
|
||||
upstreamUpdateRequestConfig
|
||||
)
|
||||
const { success, message, data } = res.data || {}
|
||||
if (!success) {
|
||||
|
||||
Reference in New Issue
Block a user