Repository Public
1// SP Notes iOS2// File: Features/Notes/PageKind.swift3// Description: The kind of a page, typed once (1.0 compared the `type` string in four places). A page the app does not know is4// `.other`: listed and opened read-only-safe as a note, never dropped.5//6// Author: Simon-Pierre Boucher7// Contact: contact@spboucher.ai8import SPNotesCore910enum PageKind: Equatable, Sendable {11 /// A note (server types `page` and `research`: both hold a document the editor edits).12 case note13 /// A page used as a folder (`properties.folder`).14 case folder15 case database16 /// 3.0: a page whose body is an infinite canvas.17 case canvas18 /// A type introduced after this build.19 case other(String)2021 init(type: String, isFolder: Bool = false) {22 if isFolder { self = .folder; return }23 switch type {24 case "page", "research", "": self = .note25 case "database": self = .database26 case "canvas": self = .canvas27 default: self = .other(type)28 }29 }3031 /// A page whose body is a document the native editor shows.32 var hasDocument: Bool {33 switch self {34 case .note, .other: return true35 case .folder, .database, .canvas: return false36 }37 }3839 /// Something a note can link to and a list of notes shows as a note (1.0 rule: everything but folders and databases).40 var isLinkable: Bool { self != .database && self != .folder }41}4243extension PageSummary {44 var kind: PageKind { PageKind(type: type, isFolder: isFolder) }45}4647extension PageRecord {48 /// The kind by type alone (a folder page is a `page` with a property; lists use `PageSummary.kind`).49 var kind: PageKind { PageKind(type: type) }50}51