Files
StickerSlack/StickerSlack/Emoji/Emoji.swift
T
neon443 91edcb6441 redid how downloaded emojis are made, abolished isLocal cos its too slow lmao
adding name to each filename so its easier to make a list of downloaded thingeis
fix using absolutestring instead of path
ts lowk fried im optimising th out of ts
2026-04-03 21:36:04 +01:00

49 lines
1.1 KiB
Swift

//
// Emoji.swift
// StickerSlack
//
// Created by neon443 on 17/10/2025.
//
import Foundation
import UIKit
import SwiftUI
import Messages
import UniformTypeIdentifiers
struct Emoji: StickerProtocol {
var id: String
var name: String
var typeGlyph: String = "slack.logo"
var localImageURLString: String {
let urlString = remoteImageURL.absoluteString
let split = urlString.split(separator: ".")
let fileExtension = ".\(split.last ?? "png")"
return EmojiHoarder.container.path()+name+"."+id+fileExtension
}
var remoteImageURL: URL
enum CodingKeys: String, CodingKey {
case id = "id"
case name = "name"
case remoteImageURL = "imageUrl"
}
init(from decoder: any Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.id = try container.decode(String.self, forKey: .id)
self.name = try container.decode(String.self, forKey: .name)
self.remoteImageURL = try container.decode(URL.self, forKey: .remoteImageURL)
}
init(
name: String,
url: URL,
id: String = UUID().uuidString
) {
self.id = id
self.name = name
self.remoteImageURL = url
}
}