mirror of
https://github.com/bitwarden/browser
synced 2026-02-27 01:53:23 +00:00
Remove unnecessary type logic to use returned enum
This commit is contained in:
@@ -286,27 +286,7 @@ export class CipherView implements View, InitializerMetadata {
|
||||
cipherView.folderId = uuidAsString(obj.folderId);
|
||||
cipherView.name = obj.name;
|
||||
cipherView.notes = obj.notes;
|
||||
|
||||
// SDK returns type as a discriminated union object, extract the actual CipherType
|
||||
const sdkType: CipherViewType | CipherType = (obj.type as any) ?? CipherType.Login;
|
||||
|
||||
// Handle both discriminated union format and numeric CipherType
|
||||
if (typeof sdkType === "number") {
|
||||
cipherView.type = sdkType;
|
||||
} else if (typeof sdkType === "object" && sdkType !== null) {
|
||||
if ("login" in sdkType) {
|
||||
cipherView.type = CipherType.Login;
|
||||
} else if ("card" in sdkType) {
|
||||
cipherView.type = CipherType.Card;
|
||||
} else if ("identity" in sdkType) {
|
||||
cipherView.type = CipherType.Identity;
|
||||
} else if ("secureNote" in sdkType) {
|
||||
cipherView.type = CipherType.SecureNote;
|
||||
} else if ("sshKey" in sdkType) {
|
||||
cipherView.type = CipherType.SshKey;
|
||||
}
|
||||
}
|
||||
|
||||
cipherView.type = obj.type ?? CipherType.Login;
|
||||
cipherView.favorite = obj.favorite;
|
||||
cipherView.organizationUseTotp = obj.organizationUseTotp;
|
||||
cipherView.permissions = obj.permissions
|
||||
|
||||
Reference in New Issue
Block a user