From a1a15c9cb8e24ad0f34d3928da9d2c157f5095f7 Mon Sep 17 00:00:00 2001 From: neon443 <69979447+neon443@users.noreply.github.com> Date: Fri, 31 Oct 2025 16:23:05 +0000 Subject: [PATCH] added a delete all images button some other stuff --- StickerSlack.xcodeproj/project.pbxproj | 4 ++-- StickerSlack/Emoji/Emoji.swift | 1 + StickerSlack/Views/ContentView.swift | 6 ++++++ StickerSlackTests/StickerSlackTests.swift | 16 +++++++--------- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/StickerSlack.xcodeproj/project.pbxproj b/StickerSlack.xcodeproj/project.pbxproj index 50fa07c..9c2c14e 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 = 6.0; + SWIFT_VERSION = 5.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 = 6.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; diff --git a/StickerSlack/Emoji/Emoji.swift b/StickerSlack/Emoji/Emoji.swift index 4ed7c3c..20ee777 100644 --- a/StickerSlack/Emoji/Emoji.swift +++ b/StickerSlack/Emoji/Emoji.swift @@ -81,6 +81,7 @@ struct Emoji: Codable, Identifiable, Hashable { try? FileManager.default.removeItem(at: localImageURL) } + @MainActor mutating func refresh() { withAnimation { self.uiID = UUID() } } diff --git a/StickerSlack/Views/ContentView.swift b/StickerSlack/Views/ContentView.swift index 7b4cb97..9cbc014 100644 --- a/StickerSlack/Views/ContentView.swift +++ b/StickerSlack/Views/ContentView.swift @@ -36,6 +36,12 @@ struct ContentView: View { hoarder.filterEmojis(byCategory: .notDownloaded, searchTerm: searchTerm) } + Button("delete all images") { + Task.detached { + await hoarder.deleteAllStickers() + } + } + Text("\(hoarder.filteredEmojis.count) Emoji") ForEach($hoarder.filteredEmojis, id: \.self) { $emoji in diff --git a/StickerSlackTests/StickerSlackTests.swift b/StickerSlackTests/StickerSlackTests.swift index 25874ea..bad92ed 100644 --- a/StickerSlackTests/StickerSlackTests.swift +++ b/StickerSlackTests/StickerSlackTests.swift @@ -47,9 +47,12 @@ struct StickerSlackTests { @Test func deleteAllEmojis() async throws { await withDiscardingTaskGroup { group in - for emoji in hoarder.emojis { + for i in hoarder.emojis.indices { group.addTask { - emoji.deleteImage() + hoarder.emojis[i].deleteImage() + await MainActor.run { + hoarder.emojis[i].refresh() + } } } } @@ -143,12 +146,7 @@ struct PerformanceTests { } @Test func deleteAllImages() async throws { - await withDiscardingTaskGroup { group in - for emoji in hoarder.emojis { - group.addTask { - emoji.deleteImage() - } - } - } + try! await fakeDownloadAllStickers() + await hoarder.deleteAllStickers() } }