summaryrefslogtreecommitdiff
path: root/Sora
diff options
context:
space:
mode:
authorFuwn <[email protected]>2025-06-09 06:02:59 -0700
committerFuwn <[email protected]>2025-06-09 06:02:59 -0700
commit3464cb6f80aeae2d0ac45e0e03f9f4eeef7d7f03 (patch)
tree6eaba27dd2f26fa1050786e8d1b9b9e71fbab18f /Sora
parentfeat: Development commit (diff)
downloadsora-testing-3464cb6f80aeae2d0ac45e0e03f9f4eeef7d7f03.tar.xz
sora-testing-3464cb6f80aeae2d0ac45e0e03f9f4eeef7d7f03.zip
feat: Development commit
Diffstat (limited to 'Sora')
-rw-r--r--Sora/Views/Generic/GenericListView.swift27
1 files changed, 25 insertions, 2 deletions
diff --git a/Sora/Views/Generic/GenericListView.swift b/Sora/Views/Generic/GenericListView.swift
index 1d44e15..93b141b 100644
--- a/Sora/Views/Generic/GenericListView.swift
+++ b/Sora/Views/Generic/GenericListView.swift
@@ -9,6 +9,8 @@ struct GenericListView<T: Identifiable & Hashable & GenericItem>: View {
@Binding var isPresented: Bool
@State private var isNewCollectionAlertPresented = false
@State private var newCollectionName = ""
+ @State private var itemPendingCollectionAssignment: UUID?
+ @State private var isCollectionErrorAlertPresented = false
let allowBookmarking: Bool
let title: String
let emptyMessage: String
@@ -91,11 +93,31 @@ struct GenericListView<T: Identifiable & Hashable & GenericItem>: View {
}
Button("Create") {
- settings.folders.append(SettingsFolder(name: newCollectionName))
+ if newCollectionName.isEmpty {
+ isCollectionErrorAlertPresented = true
+ } else {
+ let newFolder = SettingsFolder(name: newCollectionName)
- isNewCollectionAlertPresented = false
+ settings.folders.append(newFolder)
+
+ if let id = itemPendingCollectionAssignment {
+ settings.updateBookmarkFolder(withID: id, folder: newFolder)
+ }
+
+ itemPendingCollectionAssignment = nil
+ newCollectionName = ""
+ isNewCollectionAlertPresented = false
+ }
}
}
+ .alert(
+ "Error",
+ isPresented: $isCollectionErrorAlertPresented,
+ ) {
+ Button("OK", role: .cancel) { () }
+ } message: {
+ Text("Collection name cannot be empty.")
+ }
}
func itemButtonContent(item: T) -> some View {
@@ -140,6 +162,7 @@ struct GenericListView<T: Identifiable & Hashable & GenericItem>: View {
}
Button(action: {
+ itemPendingCollectionAssignment = item.id
isNewCollectionAlertPresented = true
}) {
Label("New Collection", systemImage: "plus")