Conversation
|
|
|
|
Commit SHA:7e047e023a1da56f72177ca6b2b7649fc471082f Test coverage results 🧪
|
|
Commit SHA:7e047e023a1da56f72177ca6b2b7649fc471082f |
| 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.
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.
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.
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.
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.
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)