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 WallpapersURL = "https://cowabun.ga/wallpapers"
static let MaxTendies = 10
static func getTendiesStoreURL() -> URL {
let tendiesStoreURL = SymHandler.getDocumentsDirectory().appendingPathComponent("KFC Bucket", conformingTo: .directory)
// create it if it doesn't exist
+19 -11
View File
@@ -40,23 +40,31 @@ struct Pocket_PosterApp: App {
.onOpenURL(perform: { url in
// Download URL
if url.absoluteString.starts(with: "pocketposter://download") {
downloadURL = url.absoluteString.replacingOccurrences(of: "pocketposter://download?url=", with: "")
showDownloadAlert = true
if selectedTendies.count >= PosterBoardManager.MaxTendies {
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
else if url.absoluteString.starts(with: "pocketposter://app-hash?uuid=") {
pbHash = url.absoluteString.replacingOccurrences(of: "pocketposter://app-hash?uuid=", with: "")
}
else if url.pathExtension == "tendies" {
// copy it over to the KFC bucket
do {
let newURL = try DownloadManager.copyTendies(from: url)
selectedTendies.append(newURL)
Haptic.shared.notify(.success)
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)
if selectedTendies.count >= PosterBoardManager.MaxTendies {
UIApplication.shared.alert(title: "Max Tendies Reached", body: "You can only apply \(PosterBoardManager.MaxTendies) descriptors.")
} else {
// copy it over to the KFC bucket
do {
let newURL = try DownloadManager.copyTendies(from: url)
selectedTendies.append(newURL)
Haptic.shared.notify(.success)
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
switch result {
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):
lastError = error.localizedDescription
showErrorAlert.toggle()