tabby/terminus-terminal/src/recoveryProvider.ts

29 lines
856 B
TypeScript
Raw Normal View History

2017-03-24 22:29:54 +00:00
import { Injectable } from '@angular/core'
2017-07-26 17:29:47 +00:00
import { TabRecoveryProvider, RecoveredTab } from 'terminus-core'
2017-04-11 00:22:48 +00:00
2017-04-16 18:38:42 +00:00
import { TerminalTabComponent } from './components/terminalTab.component'
import { SessionsService } from './services/sessions.service'
2017-03-24 22:29:54 +00:00
@Injectable()
2017-03-25 17:12:43 +00:00
export class RecoveryProvider extends TabRecoveryProvider {
2017-04-08 12:50:10 +00:00
constructor (
private sessions: SessionsService,
) {
2017-03-25 17:12:43 +00:00
super()
}
2017-03-24 22:29:54 +00:00
2017-07-26 17:29:47 +00:00
async recover (recoveryToken: any): Promise<RecoveredTab> {
2017-05-01 11:35:26 +00:00
if (recoveryToken.type === 'app:terminal') {
2017-05-14 11:45:14 +00:00
let sessionOptions = await this.sessions.recover(recoveryToken.recoveryId)
if (!sessionOptions) {
2017-07-26 17:59:05 +00:00
return null
2017-03-25 20:00:16 +00:00
}
2017-07-26 17:29:47 +00:00
return {
type: TerminalTabComponent,
options: { sessionOptions },
}
2017-03-24 22:29:54 +00:00
}
2017-07-26 17:29:47 +00:00
return null
2017-03-24 22:29:54 +00:00
}
}