Folders can now contain other folders, arbitrarily deep — e.g. "Work" containing "Project A"/"Project B". v10 migration adds a self-referencing parentId column; tree ordering, depth, and cycle detection are pure Swift (Folder.orderedTree/isDescendant/ visibleFolderIds), not SQL, so listFolders() stays a simple flat query. - Create nested folders via "New Subfolder…" (context menu, both list views) or by dragging a folder onto another to reparent it. Dragging onto an existing descendant is rejected (cycle guard). - Deleting a folder reparents its children and any conversations filed directly in it up one level to the deleted folder's own parent — conversations are never deleted. This also fixes a real bug: the previous deleteFolder never persisted unfiling to the database, only patched in-memory state, so a conversation whose folder was deleted kept a dangling folderId and silently vanished from view after the next relaunch. - All "Move to Folder" pickers (sidebar, advanced list, per-row context menus, the Save dialog's folder popup) show an indented flat list reflecting the tree. - New DraggedItem enum disambiguates a dragged folder from dragged conversation(s) in the shared string-based drag payload, and unifies both list views on the same bundled-multi-selection format — closes a gap where dragging a multi-selection in the advanced list (⌘L) only moved the one row grabbed, unlike the sidebar. Confirmed working live, including relaunch-survival of the delete/reparent fix.
52 lines
1.9 KiB
Swift
52 lines
1.9 KiB
Swift
//
|
|
// DraggedItem.swift
|
|
// Confab
|
|
//
|
|
// Drag-and-drop payload wire format for the conversation lists
|
|
//
|
|
// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0
|
|
// Copyright (C) 2026 Rune Olsen
|
|
//
|
|
// This file is part of Confab.
|
|
//
|
|
// Confab is licensed under the PolyForm Noncommercial License 1.0.0.
|
|
// You may use, study, modify, and share it for any noncommercial
|
|
// purpose. Commercial use — including selling Confab or any part of
|
|
// it, standalone or bundled into another product or service —
|
|
// requires a separate commercial license from the copyright holder.
|
|
//
|
|
// See the LICENSE file or
|
|
// <https://polyformproject.org/licenses/noncommercial/1.0.0> for
|
|
// the full license text. For commercial licensing, contact Rune
|
|
// Olsen via <https://oai.pm>.
|
|
|
|
import Foundation
|
|
|
|
/// Disambiguates what's being dragged in the sidebar/advanced-list conversation trees, now that
|
|
/// both conversations and folders are draggable. `.conversations` carries one or more IDs — a
|
|
/// single drag, or every ID in an active multi-selection bundled together so dropping any one of
|
|
/// them moves the whole selection.
|
|
enum DraggedItem: Equatable {
|
|
case conversations([UUID])
|
|
case folder(UUID)
|
|
|
|
var rawValue: String {
|
|
switch self {
|
|
case .conversations(let ids): return "conversation:" + ids.map(\.uuidString).joined(separator: ",")
|
|
case .folder(let id): return "folder:\(id.uuidString)"
|
|
}
|
|
}
|
|
|
|
init?(rawValue: String) {
|
|
if rawValue.hasPrefix("conversation:") {
|
|
let ids = rawValue.dropFirst(13).split(separator: ",").compactMap { UUID(uuidString: String($0)) }
|
|
guard !ids.isEmpty else { return nil }
|
|
self = .conversations(ids)
|
|
} else if rawValue.hasPrefix("folder:"), let id = UUID(uuidString: String(rawValue.dropFirst(7))) {
|
|
self = .folder(id)
|
|
} else {
|
|
return nil
|
|
}
|
|
}
|
|
}
|