simpler tab recovery system

This commit is contained in:
Eugene Pankov
2018-12-16 15:42:04 +01:00
parent df97e7ebb5
commit cded1284de
18 changed files with 545 additions and 506 deletions

View File

@@ -69,7 +69,7 @@ export abstract class BaseTabComponent {
this.activity.next(false)
}
getRecoveryToken (): any {
async getRecoveryToken (): Promise<any> {
return null
}

View File

@@ -19,13 +19,18 @@ export class TabRecoveryService {
app.tabsChanged$.subscribe(() => {
this.saveTabs(app.tabs)
})
setInterval(() => {
this.saveTabs(app.tabs)
}, 30000)
}
saveTabs (tabs: BaseTabComponent[]) {
async saveTabs (tabs: BaseTabComponent[]) {
window.localStorage.tabsRecovery = JSON.stringify(
tabs
.map((tab) => tab.getRecoveryToken())
.filter((token) => !!token)
await Promise.all(
tabs
.map(tab => tab.getRecoveryToken())
.filter(token => !!token)
)
)
}