diff --git a/StickerSlack.xcodeproj/project.pbxproj b/StickerSlack.xcodeproj/project.pbxproj index 9c2c14e..50fa07c 100644 --- a/StickerSlack.xcodeproj/project.pbxproj +++ b/StickerSlack.xcodeproj/project.pbxproj @@ -694,7 +694,7 @@ SWIFT_APPROACHABLE_CONCURRENCY = YES; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = 6.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -726,7 +726,7 @@ SWIFT_APPROACHABLE_CONCURRENCY = YES; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = 6.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; diff --git a/StickerSlack/EmojiHoarder.swift b/StickerSlack/EmojiHoarder.swift index 629b7b5..7414e40 100644 --- a/StickerSlack/EmojiHoarder.swift +++ b/StickerSlack/EmojiHoarder.swift @@ -37,6 +37,17 @@ class EmojiHoarder: ObservableObject { } } + func deleteAllStickers() async { + await withTaskGroup { group in + for emoji in emojis { + group.addTask { + guard await emoji.isLocal else { return } + await emoji.deleteImage() + } + } + } + } + func storeDB() { try! encoder.encode(emojis).write(to: EmojiHoarder.localEmojiDB) } diff --git a/StickerSlack/Views/EmojiPreview.swift b/StickerSlack/Views/EmojiPreview.swift index e877737..535d0c0 100644 --- a/StickerSlack/Views/EmojiPreview.swift +++ b/StickerSlack/Views/EmojiPreview.swift @@ -18,7 +18,7 @@ struct EmojiPreview: View { Text(emoji.name) Group { if emoji.isLocal { - Image(uiImage: emoji.image!) + Image(uiImage: emoji.image ?? UIImage()) .resizable().scaledToFit() .border(.orange) .overlay(alignment: .bottomLeading) { diff --git a/StickerSlackTests/StickerSlackTests.swift b/StickerSlackTests/StickerSlackTests.swift index eb8d3be..25874ea 100644 --- a/StickerSlackTests/StickerSlackTests.swift +++ b/StickerSlackTests/StickerSlackTests.swift @@ -131,4 +131,24 @@ struct PerformanceTests { try! await doThing(on: emoji, i: &i) } } + + @Test func fakeDownloadAllStickers() async throws { + await withDiscardingTaskGroup { group in + for emoji in hoarder.emojis { + group.addTask { + try! Data().write(to: emoji.localImageURL) + } + } + } + } + + @Test func deleteAllImages() async throws { + await withDiscardingTaskGroup { group in + for emoji in hoarder.emojis { + group.addTask { + emoji.deleteImage() + } + } + } + } }