added a delete all images button

some other stuff
This commit is contained in:
neon443
2025-10-31 16:23:05 +00:00
parent bf3ac0eb3b
commit a1a15c9cb8
4 changed files with 16 additions and 11 deletions

View File

@@ -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;
};

View File

@@ -81,6 +81,7 @@ struct Emoji: Codable, Identifiable, Hashable {
try? FileManager.default.removeItem(at: localImageURL)
}
@MainActor
mutating func refresh() {
withAnimation { self.uiID = UUID() }
}

View File

@@ -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

View File

@@ -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()
}
}