duplicate tab title and color when duplicating a tab - fixes #3588

This commit is contained in:
Eugene Pankov 2021-03-13 20:06:37 +01:00
parent 6236ee95c3
commit 62a21b03ea
No known key found for this signature in database
GPG Key ID: 5896FCBBDD1CF4F4
3 changed files with 14 additions and 12 deletions

View File

@ -100,7 +100,7 @@ export class AppService {
hostApp.windowFocused$.subscribe(() => this._activeTab?.emitFocused())
this.tabClosed$.subscribe(async tab => {
const token = await tab.getRecoveryToken()
const token = await tabRecovery.getFullRecoveryToken(tab)
if (token) {
this.closedTabsStack.push(token)
}

View File

@ -24,20 +24,22 @@ export class TabRecoveryService {
}
window.localStorage.tabsRecovery = JSON.stringify(
(await Promise.all(
tabs
.map(async tab => tab.getRecoveryToken().then(r => {
if (r) {
r.tabTitle = tab.title
if (tab.color) {
r.tabColor = tab.color
}
}
return r
}))
tabs.map(async tab => this.getFullRecoveryToken(tab))
)).filter(token => !!token)
)
}
async getFullRecoveryToken (tab: BaseTabComponent): Promise<RecoveryToken|null> {
const token = await tab.getRecoveryToken()
if (token) {
token.tabTitle = tab.title
if (tab.color) {
token.tabColor = tab.color
}
}
return token
}
async recoverTab (token: RecoveryToken): Promise<RecoveredTab|null> {
for (const provider of this.config.enabledServices(this.tabRecoveryProviders ?? [])) {
try {

View File

@ -30,7 +30,7 @@ export class TabsService {
* Duplicates an existing tab instance (using the tab recovery system)
*/
async duplicate (tab: BaseTabComponent): Promise<BaseTabComponent|null> {
const token = await tab.getRecoveryToken()
const token = await this.tabRecovery.getFullRecoveryToken(tab)
if (!token) {
return null
}