Branchwell

Jotley / app · jotley.ai / iOS / Views / iOSNotesListItem.swift

1import SwiftUI
2import CoreData
3import UIKit
4
5/// Represents an item in the unified Notes list - a saved transcript note
6enum NotesListItem: Identifiable, Hashable {
7 case note(Note)
8
9 var id: String {
10 switch self {
11 case .note(let note):
12 let fallbackID = note.objectID.uriRepresentation().absoluteString
13 return "note-\(note.id?.uuidString ?? fallbackID)"
14 }
15 }
16
17 var date: Date {
18 switch self {
19 case .note(let note):
20 return note.timestamp ?? Date()
21 }
22 }
23
24 static func == (lhs: NotesListItem, rhs: NotesListItem) -> Bool {
25 lhs.id == rhs.id
26 }
27
28 func hash(into hasher: inout Hasher) {
29 hasher.combine(id)
30 }
31}