chore: allow setting custom icon to vault
This commit is contained in:
@@ -8,6 +8,8 @@ import {
|
||||
KeySystemRootKeyStorageMode,
|
||||
FillItemContentSpecialized,
|
||||
KeySystemRootKeyInterface,
|
||||
EmojiString,
|
||||
IconType,
|
||||
} from '@standardnotes/models'
|
||||
import { MutatorClientInterface } from '../../Mutator/MutatorClientInterface'
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
@@ -25,6 +27,7 @@ export class CreateVault {
|
||||
async execute(dto: {
|
||||
vaultName: string
|
||||
vaultDescription?: string
|
||||
vaultIcon: IconType | EmojiString
|
||||
userInputtedPassword: string | undefined
|
||||
storagePreference: KeySystemRootKeyStorageMode
|
||||
}): Promise<VaultListingInterface> {
|
||||
@@ -44,6 +47,7 @@ export class CreateVault {
|
||||
keySystemIdentifier,
|
||||
vaultName: dto.vaultName,
|
||||
vaultDescription: dto.vaultDescription,
|
||||
vaultIcon: dto.vaultIcon,
|
||||
passwordType: dto.userInputtedPassword ? KeySystemPasswordType.UserInputted : KeySystemPasswordType.Randomized,
|
||||
rootKeyParams: rootKey.keyParams,
|
||||
storage: dto.storagePreference,
|
||||
@@ -58,6 +62,7 @@ export class CreateVault {
|
||||
keySystemIdentifier: string
|
||||
vaultName: string
|
||||
vaultDescription?: string
|
||||
vaultIcon: IconType | EmojiString
|
||||
passwordType: KeySystemPasswordType
|
||||
rootKeyParams: KeySystemRootKeyParamsInterface
|
||||
storage: KeySystemRootKeyStorageMode
|
||||
@@ -68,6 +73,7 @@ export class CreateVault {
|
||||
keyStorageMode: dto.storage,
|
||||
name: dto.vaultName,
|
||||
description: dto.vaultDescription,
|
||||
iconString: dto.vaultIcon,
|
||||
}
|
||||
|
||||
return this.mutator.createItem(ContentType.TYPES.VaultListing, FillItemContentSpecialized(content), true)
|
||||
|
||||
@@ -4,7 +4,9 @@ import { SendVaultDataChangedMessage } from './../SharedVaults/UseCase/SendVault
|
||||
import { isClientDisplayableError } from '@standardnotes/responses'
|
||||
import {
|
||||
DecryptedItemInterface,
|
||||
EmojiString,
|
||||
FileItem,
|
||||
IconType,
|
||||
KeySystemIdentifier,
|
||||
KeySystemRootKeyStorageMode,
|
||||
SharedVaultListingInterface,
|
||||
@@ -97,10 +99,15 @@ export class VaultService
|
||||
return vault
|
||||
}
|
||||
|
||||
async createRandomizedVault(dto: { name: string; description?: string }): Promise<VaultListingInterface> {
|
||||
async createRandomizedVault(dto: {
|
||||
name: string
|
||||
description?: string
|
||||
iconString: IconType | EmojiString
|
||||
}): Promise<VaultListingInterface> {
|
||||
return this.createVaultWithParameters({
|
||||
name: dto.name,
|
||||
description: dto.description,
|
||||
iconString: dto.iconString,
|
||||
userInputtedPassword: undefined,
|
||||
storagePreference: KeySystemRootKeyStorageMode.Synced,
|
||||
})
|
||||
@@ -109,6 +116,7 @@ export class VaultService
|
||||
async createUserInputtedPasswordVault(dto: {
|
||||
name: string
|
||||
description?: string
|
||||
iconString: IconType | EmojiString
|
||||
userInputtedPassword: string
|
||||
storagePreference: KeySystemRootKeyStorageMode
|
||||
}): Promise<VaultListingInterface> {
|
||||
@@ -118,12 +126,14 @@ export class VaultService
|
||||
private async createVaultWithParameters(dto: {
|
||||
name: string
|
||||
description?: string
|
||||
iconString: IconType | EmojiString
|
||||
userInputtedPassword: string | undefined
|
||||
storagePreference: KeySystemRootKeyStorageMode
|
||||
}): Promise<VaultListingInterface> {
|
||||
const result = await this._createVault.execute({
|
||||
vaultName: dto.name,
|
||||
vaultDescription: dto.description,
|
||||
vaultIcon: dto.iconString,
|
||||
userInputtedPassword: dto.userInputtedPassword,
|
||||
storagePreference: dto.storagePreference,
|
||||
})
|
||||
@@ -188,13 +198,14 @@ export class VaultService
|
||||
return true
|
||||
}
|
||||
|
||||
async changeVaultNameAndDescription(
|
||||
async changeVaultMetadata(
|
||||
vault: VaultListingInterface,
|
||||
params: { name: string; description?: string },
|
||||
params: { name: string; description?: string; iconString: IconType | EmojiString },
|
||||
): Promise<VaultListingInterface> {
|
||||
const updatedVault = await this.mutator.changeItem<VaultListingMutator, VaultListingInterface>(vault, (mutator) => {
|
||||
mutator.name = params.name
|
||||
mutator.description = params.description
|
||||
mutator.iconString = params.iconString
|
||||
})
|
||||
|
||||
await this.sync.sync()
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import {
|
||||
DecryptedItemInterface,
|
||||
EmojiString,
|
||||
IconType,
|
||||
KeySystemIdentifier,
|
||||
KeySystemRootKeyStorageMode,
|
||||
SharedVaultListingInterface,
|
||||
@@ -12,10 +14,15 @@ import { Result } from '@standardnotes/domain-core'
|
||||
|
||||
export interface VaultServiceInterface
|
||||
extends AbstractService<VaultServiceEvent, VaultServiceEventPayload[VaultServiceEvent]> {
|
||||
createRandomizedVault(dto: { name: string; description?: string }): Promise<VaultListingInterface>
|
||||
createRandomizedVault(dto: {
|
||||
name: string
|
||||
description?: string
|
||||
iconString: IconType | EmojiString
|
||||
}): Promise<VaultListingInterface>
|
||||
createUserInputtedPasswordVault(dto: {
|
||||
name: string
|
||||
description?: string
|
||||
iconString: IconType | EmojiString
|
||||
userInputtedPassword: string
|
||||
storagePreference: KeySystemRootKeyStorageMode
|
||||
}): Promise<VaultListingInterface>
|
||||
@@ -32,9 +39,9 @@ export interface VaultServiceInterface
|
||||
isItemInVault(item: DecryptedItemInterface): boolean
|
||||
getItemVault(item: DecryptedItemInterface): VaultListingInterface | undefined
|
||||
|
||||
changeVaultNameAndDescription(
|
||||
changeVaultMetadata(
|
||||
vault: VaultListingInterface,
|
||||
params: { name: string; description: string },
|
||||
params: { name: string; description: string; iconString: IconType | EmojiString },
|
||||
): Promise<VaultListingInterface>
|
||||
rotateVaultRootKey(vault: VaultListingInterface, vaultPassword?: string): Promise<void>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user