Skip to content

Commit

Permalink
avoid debouncing iframe messages
Browse files Browse the repository at this point in the history
  • Loading branch information
MCarlomagno committed Dec 12, 2024
1 parent ff80200 commit a1890a9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
15 changes: 4 additions & 11 deletions packages/ui/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,9 @@
import { injectHyperlinks } from './utils/inject-hyperlinks';
import { InitialOptions } from './initial-options';
import { postMessageToIframe } from './post-message';
import { debouncer } from './utils/helpers';
const dispatch = createEventDispatcher();
// listens to contract changes and posts them to the defender deploy iframe.
// we debounce the call to avoid sending too many messages while the user is editing.
const debouncedPostMessage = debouncer((contract) => {
postMessageToIframe('defender-deploy', {
kind: 'oz-wizard-defender-deploy',
sources: getSolcSources(contract)
});
}, 600);
export let initialTab: string | undefined = 'ERC20';
export let tab: Kind = sanitizeKind(initialTab);
Expand Down Expand Up @@ -103,7 +93,10 @@
$: code = printContract(contract);
$: highlightedCode = injectHyperlinks(hljs.highlight('solidity', code).value);
$: if (contract || showDeployModal) debouncedPostMessage(contract);
$: if (showDeployModal) postMessageToIframe('defender-deploy', {
kind: 'oz-wizard-defender-deploy',
sources: getSolcSources(contract)
});;
const getSolcSources = (contract: Contract) => {
const sources = getImports(contract);
Expand Down
7 changes: 0 additions & 7 deletions packages/ui/src/utils/helpers.ts

This file was deleted.

0 comments on commit a1890a9

Please sign in to comment.