// Whether the Bin is a tile on Home in the database this phone shows // (a bin's list — the table with `binned` — among Home's views). // // The words of a delete follow it (mini RJ11 sev 2): while the Bin is no tile // on Home it is not a thing on this phone, so a delete's question never sends the // person to "the bin"; it says where the record waits instead — under // "Deleted" at the end of its own list, the way back where the record was. // The core words the receipt the same way (`receipt::binned_said`). // // Kept here, not on a view: the question is asked from lists, pages, Select // and groups, none of which holds Home. Home's read sets it. import Foundation public enum BinShelf { private static let lock = NSLock() nonisolated(unsafe) private static var onHome = false /// Whether the Bin is on Home. False until Home's first read says /// otherwise — the default a new database has. public static var shown: Bool { get { lock.withLock { onHome } } set { lock.withLock { onHome = newValue } } } /// Set from a read of Home's tiles: whether a bin's list — a table whose /// rows stand for binned records (`binned`) — is one of them. public static func read(tiles: HomeTiles, definitions: [TableDefinition]) { shown = definitions.contains { $0.binned != nil && tiles.shows(HomeTiles.view(ofTool: $0.id)) } } /// Where a deleted record with no list of its own waits (a group, a /// conversation): the bin, which while no tile on Home is reached from Tools. public static var elsewhere: String { ShellLines.line("bin", shown ? "elsewhere.shown" : "elsewhere.hidden") } /// Where a deleted record of `plural` waits, said under the question. public static func sentence(count: Int, plural: String) -> String { let reach = shown ? "shown" : "hidden" let number = count == 1 ? "one" : "many" return ShellLines.line("bin", "deleted." + reach + "." + number, ["plural": plural]) } }