add tendies file limit
This commit is contained in:
1 parent
04fe5329ae
commit
5bb69b5369
3 files changed
+14
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
|
||||
|
||||
@@ -40,14 +40,21 @@ struct Pocket_PosterApp: App {
|
||||
.onOpenURL(perform: { url in
|
||||
// Download URL
|
||||
if url.absoluteString.starts(with: "pocketposter://download") {
|
||||
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" {
|
||||
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)
|
||||
@@ -59,6 +66,7 @@ struct Pocket_PosterApp: App {
|
||||
UIApplication.shared.alert(title: "Failed to import tendies", body: error.localizedDescription)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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):
|
||||
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()
|
||||
|
||||
Reference in new issue
Block a user