]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(AdminSettings/AI): show pref list of only the enabled translation providers 46949/head
authorAnupam Kumar <kyteinsky@gmail.com>
Thu, 1 Aug 2024 07:40:40 +0000 (13:10 +0530)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Thu, 1 Aug 2024 10:57:07 +0000 (10:57 +0000)
Signed-off-by: Anupam Kumar <kyteinsky@gmail.com>
apps/settings/lib/Settings/Admin/ArtificialIntelligence.php

index 41b9e837c7e1ca732779101fe9a6839b1cf93ec6..ec266f70987848ef18e02b35c95f8932ba4986ae 100644 (file)
@@ -138,7 +138,12 @@ class ArtificialIntelligence implements IDelegatedSettings {
                                                $value = array_merge($defaultValue, $value);
                                                break;
                                        case 'ai.translation_provider_preferences':
-                                               $value += array_diff($defaultValue, $value); // Add entries from $defaultValue that are not in $value to the end of $value
+                                               // Only show entries from $value (saved pref list) that are in $defaultValue (enabled providers)
+                                               // and add all providers that are enabled but not in the pref list
+                                               if (!is_array($defaultValue)) {
+                                                       break;
+                                               }
+                                               $value = array_values(array_unique(array_merge(array_intersect($value, $defaultValue), $defaultValue), SORT_STRING));
                                                break;
                                        default:
                                                break;