Skip to content

fix(settings): read social sync initial state as boolean#5566

Open
MiMoHo wants to merge 1 commit into
nextcloud:mainfrom
MiMoHo:fix/social-sync-initial-state
Open

fix(settings): read social sync initial state as boolean#5566
MiMoHo wants to merge 1 commit into
nextcloud:mainfrom
MiMoHo:fix/social-sync-initial-state

Conversation

@MiMoHo

@MiMoHo MiMoHo commented Jul 12, 2026

Copy link
Copy Markdown

Summary

Since babe45a the PageController provides allowSocialSync and enableSocialSync as booleans (SocialApiService::syncAllowedByAdmin() / backgroundSyncEnabled() return bool), but ContactsSettings.vue still compared the initial state with the strings 'yes'/'no':

allowSocialSync: loadState('contacts', 'allowSocialSync') !== 'no',
enableSocialSync: loadState('contacts', 'enableSocialSync') !== 'no',

A boolean is never === 'no', so both flags were always true: the Update avatars from social media switch always appeared enabled, regardless of the stored setting.

Changes

  • Read both states as booleans, with fallbacks matching the server defaults (allowSocialSync: true, enableSocialSync: false).
  • allowSocialSync was loaded into data() but no longer used anywhere since the settings dialog refactorings (it used to guard the switch, see 973c288 / 7310a2a). Put it back to work: the switch is now hidden when the administrator has disabled social sync, instead of showing users a toggle that has no effect (backgroundSyncEnabled() is false whenever syncAllowedByAdmin() is).

Note on AdminSettings.vue

The issue also suggests changing AdminSettings.vue, but that would break it: its initial state comes from lib/Settings/AdminSettings.php, which provides the raw string app values ('yes'/'no') from Application::AVAIL_SETTINGS, so the === 'yes' comparison is correct there. Left unchanged on purpose.

Checklist

  • Jest suite passes, npm run lint clean for the touched file (0 errors), production build succeeds
  • Manually traced both initial-state providers (PageController → booleans, Settings/AdminSettings.php → strings)

Resolve #5561

🤖 Generated with Claude Code

Since babe45a 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 nextcloud#5561

Assisted-by: Claude:claude-fable-5
Signed-off-by: MiMoHo <37556964+MiMoHo@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong comparisons

1 participant