-
-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi user sync local storage #3254
base: main
Are you sure you want to change the base?
Conversation
|
|
Commit SHA:e4eb90ed650e35b29c78840b13ad4498239618fb Test coverage results 🧪
|
Commit SHA:e4eb90ed650e35b29c78840b13ad4498239618fb |
React.useEffect(() => { | ||
function handleTokenSync(event: MessageEvent) { | ||
if (event.data.pluginMessage?.type === 'sync_tokens') { | ||
console.log('Received token update:', event.data.pluginMessage.tokens); | ||
dispatch.tokenState.setTokenData({ values: event.data.pluginMessage.tokens }); | ||
} | ||
} | ||
|
||
window.addEventListener('message', handleTokenSync); | ||
|
||
return () => { | ||
window.removeEventListener('message', handleTokenSync); | ||
}; | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets not do this inside Tokens.tsx, but rather inside packages/tokens-studio-for-figma/src/app/components/Initiator.tsx
this is where we have all the plugin message listeners - thats where we can emit this
|
||
export async function sendDocumentChange(event: DocumentChangeEvent) { | ||
if (event.documentChanges.length === 1 && event.documentChanges[0].type === 'PROPERTY_CHANGE' && event.documentChanges[0].id === '0:0') { | ||
return; | ||
const relevantChanges = event.documentChanges.filter((change) => change.type === 'PROPERTY_CHANGE' && change.properties?.includes('pluginData')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you verify once if this only includes changes from another user? I want to make sure the changes you as a user make to not trigger this event
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, will check for any other filters that we can leverage
console.log('sharedTokens', sharedTokens?.global); | ||
postToUI({ | ||
type: MessageFromPluginTypes.SYNC_TOKENS, | ||
tokens: sharedTokens?.global, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whats the global
here? I think we should sync all sets, not just the global
set - i might be wrong here!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found the token data sent inside an object called global here, will check if its the set or in general its sent in that manner
Why does this PR exist?
Draft PR for Multi User sync(local storage)
What does this pull request do?
Testing this change
Additional Notes (if any)