close tabs on remixd disconnection

pull/5370/head
Aniket-Engg 3 years ago committed by Aniket
parent 0781ec7423
commit 2a8233e5fb
  1. 2
      apps/remix-ide/src/app/files/fileManager.ts
  2. 12
      apps/remix-ide/src/app/panels/tab-proxy.js
  3. 1
      apps/remix-ide/src/app/plugins/remixd-handle.tsx

@ -484,7 +484,7 @@ class FileManager extends Plugin {
this.emit('filesAllClosed')
this.events.emit('filesAllClosed')
for (const file in this.openedFiles) {
this.closeFile(file)
await this.closeFile(file)
}
}

@ -50,10 +50,18 @@ export class TabProxy extends Plugin {
this.on('fileManager', 'fileClosed', (name) => {
const workspace = this.fileManager.currentWorkspace()
if (this.fileManager.mode === 'browser') {
name = name.startsWith(workspace + '/') ? name : workspace + '/' + name
this.removeTab(name)
let tabIndex = this.loadedTabs.findIndex(tab => tab.name === name)
// If tab doesn't exist, check if tab is opened because of abrupt disconnection with remixd
if (tabIndex === -1) {
const nameArray = name.split('/')
nameArray.shift()
name = 'localhost' + '/' + nameArray.join('/')
tabIndex = this.loadedTabs.findIndex(tab => tab.name === name)
if(tabIndex !== -1) this.removeTab(name)
} else this.removeTab(name)
} else {
name = name.startsWith(this.fileManager.mode + '/') ? name : this.fileManager.mode + '/' + name
this.removeTab(name)

@ -76,7 +76,6 @@ export class RemixdHandle extends WebsocketPlugin {
const intervalId = setInterval(() => {
if (!this.socket || (this.socket && this.socket.readyState === 3)) { // 3 means connection closed
clearInterval(intervalId)
console.log(error)
const alert:AlertModal = {
id: 'connectionAlert',
message: 'Connection to remixd terminated. Please make sure remixd is still running in the background.'

Loading…
Cancel
Save