mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-30 10:42:09 +08:00
fix(profiles): restore single switch error toast and refetch after busy
patchProfiles entered the mutate funnel without errorNotice:false, so a failed switch toasted twice. On busy the cached current profile was left untouched, so a discarded switch draft could poison later clicks on the target profile. Refetch on every non-valid outcome.
This commit is contained in:
@@ -51,6 +51,7 @@ export const useProfiles = () => {
|
||||
try {
|
||||
const result = await mutate(() => patchProfilesConfig(value), {
|
||||
id: 'patch-profiles-config',
|
||||
errorNotice: false,
|
||||
onFulfilled: (outcome) => {
|
||||
if (outcome.status === 'valid') {
|
||||
void setCacheData<IProfilesConfig>(profilesQueryKey, (current) =>
|
||||
@@ -60,12 +61,8 @@ export const useProfiles = () => {
|
||||
},
|
||||
})
|
||||
|
||||
if (!result.ok) {
|
||||
// Backend Busy keeps local state untouched, as before.
|
||||
return result.value
|
||||
}
|
||||
const outcome = result.value
|
||||
if (outcome.status !== 'valid' && outcome.status !== 'busy') {
|
||||
if (outcome.status !== 'valid') {
|
||||
await mutateProfiles()
|
||||
}
|
||||
return outcome
|
||||
|
||||
Reference in New Issue
Block a user