added deleteAllStickers

fix crash when the uiimage isnt valid
swift 6 in the messages extension
added fakedownloadallstickers test
added deleteallimages test
This commit is contained in:
neon443
2025-10-31 15:57:40 +00:00
parent a55c4b8c31
commit bf3ac0eb3b
4 changed files with 34 additions and 3 deletions

View File

@@ -694,7 +694,7 @@
SWIFT_APPROACHABLE_CONCURRENCY = YES; SWIFT_APPROACHABLE_CONCURRENCY = YES;
SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES; SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
SWIFT_VERSION = 5.0; SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
}; };
name = Debug; name = Debug;
@@ -726,7 +726,7 @@
SWIFT_APPROACHABLE_CONCURRENCY = YES; SWIFT_APPROACHABLE_CONCURRENCY = YES;
SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES; SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
SWIFT_VERSION = 5.0; SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES; VALIDATE_PRODUCT = YES;
}; };

View File

@@ -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() { func storeDB() {
try! encoder.encode(emojis).write(to: EmojiHoarder.localEmojiDB) try! encoder.encode(emojis).write(to: EmojiHoarder.localEmojiDB)
} }

View File

@@ -18,7 +18,7 @@ struct EmojiPreview: View {
Text(emoji.name) Text(emoji.name)
Group { Group {
if emoji.isLocal { if emoji.isLocal {
Image(uiImage: emoji.image!) Image(uiImage: emoji.image ?? UIImage())
.resizable().scaledToFit() .resizable().scaledToFit()
.border(.orange) .border(.orange)
.overlay(alignment: .bottomLeading) { .overlay(alignment: .bottomLeading) {

View File

@@ -131,4 +131,24 @@ struct PerformanceTests {
try! await doThing(on: emoji, i: &i) 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()
}
}
}
}
} }