chore: remember previous multiple vault selection when switching back from single to multiple
This commit is contained in:
@@ -13,7 +13,12 @@ import {
|
|||||||
StorageKey,
|
StorageKey,
|
||||||
VaultLockServiceEvent,
|
VaultLockServiceEvent,
|
||||||
} from '@standardnotes/services'
|
} from '@standardnotes/services'
|
||||||
import { VaultDisplayOptions, VaultDisplayOptionsPersistable, VaultListingInterface } from '@standardnotes/models'
|
import {
|
||||||
|
ExclusionaryOptions,
|
||||||
|
VaultDisplayOptions,
|
||||||
|
VaultDisplayOptionsPersistable,
|
||||||
|
VaultListingInterface,
|
||||||
|
} from '@standardnotes/models'
|
||||||
import { VaultDisplayServiceEvent } from './VaultDisplayServiceEvent'
|
import { VaultDisplayServiceEvent } from './VaultDisplayServiceEvent'
|
||||||
import { AbstractUIService } from '../Abstract/AbstractUIService'
|
import { AbstractUIService } from '../Abstract/AbstractUIService'
|
||||||
import { WebApplicationInterface } from '../WebApplication/WebApplicationInterface'
|
import { WebApplicationInterface } from '../WebApplication/WebApplicationInterface'
|
||||||
@@ -25,6 +30,7 @@ export class VaultDisplayService
|
|||||||
extends AbstractUIService<VaultDisplayServiceEvent>
|
extends AbstractUIService<VaultDisplayServiceEvent>
|
||||||
implements VaultDisplayServiceInterface, InternalEventHandlerInterface
|
implements VaultDisplayServiceInterface, InternalEventHandlerInterface
|
||||||
{
|
{
|
||||||
|
previousMultipleSelectionOptions?: VaultDisplayOptions
|
||||||
options: VaultDisplayOptions
|
options: VaultDisplayOptions
|
||||||
|
|
||||||
public exclusivelyShownVault: VaultListingInterface | undefined = undefined
|
public exclusivelyShownVault: VaultListingInterface | undefined = undefined
|
||||||
@@ -101,10 +107,14 @@ export class VaultDisplayService
|
|||||||
const vaults = this.application.vaults.getVaults()
|
const vaults = this.application.vaults.getVaults()
|
||||||
const lockedVaults = this.application.vaultLocks.getLockedvaults()
|
const lockedVaults = this.application.vaultLocks.getLockedvaults()
|
||||||
|
|
||||||
|
const exclude = this.previousMultipleSelectionOptions
|
||||||
|
? (this.previousMultipleSelectionOptions.getOptions() as ExclusionaryOptions).exclude
|
||||||
|
: vaults
|
||||||
|
.map((vault) => vault.systemIdentifier)
|
||||||
|
.filter((identifier) => identifier !== this.exclusivelyShownVault?.systemIdentifier)
|
||||||
|
|
||||||
const newOptions = new VaultDisplayOptions({
|
const newOptions = new VaultDisplayOptions({
|
||||||
exclude: vaults
|
exclude,
|
||||||
.map((vault) => vault.systemIdentifier)
|
|
||||||
.filter((identifier) => identifier !== this.exclusivelyShownVault?.systemIdentifier),
|
|
||||||
locked: lockedVaults.map((vault) => vault.systemIdentifier),
|
locked: lockedVaults.map((vault) => vault.systemIdentifier),
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -187,8 +197,16 @@ export class VaultDisplayService
|
|||||||
}
|
}
|
||||||
|
|
||||||
private setVaultSelectionOptions = (options: VaultDisplayOptions) => {
|
private setVaultSelectionOptions = (options: VaultDisplayOptions) => {
|
||||||
|
const previousOptions = this.options
|
||||||
this.options = options
|
this.options = options
|
||||||
|
|
||||||
|
const changingFromMultipleToExclusive =
|
||||||
|
!previousOptions.isInExclusiveDisplayMode() && options.isInExclusiveDisplayMode()
|
||||||
|
|
||||||
|
if (changingFromMultipleToExclusive) {
|
||||||
|
this.previousMultipleSelectionOptions = previousOptions
|
||||||
|
}
|
||||||
|
|
||||||
if (this.isInExclusiveDisplayMode()) {
|
if (this.isInExclusiveDisplayMode()) {
|
||||||
this.exclusivelyShownVault = this.application.vaults.getVault({
|
this.exclusivelyShownVault = this.application.vaults.getVault({
|
||||||
keySystemIdentifier: this.options.getExclusivelyShownVault(),
|
keySystemIdentifier: this.options.getExclusivelyShownVault(),
|
||||||
|
|||||||
Reference in New Issue
Block a user