chore(extension): show error when connection is rejected due to inact… (#836)

…ivity
This commit is contained in:
Yury Semikhatsky
2025-08-05 15:08:57 -07:00
committed by GitHub
parent 20e1144c3b
commit 5dbb1504ba
2 changed files with 10 additions and 1 deletions

View File

@@ -166,8 +166,10 @@ class TabShareExtension {
if (!pending.timerId) {
pending.timerId = setTimeout(() => {
const existed = this._pendingTabSelection.delete(tabId);
if (existed)
if (existed) {
pending.connection.close('Tab has been inactive for 5 seconds');
chrome.tabs.sendMessage(tabId, { type: 'connectionTimeout' });
}
}, 5000);
return;
}

View File

@@ -121,6 +121,13 @@ const ConnectApp: React.FC = () => {
setStatus({ type: 'error', message: 'Connection rejected. This tab can be closed.' });
}, []);
useEffect(() => {
chrome.runtime.onMessage.addListener(message => {
if (message.type === 'connectionTimeout')
handleReject();
});
}, []);
return (
<div className='app-container'>
<div className='content-wrapper'>