Repository Public
1// One item: fields with masked secrets, live one-time code, URLs, attachments, password history, revisions, actions.2import QuickLook3import SharedVaultKit4import SwiftUI5import UniformTypeIdentifiers67/// A list row: glyph, title, who / where. Never shows a secret.8struct ItemRowView: View {9 let view: ItemView10 var body: some View {11 HStack(spacing: 11) {12 ItemGlyph(title: ItemMeta.displayTitle(view.item), symbol: ItemMeta.glyphSymbol(view.item), size: rowGlyph)13 VStack(alignment: .leading, spacing: 2) {14 HStack(spacing: 5) {15 Text(ItemMeta.displayTitle(view.item)).font(.body.weight(.medium)).foregroundStyle(Palette.text).lineLimit(1)16 if view.item.favorite { Image(systemName: "star.fill").font(.caption2).foregroundStyle(Palette.brass).accessibilityLabel("Favorite") }17 if view.item.conflictOf != nil { Image(systemName: "arrow.triangle.branch").font(.caption2).foregroundStyle(Palette.brass).accessibilityLabel("Conflict copy") }18 }19 Text(ItemMeta.subtitle(view.item)).font(.callout).foregroundStyle(Palette.muted).lineLimit(1)20 }21 Spacer(minLength: 4)22 if view.pending { Image(systemName: "arrow.triangle.2.circlepath").font(.caption).foregroundStyle(Palette.muted).accessibilityLabel("Waiting to sync") }23 }24 .padding(.vertical, rowPad)25 .contentShape(Rectangle())26 .accessibilityElement(children: .combine)27 .accessibilityIdentifier("item-row-\(ItemMeta.displayTitle(view.item))")28 }29 private var rowGlyph: CGFloat {30 #if os(macOS)31 3232 #else33 4034 #endif35 }36 private var rowPad: CGFloat {37 #if os(macOS)38 339 #else40 441 #endif42 }43}4445struct ItemDetailView: View {46 @Environment(AppModel.self) private var model47 @Environment(\.openURL) private var openURL48 @Environment(\.horizontalSizeClass) private var sizeClass49 let view: ItemView5051 @State private var confirm: ConfirmRequest?52 @State private var sharing = false53 @State private var importing = false54 @State private var error: String?55 @State private var uploadProgress: Double?56 @State private var preview: URL?57 @State private var busyAttachment: String?58 @State private var showPasswordHistory = false59 @State private var showHistory = false60 @State private var revisions: [ItemRevision]?61 @State private var revisionPreview: ItemRevision?6263 /// iPhone: the header actions live in the navigation bar and the layout stacks vertically.64 private var compact: Bool {65 #if os(iOS)66 sizeClass == .compact67 #else68 false69 #endif70 }71 private var item: Item { view.item }72 private var trashed: Bool { !(item.trashedAt ?? "").isEmpty }73 private var writable: Bool { model.vault(view.vaultId)?.role != .reader }7475 var body: some View {76 ScrollView {77 VStack(alignment: .leading, spacing: 16) {78 header79 if trashed {80 Callout(kind: .warn, title: "In the trash", text: "Moved to trash \(ItemMeta.relative(item.trashedAt)). Restore it to use it again, or delete it permanently.")81 }82 if item.conflictOf != nil, !trashed { conflictBanner }83 expiryBanner84 ErrorText(text: error)85 fieldsCard86 urlsCard87 customCard88 notesCard89 if !item.tags.isEmpty { tags }90 attachments91 histories92 meta93 actions94 }95 .frame(maxWidth: 720, alignment: .leading)96 .padding(.horizontal, pad).padding(.top, compact ? 8 : 20).padding(.bottom, compact ? 28 : 20)97 .frame(maxWidth: .infinity, alignment: .center)98 }99 .scrollContentBackground(.hidden)100 .vaultBackground()101 .containerID("item-detail")102 .confirmSheet($confirm)103 .sheet(isPresented: $sharing) { ShareItemSheet(item: view) }104 .sheet(item: Binding(get: { revisionPreview.map(RevisionBox.init) }, set: { revisionPreview = $0?.revision })) { box in revisionSheet(box.revision) }105 .fileImporter(isPresented: $importing, allowedContentTypes: [.item]) { result in106 if case .success(let url) = result { Task { await attach(url) } }107 }108 .quickLookPreview($preview)109 .onChange(of: preview) { old, new in if new == nil, let old { try? FileManager.default.removeItem(at: old.deletingLastPathComponent()) } }110 .onChange(of: view.id) { _, _ in revisions = nil; showHistory = false; showPasswordHistory = false; error = nil }111 .onChange(of: view.rev) { _, _ in if showHistory { Task { await loadHistory() } } }112 }113114 private var pad: CGFloat {115 #if os(macOS)116 28117 #else118 16119 #endif120 }121122 // ── header ──123 private var header: some View {124 HStack(alignment: .center, spacing: 14) {125 ItemGlyph(title: ItemMeta.displayTitle(item), symbol: ItemMeta.glyphSymbol(item), size: 52)126 VStack(alignment: .leading, spacing: 3) {127 Text(ItemMeta.displayTitle(item)).font(compact ? .system(.title, design: .serif, weight: .semibold) : .vaultLargeTitle).foregroundStyle(Palette.text)128 .lineLimit(2).minimumScaleFactor(0.75).accessibilityAddTraits(.isHeader).accessibilityIdentifier("detail-title")129 Text("\(item.type.template.label) · \(ItemMeta.subtitle(item))").font(.callout).foregroundStyle(Palette.muted).lineLimit(2)130 }131 Spacer(minLength: 6)132 if writable, !trashed, !compact { favoriteButton; editButton }133 }134 #if os(iOS)135 .toolbar {136 if writable, !trashed, compact {137 ToolbarItem(placement: .topBarTrailing) { favoriteButton }138 ToolbarItem(placement: .topBarTrailing) { Button("Edit") { model.edit(view) }.fontWeight(.semibold).accessibilityIdentifier("detail-edit") }139 }140 }141 #endif142 }143144 private var favoriteButton: some View {145 IconButton(systemName: item.favorite ? "star.fill" : "star", label: item.favorite ? "Remove from favorites" : "Add to favorites", tint: item.favorite ? Palette.brass : Palette.muted) {146 Task { await model.toggleFavorite(view) }147 }148 .accessibilityIdentifier("detail-favorite")149 }150151 private var editButton: some View {152 Button { model.edit(view) } label: { Label("Edit", systemImage: "pencil") }.buttonStyle(.vaultPrimary).accessibilityIdentifier("detail-edit")153 }154155 // ── banners ──156 private var conflictBanner: some View {157 VStack(alignment: .leading, spacing: 10) {158 Callout(kind: .warn, title: "Conflict copy", text: "This item was edited on two devices at the same time. The server kept the other version; this is the version from this device. Keep the one you want.")159 HStack {160 Button("Keep this one") { Task { await keepConflict() } }.buttonStyle(VaultButtonStyle(kind: .primary, compact: true)).accessibilityIdentifier("conflict-keep")161 Button("Discard copy") { Task { await model.act("Conflict copy discarded") { try await model.engine.deleteItem(vaultId: view.vaultId, id: view.recordId) } } }162 .buttonStyle(VaultButtonStyle(kind: .danger, compact: true)).accessibilityIdentifier("conflict-discard")163 }164 }165 .frame(maxWidth: .infinity, alignment: .leading)166 }167168 private func keepConflict() async {169 var clean = item170 clean.conflictOf = nil171 if clean.title.hasSuffix(" (conflict copy)") { clean.title.removeLast(" (conflict copy)".count) }172 let original = item.conflictOf.flatMap { model.engine_get(view.vaultId, $0) }173 await model.act("Kept this version") {174 if let original {175 try await model.engine.saveItem(vaultId: view.vaultId, id: original.recordId, item: clean)176 try await model.engine.deleteItem(vaultId: view.vaultId, id: view.recordId)177 model.selectedItemID = original.id178 } else {179 try await model.engine.saveItem(vaultId: view.vaultId, id: view.recordId, item: clean)180 }181 }182 }183184 @ViewBuilder private var expiryBanner: some View {185 if let exp = item.expiresAt, let d = ItemMeta.parseISO(exp) {186 let days = Int(d.timeIntervalSinceNow / 86400)187 if d < Date() { Callout(kind: .danger, title: "Expired", text: "This item expired on \(d.formatted(date: .abbreviated, time: .omitted)).") }188 else if days <= 30 { Callout(kind: .warn, title: "Expires soon", text: "Expires on \(d.formatted(date: .abbreviated, time: .omitted)) (in \(days) day\(days == 1 ? "" : "s")).") }189 }190 }191192 // ── fields ──193 private var shownFields: [FieldDef] { item.type.template.fields.filter { !(item.fields[$0.key] ?? "").isEmpty } }194195 @ViewBuilder private var fieldsCard: some View {196 let defs = shownFields197 if !defs.isEmpty {198 VStack(spacing: 0) {199 ForEach(Array(defs.enumerated()), id: \.element.key) { i, def in200 CardRow(last: i == defs.count - 1) { fieldRow(def.label, item.fields[def.key] ?? "", def.kind, id: def.key) }201 }202 }203 .vaultCard()204 }205 }206207 @ViewBuilder private func fieldRow(_ label: String, _ value: String, _ kind: FieldKind, id: String) -> some View {208 switch kind {209 case .secret: SecretRow(label: label, value: value, multiline: value.contains("\n"), testID: "field-\(id)")210 case .totp: TotpRow(secret: value, label: label)211 case .multiline: TextValueRow(label: label, value: value, mono: true, testID: "field-\(id)")212 case .url:213 FieldRow(label: label) { Text(value).foregroundStyle(Palette.text).textSelection(.enabled) } actions: {214 IconButton(systemName: "doc.on.doc", label: "Copy \(label)") { model.copy(value, label: label, secret: false) }215 }216 case .text, .date: TextValueRow(label: label, value: value, testID: "field-\(id)")217 }218 }219220 @ViewBuilder private var urlsCard: some View {221 if !item.urls.isEmpty {222 VStack(spacing: 0) {223 ForEach(Array(item.urls.enumerated()), id: \.offset) { i, u in224 CardRow(last: i == item.urls.count - 1) {225 let origin = SPV1.parseOrigin(u.url)226 FieldRow(label: item.urls.count > 1 ? "Website \(i + 1)" : "Website") {227 VStack(alignment: .leading, spacing: 2) {228 Text(origin?.display ?? u.url).font(.body.weight(.semibold)).foregroundStyle(Palette.text).lineLimit(1).textSelection(.enabled)229 HStack(spacing: 6) {230 if origin?.scheme == "http" { Pill(text: "not encrypted (http)", tint: Palette.danger) }231 if origin?.mixedScript == true { Pill(text: "mixed scripts", tint: Palette.danger) }232 if u.match != .domain { Pill(text: Self.matchLabel(u.match)) }233 }234 }235 } actions: {236 if let origin, origin.scheme == "https" || origin.scheme == "http", let url = URL(string: u.url) {237 IconButton(systemName: "arrow.up.right.square", label: "Open \(origin.display) in the browser") { openURL(url) }238 }239 IconButton(systemName: "doc.on.doc", label: "Copy address") { model.copy(u.url, label: "Address", secret: false) }240 }241 }242 }243 }244 .vaultCard()245 }246 }247248 static func matchLabel(_ m: UrlMatch) -> String {249 switch m {250 case .domain: "matches the whole domain"251 case .host: "this host only"252 case .exact: "this exact address only"253 case .never: "never offered for autofill"254 }255 }256257 @ViewBuilder private var customCard: some View {258 if !item.custom.isEmpty {259 VStack(spacing: 0) {260 ForEach(Array(item.custom.enumerated()), id: \.offset) { i, c in261 CardRow(last: i == item.custom.count - 1) { fieldRow(c.label.isEmpty ? "Field" : c.label, c.value, c.kind, id: "custom-\(i)") }262 }263 }264 .vaultCard()265 }266 }267268 @ViewBuilder private var notesCard: some View {269 if !item.notes.isEmpty {270 VStack(alignment: .leading, spacing: 6) {271 Text("Notes").font(.caption.weight(.medium)).foregroundStyle(Palette.muted)272 Text(item.notes).font(.body).foregroundStyle(Palette.text).textSelection(.enabled).frame(maxWidth: .infinity, alignment: .leading)273 }274 .padding(Metrics.rowPadding).vaultCard()275 }276 }277278 private var tags: some View {279 HStack(spacing: 6) {280 Image(systemName: "tag").font(.caption).foregroundStyle(Palette.muted).accessibilityHidden(true)281 ForEach(item.tags, id: \.self) { Pill(text: $0) }282 }283 .accessibilityElement(children: .combine).accessibilityLabel("Tags: \(item.tags.joined(separator: ", "))")284 }285286 // ── attachments ──287 private var attachments: some View {288 VStack(alignment: .leading, spacing: 8) {289 HStack {290 Eyebrow("Attachments")291 Spacer()292 if writable, !trashed {293 Button { importing = true } label: { Label("Attach file", systemImage: "arrow.up.doc") }.buttonStyle(.vaultCompact).disabled(uploadProgress != nil)294 .accessibilityIdentifier("attach-file")295 }296 }297 if let p = uploadProgress { ProgressView(value: p).tint(Palette.accent).accessibilityLabel("Uploading attachment") }298 if item.attachments.isEmpty {299 Text("Files are encrypted on this device in 1 MiB chunks before upload. The server sees sizes only.").font(.caption).foregroundStyle(Palette.muted)300 } else {301 VStack(spacing: 0) {302 ForEach(Array(item.attachments.enumerated()), id: \.element.id) { i, a in303 CardRow(last: i == item.attachments.count - 1) {304 HStack(spacing: 10) {305 Image(systemName: "doc").foregroundStyle(Palette.muted).accessibilityHidden(true)306 VStack(alignment: .leading, spacing: 1) {307 Text(a.name.isEmpty ? "Attachment" : a.name).foregroundStyle(Palette.text).lineLimit(1)308 Text(ByteCountFormatter.string(fromByteCount: Int64(a.size), countStyle: .file)).font(.caption).foregroundStyle(Palette.muted)309 }310 Spacer()311 if busyAttachment == a.id { ProgressView().controlSize(.small) }312 else {313 IconButton(systemName: "eye", label: "Preview \(a.name)") { Task { await open(a) } }314 if writable, !trashed {315 IconButton(systemName: "trash", label: "Remove \(a.name)", tint: Palette.danger) {316 confirm = ConfirmRequest(title: "Remove this attachment?", message: "“\(a.name)” will be detached from the item. Earlier revisions that reference it keep it until they expire.", confirmLabel: "Remove") {317 var it = item318 it.attachments.removeAll { $0.id == a.id }319 await model.act("Attachment removed") { try await model.engine.saveItem(vaultId: view.vaultId, id: view.recordId, item: it) }320 }321 }322 }323 }324 }325 }326 }327 }328 .vaultCard()329 }330 }331 }332333 private func attach(_ url: URL) async {334 let scoped = url.startAccessingSecurityScopedResource()335 defer { if scoped { url.stopAccessingSecurityScopedResource() } }336 guard let data = try? Data(contentsOf: url) else { error = "The file could not be read."; return }337 guard data.count <= 100 * 1024 * 1024 else { error = "This file is larger than 100 MB."; return }338 let name = url.lastPathComponent, mime = UTType(filenameExtension: url.pathExtension)?.preferredMIMEType ?? "application/octet-stream"339 uploadProgress = 0340 defer { uploadProgress = nil }341 error = await model.perform("Attachment encrypted and uploaded") {342 let ref = try await model.engine.upload(vaultId: view.vaultId, name: name, mime: mime, data: data) { done, total in343 Task { @MainActor in uploadProgress = Double(done) / Double(max(total, 1)) }344 }345 var it = item346 it.attachments.append(ref)347 try await model.engine.saveItem(vaultId: view.vaultId, id: view.recordId, item: it)348 }349 }350351 /// Downloads, decrypts and shows the file with Quick Look. The decrypted copy lives in a private temporary352 /// directory only while the preview is open.353 private func open(_ a: AttachmentRef) async {354 busyAttachment = a.id355 defer { busyAttachment = nil }356 error = await model.perform {357 let data = try await model.engine.download(a)358 let dir = FileManager.default.temporaryDirectory.appendingPathComponent("spv-preview-\(UUID().uuidString)", isDirectory: true)359 try FileManager.default.createDirectory(at: dir, withIntermediateDirectories: true, attributes: [.posixPermissions: 0o700])360 let safe = a.name.replacingOccurrences(of: "/", with: "_").replacingOccurrences(of: "\\", with: "_")361 let file = dir.appendingPathComponent(safe.isEmpty || safe.hasPrefix(".") ? "attachment" : safe)362 var options: Data.WritingOptions = [.atomic]363 #if os(iOS)364 options.insert(.completeFileProtection)365 #endif366 try data.write(to: file, options: options)367 preview = file368 }369 }370371 // ── histories ──372 @ViewBuilder private var histories: some View {373 VStack(alignment: .leading, spacing: 0) {374 if !item.passwordHistory.isEmpty {375 Divider().overlay(Palette.line)376 DisclosureGroup(isExpanded: $showPasswordHistory) {377 VStack(spacing: 0) {378 ForEach(Array(item.passwordHistory.reversed().enumerated()), id: \.offset) { i, h in379 CardRow(last: i == item.passwordHistory.count - 1) { SecretRow(label: "Replaced \(ItemMeta.date(h.at))", value: h.value, testID: "pwhistory-\(i)") }380 }381 }382 .vaultCard().padding(.top, 8)383 } label: {384 (Text("Password history ").fontWeight(.semibold).foregroundColor(Palette.text) + Text("(\(item.passwordHistory.count))").foregroundColor(Palette.muted))385 }386 .padding(.vertical, 10).accessibilityIdentifier("password-history")387 }388 Divider().overlay(Palette.line)389 DisclosureGroup(isExpanded: $showHistory) {390 Group {391 if let revisions {392 if revisions.isEmpty { Text("No earlier revision is kept for this item.").font(.callout).foregroundStyle(Palette.muted).padding(.top, 8) }393 else {394 VStack(spacing: 0) {395 ForEach(Array(revisions.enumerated()), id: \.element.rev) { i, r in396 CardRow(last: i == revisions.count - 1) {397 HStack {398 VStack(alignment: .leading, spacing: 1) {399 Text("Revision \(r.rev)").foregroundStyle(Palette.text)400 Text(ItemMeta.date(r.at)).font(.caption).foregroundStyle(Palette.muted)401 }402 Spacer()403 Button("View") { revisionPreview = r }.buttonStyle(.vaultCompact).accessibilityIdentifier("history-view-\(r.rev)")404 }405 }406 }407 }408 .vaultCard().padding(.top, 8)409 }410 } else { ProgressView().controlSize(.small).padding(.top, 8) }411 }412 } label: {413 (Text("Item history ").fontWeight(.semibold).foregroundColor(Palette.text) + Text("(revision \(view.rev))").foregroundColor(Palette.muted))414 }415 .padding(.vertical, 10).accessibilityIdentifier("item-history")416 .onChange(of: showHistory) { _, open in if open { Task { await loadHistory() } } }417 Divider().overlay(Palette.line)418 }419 .tint(Palette.muted)420 }421422 private func loadHistory() async {423 error = await model.perform { revisions = try await model.engine.history(vaultId: view.vaultId, id: view.recordId) }424 if revisions == nil { revisions = [] }425 }426427 private struct RevisionBox: Identifiable { let revision: ItemRevision; var id: Int { revision.rev } }428429 private func revisionSheet(_ r: ItemRevision) -> some View {430 VStack(alignment: .leading, spacing: 12) {431 Text("Revision \(r.rev)").font(.vaultTitle).foregroundStyle(Palette.text)432 Text("Saved \(ItemMeta.date(r.at)) · \(ItemMeta.displayTitle(r.item))").font(.callout).foregroundStyle(Palette.muted)433 ScrollView {434 VStack(spacing: 0) {435 let defs = r.item.type.template.fields.filter { !(r.item.fields[$0.key] ?? "").isEmpty }436 ForEach(Array(defs.enumerated()), id: \.element.key) { i, def in437 CardRow(last: i == defs.count - 1) {438 if def.kind == .secret || def.kind == .totp { SecretRow(label: def.label, value: r.item.fields[def.key] ?? "", testID: "rev-\(def.key)") }439 else { TextValueRow(label: def.label, value: r.item.fields[def.key] ?? "") }440 }441 }442 }443 .vaultCard()444 }445 HStack {446 Spacer()447 Button("Close") { revisionPreview = nil }.buttonStyle(.vaultSecondary).keyboardShortcut(.cancelAction)448 if writable, !trashed {449 Button("Restore this version") {450 var it = r.item451 it.trashedAt = nil; it.conflictOf = nil; it.attachments = item.attachments452 revisionPreview = nil453 Task { await model.act("Revision \(r.rev) restored as a new revision") { try await model.engine.saveItem(vaultId: view.vaultId, id: view.recordId, item: it) } }454 }455 .buttonStyle(.vaultPrimary).accessibilityIdentifier("history-restore")456 }457 }458 }459 .padding(22).frame(minWidth: 320, idealWidth: 480, minHeight: 360).background(Palette.s1)460 }461462 // ── meta & actions ──463 @ViewBuilder private var meta: some View {464 if compact {465 VStack(spacing: 6) {466 metaRow("Vault", model.vault(view.vaultId)?.meta.name ?? "—")467 metaRow("Updated", ItemMeta.date(item.updatedAt))468 metaRow("Created", ItemMeta.date(item.createdAt))469 if view.pending { pendingLabel.frame(maxWidth: .infinity, alignment: .leading) }470 }471 } else {472 Grid(alignment: .leading, horizontalSpacing: 24, verticalSpacing: 4) {473 GridRow { Eyebrow("Vault"); Eyebrow("Updated"); Eyebrow("Created") }474 GridRow {475 Text(model.vault(view.vaultId)?.meta.name ?? "—")476 Text(ItemMeta.date(item.updatedAt))477 Text(ItemMeta.date(item.createdAt))478 }479 .font(.callout).foregroundStyle(Palette.text)480 if view.pending { GridRow { pendingLabel.gridCellColumns(3) } }481 }482 }483 }484485 private func metaRow(_ label: String, _ value: String) -> some View {486 HStack { Eyebrow(label); Spacer(); Text(value).font(.callout).foregroundStyle(Palette.text) }487 .accessibilityElement(children: .combine)488 }489490 private var pendingLabel: some View {491 Label("Saved on this device, waiting to reach the server", systemImage: "arrow.triangle.2.circlepath").font(.caption).foregroundStyle(Palette.brass)492 }493494 @ViewBuilder private var actions: some View {495 if writable {496 HStack(spacing: 10) {497 if trashed {498 Button { Task { await model.restore(view) } } label: { Label("Restore", systemImage: "arrow.uturn.backward") }.buttonStyle(.vaultPrimary).accessibilityIdentifier("detail-restore")499 Button {500 confirm = ConfirmRequest(title: "Delete permanently?", message: "“\(ItemMeta.displayTitle(item))” will be replaced by an authenticated tombstone on every device. This cannot be undone.", confirmLabel: "Delete permanently") { await model.deleteForever(view) }501 } label: { Label("Delete permanently", systemImage: "trash") }.buttonStyle(.vaultDanger).accessibilityIdentifier("detail-delete")502 } else {503 Button { sharing = true } label: { Label("Share…", systemImage: "square.and.arrow.up") }.buttonStyle(.vaultSecondary).accessibilityIdentifier("detail-share")504 let targets = model.writableVaults.filter { $0.vaultId != view.vaultId }505 if !targets.isEmpty {506 Menu {507 ForEach(targets) { v in508 Button(v.meta.name) {509 confirm = ConfirmRequest(title: "Move to “\(v.meta.name)”?", message: "The item is re-encrypted under the target vault's key and removed from this vault. Everyone with access to the target vault will be able to read it. Its revision history stays with the old vault.", confirmLabel: "Move", destructive: false) {510 await model.act("Moved to \(v.meta.name)") { model.selectedItemID = "\(v.vaultId)/\(try await model.engine.moveItem(fromVault: view.vaultId, id: view.recordId, toVault: v.vaultId))" }511 }512 }513 }514 } label: { Label("Move…", systemImage: "arrow.right.square") }515 .menuStyle(.button).buttonStyle(.vaultSecondary).fixedSize().accessibilityIdentifier("detail-move")516 }517 Spacer()518 Button { Task { await model.trash(view) } } label: { Label("Move to trash", systemImage: "trash") }.buttonStyle(.vaultDangerGhost).accessibilityIdentifier("detail-trash")519 }520 }521 } else {522 Label("This vault is read-only for you", systemImage: "eye").font(.callout).foregroundStyle(Palette.muted)523 }524 }525}526527extension AppModel {528 /// Synchronous lookup in the current snapshot (the engine's `get` is async).529 func engine_get(_ vaultId: String, _ recordId: String) -> ItemView? { items.first { $0.vaultId == vaultId && $0.recordId == recordId } }530}531