refactoring Eugeny/tabby#8589 (shouldTabBeDestroyedOnSessionClose)

This commit is contained in:
Clem
2023-06-16 16:23:30 +02:00
parent 7f2340e701
commit 27c8b920ea
2 changed files with 6 additions and 9 deletions

View File

@@ -789,7 +789,7 @@ export class BaseTerminalTabComponent<P extends BaseTerminalProfile> extends Bas
* Method called when session is closed. * Method called when session is closed.
*/ */
protected onSessionClosed (destroyOnSessionClose = false): void { protected onSessionClosed (destroyOnSessionClose = false): void {
if (destroyOnSessionClose || this.doesTabShouldBeDestroyedOnSessionClosed()) { if (destroyOnSessionClose || this.shouldTabBeDestroyedOnSessionClose()) {
this.destroy() this.destroy()
} }
} }
@@ -797,12 +797,9 @@ export class BaseTerminalTabComponent<P extends BaseTerminalProfile> extends Bas
/** /**
* Return true if tab should be destroyed on session closed. * Return true if tab should be destroyed on session closed.
*/ */
protected doesTabShouldBeDestroyedOnSessionClosed (): boolean { protected shouldTabBeDestroyedOnSessionClose (): boolean {
const behavior = this.profile.behaviorOnSessionEnd const behavior = this.profile.behaviorOnSessionEnd
if (behavior === 'close' || behavior === 'auto' && this.isSessionExplicitlyTerminated()) { return behavior === 'close' || behavior === 'auto' && this.isSessionExplicitlyTerminated()
return true
}
return false
} }
/** /**

View File

@@ -68,7 +68,7 @@ export abstract class ConnectableTerminalTabComponent<P extends BaseTerminalProf
if (this.frontend) { if (this.frontend) {
if (this.profile.behaviorOnSessionEnd === 'reconnect' && !this.isDisconnectedByHand) { if (this.profile.behaviorOnSessionEnd === 'reconnect' && !this.isDisconnectedByHand) {
this.reconnect() this.reconnect()
} else if (this.profile.behaviorOnSessionEnd === 'keep' || !this.doesTabShouldBeDestroyedOnSessionClosed()) { } else if (this.profile.behaviorOnSessionEnd === 'keep' || !this.shouldTabBeDestroyedOnSessionClose()) {
this.offerReconnection() this.offerReconnection()
} }
} }
@@ -93,11 +93,11 @@ export abstract class ConnectableTerminalTabComponent<P extends BaseTerminalProf
/** /**
* Return true if tab should be destroyed on session closed. * Return true if tab should be destroyed on session closed.
*/ */
protected doesTabShouldBeDestroyedOnSessionClosed (): boolean { protected shouldTabBeDestroyedOnSessionClose (): boolean {
if (this.isDisconnectedByHand) { if (this.isDisconnectedByHand) {
return false return false
} }
return super.doesTabShouldBeDestroyedOnSessionClosed() return super.shouldTabBeDestroyedOnSessionClose()
} }
async getRecoveryToken (options?: GetRecoveryTokenOptions): Promise<RecoveryToken> { async getRecoveryToken (options?: GetRecoveryTokenOptions): Promise<RecoveryToken> {