From 75a339cc83be3bdd28e85761e231cc7769169c31 Mon Sep 17 00:00:00 2001 From: MiMoHo <37556964+MiMoHo@users.noreply.github.com> Date: Sun, 12 Jul 2026 19:25:39 +0200 Subject: [PATCH 1/2] fix(settings): read social sync initial state as boolean Since babe45a5 the PageController provides allowSocialSync and enableSocialSync as booleans, but ContactsSettings.vue still compared them with the strings 'yes'/'no'. Both comparisons therefore always evaluated to true: the 'Update avatars from social media' switch always appeared enabled regardless of the stored setting. Also put the unused allowSocialSync state back to work by hiding the switch when the administrator has disabled social sync, matching the behaviour before the settings dialog refactorings. AdminSettings.vue is intentionally left unchanged: its initial state comes from lib/Settings/AdminSettings.php, which still provides the raw string app values, so the string comparison is correct there. Resolves #5561 Assisted-by: Claude:claude-fable-5 Signed-off-by: MiMoHo <37556964+MiMoHo@users.noreply.github.com> Signed-off-by: Hamza --- src/components/AdminSettings.vue | 2 +- src/components/AppNavigation/ContactsSettings.vue | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/AdminSettings.vue b/src/components/AdminSettings.vue index 0d79be5c7f..7829076113 100644 --- a/src/components/AdminSettings.vue +++ b/src/components/AdminSettings.vue @@ -26,7 +26,7 @@ export default { name: 'AdminSettings', data() { return { - allowSocialSync: loadState('contacts', 'allowSocialSync') === 'yes', + allowSocialSync: loadState('contacts', 'allowSocialSync', false), } }, diff --git a/src/components/AppNavigation/ContactsSettings.vue b/src/components/AppNavigation/ContactsSettings.vue index 5e2099613f..0dfb806375 100644 --- a/src/components/AppNavigation/ContactsSettings.vue +++ b/src/components/AppNavigation/ContactsSettings.vue @@ -12,7 +12,7 @@ - + Date: Thu, 16 Jul 2026 15:15:09 +0200 Subject: [PATCH 2/2] fix: unify `allowSocialSync` frontend type fix: unify `allowSocialSync` frontend type Signed-off-by: Hamza [skip ci] --- lib/AppInfo/Application.php | 4 -- lib/Settings/AdminSettings.php | 10 +---- src/components/AdminSettings.vue | 2 +- tests/unit/Settings/AdminSettingsTest.php | 50 +++++++++++++++++++++++ 4 files changed, 52 insertions(+), 14 deletions(-) create mode 100644 tests/unit/Settings/AdminSettingsTest.php diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index ac43828a3c..3ffea8610b 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -22,10 +22,6 @@ class Application extends App implements IBootstrap { public const APP_ID = 'contacts'; - public const AVAIL_SETTINGS = [ - 'allowSocialSync' => 'yes', - ]; - public function __construct() { parent::__construct(self::APP_ID); } diff --git a/lib/Settings/AdminSettings.php b/lib/Settings/AdminSettings.php index 0162b25c44..46af297800 100644 --- a/lib/Settings/AdminSettings.php +++ b/lib/Settings/AdminSettings.php @@ -8,25 +8,17 @@ namespace OCA\Contacts\Settings; use OCA\Contacts\AppInfo\Application; +use OCA\Contacts\Service\SocialApiService; use OCP\AppFramework\Http\TemplateResponse; use OCP\IConfig; use OCP\IInitialStateService; use OCP\Settings\ISettings; class AdminSettings implements ISettings { - protected $appName; - - /** - * Admin constructor. - * - * @param IConfig $config - * @param IL10N $l - */ public function __construct( private IConfig $config, private IInitialStateService $initialStateService, ) { - $this->appName = Application::APP_ID; } /** diff --git a/src/components/AdminSettings.vue b/src/components/AdminSettings.vue index 7829076113..255dbefe4d 100644 --- a/src/components/AdminSettings.vue +++ b/src/components/AdminSettings.vue @@ -26,7 +26,7 @@ export default { name: 'AdminSettings', data() { return { - allowSocialSync: loadState('contacts', 'allowSocialSync', false), + allowSocialSync: loadState('contacts', 'allowSocialSync', true), } }, diff --git a/tests/unit/Settings/AdminSettingsTest.php b/tests/unit/Settings/AdminSettingsTest.php new file mode 100644 index 0000000000..a3a994348f --- /dev/null +++ b/tests/unit/Settings/AdminSettingsTest.php @@ -0,0 +1,50 @@ +initialState = $this->createMock(IInitialState::class); + $this->socialApiService = $this->createMock(SocialApiService::class); + $this->settings = new AdminSettings($this->initialState, $this->socialApiService); + } + + public static function allowSocialSyncProvider(): array { + return [[true], [false]]; + } + + #[DataProvider('allowSocialSyncProvider')] + public function testGetFormProvidesBooleanInitialState(bool $allowed): void { + $this->socialApiService + ->method('syncAllowedByAdmin') + ->willReturn($allowed); + $this->initialState + ->expects($this->once()) + ->method('provideInitialState') + ->with('allowSocialSync', $allowed); + + $form = $this->settings->getForm(); + $this->assertInstanceOf(TemplateResponse::class, $form); + } +}