moved recentProfiles from config to localStorage

This commit is contained in:
Eugene Pankov 2021-08-27 19:54:20 +02:00
parent bcf09c59e3
commit f36e2551b5
No known key found for this signature in database
GPG Key ID: 5896FCBBDD1CF4F4
3 changed files with 4 additions and 5 deletions

View File

@ -35,7 +35,7 @@ export class ButtonProvider extends ToolbarButtonProvider {
async launchProfile (profile: PartialProfile<Profile>) {
await this.profilesService.openNewTabForProfile(profile)
let recentProfiles = this.config.store.recentProfiles
let recentProfiles: PartialProfile<Profile>[] = JSON.parse(window.localStorage['recentProfiles'] ?? '[]')
if (this.config.store.terminal.showRecentProfiles > 0) {
recentProfiles = recentProfiles.filter(x => x.group !== profile.group || x.name !== profile.name)
recentProfiles.unshift(profile)
@ -43,7 +43,7 @@ export class ButtonProvider extends ToolbarButtonProvider {
} else {
recentProfiles = []
}
this.config.store.recentProfiles = recentProfiles
window.localStorage['recentProfiles'] = JSON.stringify(recentProfiles)
this.config.save()
}

View File

@ -25,7 +25,6 @@ hotkeys:
profiles: []
profileDefaults:
__nonStructural: true
recentProfiles: []
recoverTabs: true
enableAnalytics: true
enableWelcomeTab: true

View File

@ -94,7 +94,7 @@ export class ProfilesService {
showProfileSelector (): Promise<PartialProfile<Profile>|null> {
return new Promise<PartialProfile<Profile>|null>(async (resolve, reject) => {
try {
let recentProfiles: PartialProfile<Profile>[] = this.config.store.recentProfiles
let recentProfiles: PartialProfile<Profile>[] = JSON.parse(window.localStorage['recentProfiles'] ?? '[]')
recentProfiles = recentProfiles.slice(0, this.config.store.terminal.showRecentProfiles)
let options: SelectorOption<void>[] = recentProfiles.map(p => ({
@ -113,7 +113,7 @@ export class ProfilesService {
name: 'Clear recent connections',
icon: 'fas fa-eraser',
callback: async () => {
this.config.store.recentProfiles = []
window.localStorage.removeItem('recentProfiles')
this.config.save()
resolve(null)
},