Skip to content

Commit

Permalink
fix: bug when there are iframes
Browse files Browse the repository at this point in the history
  • Loading branch information
stepan662 committed Apr 17, 2024
1 parent 587c41d commit 7ec5dfc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
2 changes: 0 additions & 2 deletions src/content/contentScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ messages.startRuntimeListening();
messages.listenRuntime('DETECT_TOLGEE', async () => {
if (configuration) {
messages.sendToPlugin('TOLGEE_CONFIG_LOADED', configuration);
} else {
messages.sendToPlugin('TOLGEE_CONFIG_NOT_LOADED');
}
});

Expand Down
21 changes: 16 additions & 5 deletions src/popup/useDetectorForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,22 @@ export const useDetectorForm = () => {
});
}, []);

// timeout when Tolgee is not detected
useEffect(() => {
if (!state.libConfig) {
const timer = setTimeout(
() =>
dispatch({
type: 'CHANGE_LIB_CONFIG',
payload: { frameId: null, libData: null },
}),
300
);
return () => clearTimeout(timer);
}
return undefined;
}, [state.libConfig]);

// after tolgee config is loaded
// get applied values and stored values
const onLibConfigChange = async () => {
Expand Down Expand Up @@ -199,11 +215,6 @@ export const useDetectorForm = () => {
type: 'CHANGE_LIB_CONFIG',
payload: { libData: data, frameId: frameId || null },
});
} else if (type === 'TOLGEE_CONFIG_NOT_LOADED') {
dispatch({
type: 'CHANGE_LIB_CONFIG',
payload: { libData: null, frameId: null },
});
}
};
chrome.runtime.onMessage.addListener(listener);
Expand Down

0 comments on commit 7ec5dfc

Please sign in to comment.