Avoid auto selecting instance in iFrame

Avoid auto selecting the outter frame instance when redux exist in
iFrame embedded on the page.
This commit is contained in:
Alexandre Côté 2024-06-21 16:32:22 -04:00
parent 65126657cb
commit d03eb599a8
No known key found for this signature in database
GPG Key ID: 0BF7EB13314D09C9
2 changed files with 15 additions and 1 deletions

View File

@ -0,0 +1,5 @@
---
'remotedev-redux-devtools-extension': patch
---
Avoid auto-selecting instance with iFrames

View File

@ -13,7 +13,16 @@ function selectInstance(
) { ) {
const instances = store.getState().instances; const instances = store.getState().instances;
if (instances.current === 'default') return; if (instances.current === 'default') return;
const connections = instances.connections[tabId];
const connections = Object.entries(instances.connections).reduce<
(string | number)[]
>((acc, [key, connections]) => {
if (key.startsWith(String(tabId))) {
return [...acc, ...connections];
}
return acc;
}, []);
if (connections && connections.length === 1) { if (connections && connections.length === 1) {
next({ type: SELECT_INSTANCE, selected: connections[0] }); next({ type: SELECT_INSTANCE, selected: connections[0] });
} }