fix: prevent duplicate channel action toasts (#5015)

* fix: prevent duplicate channel action toasts

* fix: localize api error fallbacks
This commit is contained in:
yyhhyyyyyy
2026-05-26 10:20:54 +08:00
committed by GitHub
parent a64f26d1d2
commit ad224ecf5b
6 changed files with 182 additions and 81 deletions
@@ -135,6 +135,8 @@ export function MultiKeyManageDialog({
setEnabledCount(response.data.enabled_count || 0)
setManualDisabledCount(response.data.manual_disabled_count || 0)
setAutoDisabledCount(response.data.auto_disabled_count || 0)
} else {
toast.error(response.message || t('Failed to load key status'))
}
} catch (error: unknown) {
toast.error(
@@ -211,14 +211,22 @@ export function OllamaModelsDialog({
? Array.from(new Set(selected))
: Array.from(new Set([...existingModels, ...selected]))
const res = await updateChannel(currentRow.id, { models: next.join(',') })
if (res.success) {
toast.success(
mode === 'replace'
? t('Models updated successfully')
: t('Models appended successfully')
try {
const res = await updateChannel(currentRow.id, { models: next.join(',') })
if (res.success) {
toast.success(
mode === 'replace'
? t('Models updated successfully')
: t('Models appended successfully')
)
queryClient.invalidateQueries({ queryKey: channelsQueryKeys.lists() })
} else {
toast.error(res.message || t('Failed to update models'))
}
} catch (err: unknown) {
toast.error(
err instanceof Error ? err.message : t('Failed to update models')
)
queryClient.invalidateQueries({ queryKey: channelsQueryKeys.lists() })
}
}