Skip to content

fix multi user sync local storage#3265

Closed
six7 wants to merge 1 commit intomulti-user-sync-local-storagefrom
six7/fix-multi-user-sync-local-storage
Closed

fix multi user sync local storage#3265
six7 wants to merge 1 commit intomulti-user-sync-local-storagefrom
six7/fix-multi-user-sync-local-storage

Conversation

@six7
Copy link
Collaborator

@six7 six7 commented Feb 16, 2025

Key changes:

  • packages/tokens-studio-for-figma/src/figmaStorage/LastModifiedBy.ts: correctly reads and sets property on shared plugin space, not on client storage (this was the cause why it was always showing the current user)
  • packages/tokens-studio-for-figma/src/app/components/Initiator.tsx and other setActiveTheme related code: made sure to pass along a prop to not cause updateDocument to appear when its an external change
  • packages/tokens-studio-for-figma/src/app/store/models/settings.tsx: baseFontSize kept being called. This property is stored on client storage - there's no need to update document when that changes, fixed that.
  • packages/tokens-studio-for-figma/src/hooks/useChangedState.ts: fixed change state detection to not trigger if we're on local storage

@changeset-bot
Copy link

changeset-bot bot commented Feb 16, 2025

⚠️ No Changeset found

Latest commit: d9674eb

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

newActiveTheme: typeof pluginMessage.activeTheme === 'string'
? { [INTERNAL_THEMES_NO_GROUP]: pluginMessage.activeTheme }
: pluginMessage.activeTheme ?? {},
shouldUpdateDocument: !pluginMessage.isExternalChange, // if the change is external, we don't want to update the document as it would trigger a loop
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and other setActiveTheme related code: made sure to pass along a prop to not cause updateDocument to appear when its an external change

},
setBaseFontSize: (payload, rootState) => {
setUI(rootState.settings);
dispatch.tokenState.updateDocument({ shouldUpdateNodes: false, updateRemote: false });
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

baseFontSize kept being called. This property is stored on client storage - there's no need to update document when that changes, fixed that.


export const LastModifiedByProperty = new FigmaStorageProperty<string>(
FigmaStorageType.CLIENT_STORAGE,
FigmaStorageType.SHARED_PLUGIN_DATA,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correctly reads and sets property on shared plugin space, not on client storage (this was the cause why it was always showing the current user)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am still facing the same issue, even on shared_plugin_data
is this working for you?

}, [remoteData, tokens, themes, storageType]);

const hasChanges = useMemo(() => {
if (storageType.provider === StorageProviderType.LOCAL) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed change state detection to not trigger if we're on local storage

@github-actions
Copy link
Contributor

⤵️ 📦 ✨ The artifact was successfully created! Want to test it? Download it here 👀 🎁

@github-actions
Copy link
Contributor

Commit SHA:c3c187990fea89fb814b2fe8135870ca8f44cf3b

Test coverage results 🧪

Code coverage diff between base branch:multi-user-sync-local-storage and head branch: six7/fix-multi-user-sync-local-storage 
Status File % Stmts % Branch % Funcs % Lines
🔴 total 66.88 (-0.01) 57.76 (-0.02) 63.86 (-0.01) 67.25 (-0.01)
🔴 packages/tokens-studio-for-figma/src/app/components/BranchSelector.tsx 43.93 (0) 20 (-2.85) 15.38 (0) 44.61 (0)
🔴 packages/tokens-studio-for-figma/src/app/components/ConvertToDTCGModal.tsx 66.66 (0) 33.33 (-5.55) 33.33 (0) 70.58 (0)
🔴 packages/tokens-studio-for-figma/src/app/components/DirtyStateBadgeWrapper.tsx 100 (0) 50 (-50) 100 (0) 100 (0)
🔴 packages/tokens-studio-for-figma/src/app/store/updateSources.tsx 12.9 (0) 22.72 (-4.55) 25 (0) 13.79 (0)
🔴 packages/tokens-studio-for-figma/src/app/store/models/settings.tsx 75.55 (-0.53) 40 (0) 77.14 (0) 75.55 (-0.53)
🔴 packages/tokens-studio-for-figma/src/app/store/models/effects/tokenState/setActiveTheme.ts 66.66 (-33.34) 50 (-50) 100 (0) 66.66 (-33.34)
🔴 packages/tokens-studio-for-figma/src/figmaStorage/FigmaStorageProperty.ts 92.85 (0) 86.36 (-4.54) 80 (0) 95.83 (0)
🔴 packages/tokens-studio-for-figma/src/hooks/useChangedState.ts 85 (-15) 50 (0) 100 (0) 85 (-15)
packages/tokens-studio-for-figma/src/utils/compareLastSyncedState.ts 80 50 100 80

@github-actions
Copy link
Contributor

Commit SHA:c3c187990fea89fb814b2fe8135870ca8f44cf3b
Current PR reduces the test coverage percentage by 1 for some tests

@six7 six7 closed this Apr 7, 2025
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.

2 participants

Comments