mirror of
https://github.com/neon443/StickerSlack.git
synced 2026-11-30 12:44:51 +00:00
fix memory leak when emojipack some emojis that dont exist
added a refersh button
This commit is contained in:
3 files changed
+40
-24
No files matched your search
@@ -21,6 +21,8 @@ struct EmojiPackDetailView: View {
|
||||
|
||||
@State var showShare: Bool = false
|
||||
|
||||
@State var showNotFoundAlert: Bool = false
|
||||
|
||||
var allDownloaded: Bool {
|
||||
let date = Date.now
|
||||
let result = Set(pack.items).isSubset(of: hoarder.downloadedStickers)
|
||||
@@ -102,13 +104,38 @@ struct EmojiPackDetailView: View {
|
||||
LazyVGrid(columns: layout, spacing: spacing) {
|
||||
ForEach(pack.items, id: \.self) { name in
|
||||
TimelineView(.animation) { tl in
|
||||
let emoji = hoarder.trie.dict[name] ?? .test
|
||||
VStack {
|
||||
StickerPreview(sticker: emoji)
|
||||
Text(emoji.UIName)
|
||||
.multilineTextAlignment(.center)
|
||||
.font(.caption)
|
||||
Spacer()
|
||||
Group {
|
||||
VStack {
|
||||
if let emoji = hoarder.trie.dict[name] {
|
||||
StickerPreview(sticker: emoji)
|
||||
Text(emoji.UIName)
|
||||
.multilineTextAlignment(.center)
|
||||
.font(.caption)
|
||||
} else {
|
||||
Image(systemName: "questionmark.circle.dashed")
|
||||
.resizable().scaledToFit()
|
||||
.foregroundStyle(.gray.opacity(0.5))
|
||||
.overlay(alignment: .topTrailing) {
|
||||
Button {
|
||||
showNotFoundAlert.toggle()
|
||||
} label: {
|
||||
Image(systemName: "info")
|
||||
.font(.title3.bold())
|
||||
}
|
||||
}
|
||||
Text(name)
|
||||
.multilineTextAlignment(.center)
|
||||
.font(.caption)
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
.alert("This emoji was not found", isPresented: $showNotFoundAlert) {
|
||||
Button("OK") {
|
||||
showNotFoundAlert.toggle()
|
||||
}
|
||||
} message: {
|
||||
Text("Try reopening the app with an Internet connection to refresh the emoji database.")
|
||||
}
|
||||
}
|
||||
.overlay(alignment: .topLeading) {
|
||||
if edit {
|
||||
|
||||
@@ -112,6 +112,10 @@ struct SettingsView: View {
|
||||
}
|
||||
|
||||
Section("Debug") {
|
||||
Button("Refresh", systemImage: "arrow.clockwise", role: .destructive) {
|
||||
hoarder.startLoading(localOnly: false, skipIndex: false)
|
||||
}
|
||||
|
||||
NavigationLink {
|
||||
TrieTestingView(hoarder: hoarder)
|
||||
} label: {
|
||||
|
||||