1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-03-28 18:04:19 -04:00

Compare commits

..

1 Commits

Author SHA1 Message Date
Mark McDowall
3c087f0a80 Prevent duplicating providers when adding a new provider 2026-03-28 14:10:11 -07:00

View File

@@ -122,13 +122,17 @@ export const useSaveProviderSettings = <T extends ModelBase>(
},
onSuccess: (updatedSettings: T) => {
queryClient.setQueryData<T[]>([path], (oldData = []) => {
if (id) {
return oldData.map((item) =>
item.id === updatedSettings.id ? updatedSettings : item
);
const existingIndex = oldData.findIndex(
(item) => item.id === updatedSettings.id
);
if (existingIndex === -1) {
return [...oldData, updatedSettings];
}
return [...oldData, updatedSettings];
return oldData.map((item) =>
item.id === updatedSettings.id ? updatedSettings : item
);
});
onSuccess?.(updatedSettings);
},