mirror of
https://github.com/Eugeny/tabby.git
synced 2025-01-05 09:34:56 +03:00
parent
eb0d8615e1
commit
6cb5505ded
@ -133,9 +133,7 @@ export class AppRootComponent {
|
|||||||
})
|
})
|
||||||
|
|
||||||
this.hostApp.windowCloseRequest$.subscribe(async () => {
|
this.hostApp.windowCloseRequest$.subscribe(async () => {
|
||||||
if (await this.app.closeAllTabs()) {
|
this.app.closeWindow()
|
||||||
this.hostApp.closeWindow()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if (window['safeModeReason']) {
|
if (window['safeModeReason']) {
|
||||||
|
@ -13,8 +13,6 @@ export class WindowControlsComponent {
|
|||||||
constructor (public hostApp: HostAppService, public app: AppService) { }
|
constructor (public hostApp: HostAppService, public app: AppService) { }
|
||||||
|
|
||||||
async closeWindow () {
|
async closeWindow () {
|
||||||
if (await this.app.closeAllTabs()) {
|
this.app.closeWindow()
|
||||||
this.hostApp.closeWindow()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,32 +74,30 @@ export class AppService {
|
|||||||
private tabsService: TabsService,
|
private tabsService: TabsService,
|
||||||
private ngbModal: NgbModal,
|
private ngbModal: NgbModal,
|
||||||
) {
|
) {
|
||||||
if (hostApp.getWindow().id === 1) {
|
|
||||||
if (config.store.terminal.recoverTabs) {
|
|
||||||
this.tabRecovery.recoverTabs().then(tabs => {
|
|
||||||
for (const tab of tabs) {
|
|
||||||
this.openNewTabRaw(tab.type, tab.options)
|
|
||||||
}
|
|
||||||
this.startTabStorage()
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
/** Continue to store the tabs even if the setting is currently off */
|
|
||||||
this.startTabStorage()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
hostApp.windowFocused$.subscribe(() => {
|
|
||||||
this._activeTab?.emitFocused()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
startTabStorage (): void {
|
|
||||||
this.tabsChanged$.subscribe(() => {
|
this.tabsChanged$.subscribe(() => {
|
||||||
this.tabRecovery.saveTabs(this.tabs)
|
this.tabRecovery.saveTabs(this.tabs)
|
||||||
})
|
})
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
this.tabRecovery.saveTabs(this.tabs)
|
this.tabRecovery.saveTabs(this.tabs)
|
||||||
}, 30000)
|
}, 30000)
|
||||||
|
|
||||||
|
if (hostApp.getWindow().id === 1) {
|
||||||
|
if (config.store.terminal.recoverTabs) {
|
||||||
|
this.tabRecovery.recoverTabs().then(tabs => {
|
||||||
|
for (const tab of tabs) {
|
||||||
|
this.openNewTabRaw(tab.type, tab.options)
|
||||||
|
}
|
||||||
|
this.tabRecovery.enabled = true
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
/** Continue to store the tabs even if the setting is currently off */
|
||||||
|
this.tabRecovery.enabled = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hostApp.windowFocused$.subscribe(() => {
|
||||||
|
this._activeTab?.emitFocused()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
addTabRaw (tab: BaseTabComponent, index: number|null = null): void {
|
addTabRaw (tab: BaseTabComponent, index: number|null = null): void {
|
||||||
@ -295,6 +293,16 @@ export class AppService {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async closeWindow (): Promise<void> {
|
||||||
|
this.tabRecovery.enabled = false
|
||||||
|
await this.tabRecovery.saveTabs(this.tabs)
|
||||||
|
if (await this.closeAllTabs()) {
|
||||||
|
this.hostApp.closeWindow()
|
||||||
|
} else {
|
||||||
|
this.tabRecovery.enabled = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** @hidden */
|
/** @hidden */
|
||||||
emitReady (): void {
|
emitReady (): void {
|
||||||
this.ready.next()
|
this.ready.next()
|
||||||
|
@ -8,6 +8,7 @@ import { ConfigService } from '../services/config.service'
|
|||||||
@Injectable({ providedIn: 'root' })
|
@Injectable({ providedIn: 'root' })
|
||||||
export class TabRecoveryService {
|
export class TabRecoveryService {
|
||||||
logger: Logger
|
logger: Logger
|
||||||
|
enabled = false
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
@Inject(TabRecoveryProvider) private tabRecoveryProviders: TabRecoveryProvider[],
|
@Inject(TabRecoveryProvider) private tabRecoveryProviders: TabRecoveryProvider[],
|
||||||
@ -18,6 +19,9 @@ export class TabRecoveryService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async saveTabs (tabs: BaseTabComponent[]): Promise<void> {
|
async saveTabs (tabs: BaseTabComponent[]): Promise<void> {
|
||||||
|
if (!this.enabled) {
|
||||||
|
return
|
||||||
|
}
|
||||||
window.localStorage.tabsRecovery = JSON.stringify(
|
window.localStorage.tabsRecovery = JSON.stringify(
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
tabs
|
tabs
|
||||||
@ -25,8 +29,11 @@ export class TabRecoveryService {
|
|||||||
let token = tab.getRecoveryToken()
|
let token = tab.getRecoveryToken()
|
||||||
if (token) {
|
if (token) {
|
||||||
token = token.then(r => {
|
token = token.then(r => {
|
||||||
if (r && tab.color) {
|
if (r) {
|
||||||
r.tabColor = tab.color
|
r.tabTitle = tab.title
|
||||||
|
if (tab.color) {
|
||||||
|
r.tabColor = tab.color
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return r
|
return r
|
||||||
})
|
})
|
||||||
@ -45,6 +52,7 @@ export class TabRecoveryService {
|
|||||||
if (tab !== null) {
|
if (tab !== null) {
|
||||||
tab.options = tab.options || {}
|
tab.options = tab.options || {}
|
||||||
tab.options.color = token.tabColor || null
|
tab.options.color = token.tabColor || null
|
||||||
|
tab.options.title = token.tabTitle || ''
|
||||||
return tab
|
return tab
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user