add tendies file limit

This commit is contained in:
leminlimez committed 2025-06-04 04:05:04 -04:00
1 parent 04fe5329ae
commit 5bb69b5369
3 files changed
+26 -12

No files matched your search

@@ -13,6 +13,8 @@ class PosterBoardManager {
static let ShortcutURL = "https://www.icloud.com/shortcuts/a28d2c02ca11453cb5b8f91c12cfa692" static let ShortcutURL = "https://www.icloud.com/shortcuts/a28d2c02ca11453cb5b8f91c12cfa692"
static let WallpapersURL = "https://cowabun.ga/wallpapers" static let WallpapersURL = "https://cowabun.ga/wallpapers"
static let MaxTendies = 10
static func getTendiesStoreURL() -> URL { static func getTendiesStoreURL() -> URL {
let tendiesStoreURL = SymHandler.getDocumentsDirectory().appendingPathComponent("KFC Bucket", conformingTo: .directory) let tendiesStoreURL = SymHandler.getDocumentsDirectory().appendingPathComponent("KFC Bucket", conformingTo: .directory)
// create it if it doesn't exist // create it if it doesn't exist
+19 -11
View File
@@ -40,23 +40,31 @@ struct Pocket_PosterApp: App {
.onOpenURL(perform: { url in .onOpenURL(perform: { url in
// Download URL // Download URL
if url.absoluteString.starts(with: "pocketposter://download") { if url.absoluteString.starts(with: "pocketposter://download") {
downloadURL = url.absoluteString.replacingOccurrences(of: "pocketposter://download?url=", with: "") if selectedTendies.count >= PosterBoardManager.MaxTendies {
showDownloadAlert = true UIApplication.shared.alert(title: "Max Tendies Reached", body: "You can only apply \(PosterBoardManager.MaxTendies) descriptors.")
} else {
downloadURL = url.absoluteString.replacingOccurrences(of: "pocketposter://download?url=", with: "")
showDownloadAlert = true
}
} }
// App Hash URL // App Hash URL
else if url.absoluteString.starts(with: "pocketposter://app-hash?uuid=") { else if url.absoluteString.starts(with: "pocketposter://app-hash?uuid=") {
pbHash = url.absoluteString.replacingOccurrences(of: "pocketposter://app-hash?uuid=", with: "") pbHash = url.absoluteString.replacingOccurrences(of: "pocketposter://app-hash?uuid=", with: "")
} }
else if url.pathExtension == "tendies" { else if url.pathExtension == "tendies" {
// copy it over to the KFC bucket if selectedTendies.count >= PosterBoardManager.MaxTendies {
do { UIApplication.shared.alert(title: "Max Tendies Reached", body: "You can only apply \(PosterBoardManager.MaxTendies) descriptors.")
let newURL = try DownloadManager.copyTendies(from: url) } else {
selectedTendies.append(newURL) // copy it over to the KFC bucket
Haptic.shared.notify(.success) do {
UIApplication.shared.alert(title: "Successfully imported \(url.lastPathComponent)", body: "") let newURL = try DownloadManager.copyTendies(from: url)
} catch { selectedTendies.append(newURL)
Haptic.shared.notify(.error) Haptic.shared.notify(.success)
UIApplication.shared.alert(title: "Failed to import tendies", body: error.localizedDescription) UIApplication.shared.alert(title: "Successfully imported \(url.lastPathComponent)", body: "")
} catch {
Haptic.shared.notify(.error)
UIApplication.shared.alert(title: "Failed to import tendies", body: error.localizedDescription)
}
} }
} }
}) })
+5 -1
View File
@@ -130,7 +130,11 @@ struct ContentView: View {
.fileImporter(isPresented: $showTendiesImporter, allowedContentTypes: [UTType(filenameExtension: "tendies", conformingTo: .data)!], allowsMultipleSelection: true, onCompletion: { result in .fileImporter(isPresented: $showTendiesImporter, allowedContentTypes: [UTType(filenameExtension: "tendies", conformingTo: .data)!], allowsMultipleSelection: true, onCompletion: { result in
switch result { switch result {
case .success(let url): case .success(let url):
selectedTendies.wrappedValue.append(contentsOf: url) if selectedTendies.wrappedValue.count + url.count > PosterBoardManager.MaxTendies {
UIApplication.shared.alert(title: "Max Tendies Reached", body: "You can only apply \(PosterBoardManager.MaxTendies) descriptors.")
} else {
selectedTendies.wrappedValue.append(contentsOf: url)
}
case .failure(let error): case .failure(let error):
lastError = error.localizedDescription lastError = error.localizedDescription
showErrorAlert.toggle() showErrorAlert.toggle()