Skip to content

Commit

Permalink
Merge pull request #224 from HunnySajid/fix/223
Browse files Browse the repository at this point in the history
fix: could not establish connection error
  • Loading branch information
HunnySajid authored Nov 13, 2024
2 parents 6ae062f + f6974d2 commit 1b8c663
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
4 changes: 4 additions & 0 deletions src/components/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export function Main(props: IMain): JSX.Element {
const [currentTabState, setCurrentTabState] = useState(TAB_STATE.NONE);

const fetchTabState = async () => {
try {
const tab = await getCurrentTab();
const { data } = await sendMessageTab(tab.id!, {
type: "tab",
Expand All @@ -51,6 +52,9 @@ export function Main(props: IMain): JSX.Element {
setActiveSidebar(SIDEBAR[2]);
}
}
} catch (error) {
console.log("Error fetching tab state", error);
}
};

useEffect(() => {
Expand Down
24 changes: 14 additions & 10 deletions src/pages/popup/Popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,20 @@ export default function Popup(): JSX.Element {
});
setIsConnected(!!data.isConnected);
if (data.isConnected) {
const tab = await getCurrentTab();
const { data } = await sendMessageTab(tab.id!, {
type: "tab",
subtype: "get-tab-state",
});
sendMessageTab(tab.id!, {
type: "tab",
subtype: "reload-state",
eventType: data?.tabState,
});
try {
const tab = await getCurrentTab();
const { data } = await sendMessageTab(tab.id!, {
type: "tab",
subtype: "get-tab-state",
});
sendMessageTab(tab.id!, {
type: "tab",
subtype: "reload-state",
eventType: data?.tabState,
});
} catch (error) {
console.log("Error in popup from sendMessageTab", error);
}
}
};

Expand Down

0 comments on commit 1b8c663

Please sign in to comment.