fixed some gifs not being loaded as downloaded

-added UIName to separate the gif's slug and title
fixed downloading gifs into emoji container
This commit is contained in:
neon443 committed 2026-04-08 18:51:14 +01:00
1 parent 089adf002e
commit 6096173751
10 files changed
+42 -14

No files matched your search

+4
View File
@@ -14,6 +14,10 @@ import UniformTypeIdentifiers
struct Emoji: StickerProtocol {
var id: String
var name: String
var UIName: String {
get { name }
set { return }
}
var typeGlyph: String = "slack.logo"
var remoteImageURL: URL
+3 -1
View File
@@ -12,9 +12,9 @@ import UniformTypeIdentifiers
struct Gif: StickerProtocol {
var id: String
var name: String
var UIName: String
var typeGlyph: String = "giphy.logo"
var remoteImageURL: URL
var giphyImages: GiphyImages?
// enum CodingKeys: String, CodingKey {
@@ -23,12 +23,14 @@ struct Gif: StickerProtocol {
init(
name: String,
UIName: String,
url: URL,
giphyImages: GiphyImages?,
id: String = UUID().uuidString
) {
self.id = id
self.name = name
self.UIName = UIName
self.giphyImages = giphyImages
self.remoteImageURL = url
}
+3 -2
View File
@@ -32,8 +32,9 @@ struct GifObject: Codable, Identifiable {
var toGif: Gif {
return Gif(
name: self.title,
url: URL(string: self.images.fixed_width.url)!,
name: self.slug,
UIName: self.title,
url: URL(string: self.images.original.url)!,
giphyImages: images,
id: self.id
)
+10 -2
View File
@@ -10,10 +10,18 @@ import Messages
extension StickerProtocol {
var localImageURLString: String {
let containerPath: String
if type(of: self) == Emoji.self {
containerPath = EmojiHoarder.container.path()
} else if type(of: self) == Gif.self {
containerPath = GifHoarder.container.path()
} else {
fatalError("sticker type unrecogniesd")
}
let urlString = remoteImageURL.absoluteString
let split = urlString.split(separator: ".")
let fileExtension = ".\(split.last ?? "png")"
return EmojiHoarder.container.path()+name+"."+id+fileExtension
let fileExtension = ".\(split.last!)"
return containerPath+name+"."+id+fileExtension
}
var localImageURL: URL {
@@ -11,6 +11,7 @@ import Messages
protocol StickerProtocol: Codable, Identifiable, Hashable {
var id: String { get set }
var name: String { get set }
var UIName: String { get set }
var typeGlyph: String { get }
+16 -4
View File
@@ -31,12 +31,24 @@ struct BrowseView: View {
.ignoresSafeArea(.container, edges: .bottom)
.id(emojiHoarder.emojis)
case .giphyGifs:
ScrollView {
ForEach(gifHoarder.trendingGifs) { gif in
StickerRow(hoarder: gifHoarder, sticker: gif)
.listRowSeparator(.hidden)
Button("download all") {
Task {
for gif in gifHoarder.trendingGifs {
await gifHoarder.download(emoji: gif)
}
}
}
Button("del all") {
for gif in gifHoarder.trendingGifs {
gifHoarder.delete(emoji: gif)
}
}
List {
ForEach(gifHoarder.trendingGifs) { gif in
StickerRow(hoarder: gifHoarder, sticker: gif)
}
}
.listRowSeparator(.hidden)
}
}
}
+2 -2
View File
@@ -54,9 +54,9 @@ struct DownloadedView: View {
.aspectRatio(1, contentMode: .fit)
.clipShape(RoundedRectangle(cornerRadius: 15))
.contextMenu {
Text(emoji.name)
Text(emoji.UIName)
Button("Copy Name", systemImage: "doc.on.clipboard") {
UIPasteboard.general.string = emoji.name
UIPasteboard.general.string = emoji.UIName
}
Button("Copy Image", systemImage: "photo.fill.on.rectangle.fill") {
UIPasteboard.general.image = emoji.image
@@ -61,7 +61,7 @@ struct EmojiPackDetailView: View {
let emoji = hoarder.trie.dict[name] ?? .test
VStack {
StickerPreview(sticker: emoji)
Text(emoji.name)
Text(emoji.UIName)
.multilineTextAlignment(.center)
.font(.caption)
Spacer()
+1 -1
View File
@@ -19,7 +19,7 @@ struct StickerPreview: View {
} else if type == Gif.self {
return .giphyGifs
} else {
fatalError()
fatalError("sticker type unrecognisedd")
}
}
var body: some View {
+1 -1
View File
@@ -24,7 +24,7 @@ struct StickerRow<T: Hoarder>: View {
.transition(.scale)
VStack(alignment: .leading, spacing: 5) {
Text(sticker.name)
Text(sticker.UIName)
.font(.caption)
.bold(isDownloaded)
.foregroundColor(isDownloaded ? .green : .primary)
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.