From 3c868c606b84787fc6670e3d01e99606aeea08c5 Mon Sep 17 00:00:00 2001 From: Nihaal Sharma <69979447+neon443@users.noreply.github.com> Date: Tue, 10 Mar 2026 01:15:12 +0000 Subject: [PATCH] added a protocol for hoarders --- StickerSlack.xcodeproj/project.pbxproj | 6 ++++++ StickerSlack/Emoji/EmojiHoarder.swift | 7 ++----- StickerSlack/Gifs/GifHoarder.swift | 6 ++++++ StickerSlack/Hoarder.swift | 27 ++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 StickerSlack/Hoarder.swift diff --git a/StickerSlack.xcodeproj/project.pbxproj b/StickerSlack.xcodeproj/project.pbxproj index 50af511..1bc7e1a 100644 --- a/StickerSlack.xcodeproj/project.pbxproj +++ b/StickerSlack.xcodeproj/project.pbxproj @@ -77,6 +77,8 @@ A9BE30FA2F5B03F400A57668 /* Sticker.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9BE30F92F5B03F400A57668 /* Sticker.swift */; }; A9BE30FB2F5B03F400A57668 /* Sticker.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9BE30F92F5B03F400A57668 /* Sticker.swift */; }; A9BE30FC2F5B03F400A57668 /* Sticker.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9BE30F92F5B03F400A57668 /* Sticker.swift */; }; + A9BE30FE2F5FA47100A57668 /* Hoarder.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9BE30FD2F5FA47100A57668 /* Hoarder.swift */; }; + A9BE30FF2F5FA78E00A57668 /* Hoarder.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9BE30FD2F5FA47100A57668 /* Hoarder.swift */; }; A9C172DC2EB8C9AC008A7885 /* Trie.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C172DB2EB8C9AC008A7885 /* Trie.swift */; }; A9C172DD2EB8C9AC008A7885 /* Trie.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C172DB2EB8C9AC008A7885 /* Trie.swift */; }; A9CD6C352EDDE22800B7F421 /* EmojiPackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9CD6C342EDDE22800B7F421 /* EmojiPackView.swift */; }; @@ -168,6 +170,7 @@ A9BE30F12F5B004E00A57668 /* Gif.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Gif.swift; sourceTree = ""; }; A9BE30F52F5B011A00A57668 /* StickerProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StickerProtocol.swift; sourceTree = ""; }; A9BE30F92F5B03F400A57668 /* Sticker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Sticker.swift; sourceTree = ""; }; + A9BE30FD2F5FA47100A57668 /* Hoarder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Hoarder.swift; sourceTree = ""; }; A9C172DB2EB8C9AC008A7885 /* Trie.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Trie.swift; sourceTree = ""; }; A9CD6C342EDDE22800B7F421 /* EmojiPackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiPackView.swift; sourceTree = ""; }; A9CD6C372EDDE37500B7F421 /* EmojiPackManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmojiPackManager.swift; sourceTree = ""; }; @@ -324,6 +327,7 @@ A9104C812EB4022E00D160EA /* Extensions */, A91C098E2EBBD7C700210C34 /* UIKit */, A91C098D2EBBD7C100210C34 /* SwiftUI */, + A9BE30FD2F5FA47100A57668 /* Hoarder.swift */, ); path = StickerSlack; sourceTree = ""; @@ -571,6 +575,7 @@ A9BE30F02F5B004800A57668 /* GifHoarder.swift in Sources */, A9BE30F22F5B004E00A57668 /* Gif.swift in Sources */, A9BE30EC2F5AFE1E00A57668 /* StickerType.swift in Sources */, + A9BE30FE2F5FA47100A57668 /* Hoarder.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -585,6 +590,7 @@ A9EB724B2EB94A5700658CEB /* Trie.swift in Sources */, A9BE30FA2F5B03F400A57668 /* Sticker.swift in Sources */, A986A6CD2EB659E000B6E0FA /* MessagesViewController.swift in Sources */, + A9BE30FF2F5FA78E00A57668 /* Hoarder.swift in Sources */, A986A6CE2EB659E000B6E0FA /* StickerBrowserDataSource.swift in Sources */, A957C17E2ECFAA1100EA3EE9 /* GifView.swift in Sources */, A9BBC5192EB8FA4500FFE82F /* ViewModifiers.swift in Sources */, diff --git a/StickerSlack/Emoji/EmojiHoarder.swift b/StickerSlack/Emoji/EmojiHoarder.swift index 1852867..17159e6 100644 --- a/StickerSlack/Emoji/EmojiHoarder.swift +++ b/StickerSlack/Emoji/EmojiHoarder.swift @@ -11,14 +11,11 @@ import Combine import UniformTypeIdentifiers import Haptics -class EmojiHoarder: ObservableObject { - static let container = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.com.neon443.StickerSlack")!.appendingPathComponent("Library", conformingTo: .directory) +class EmojiHoarder: Hoarder, ObservableObject { nonisolated static let localEmojiDB: URL = EmojiHoarder.container.appendingPathComponent("_localEmojiDB.json", conformingTo: .fileURL) nonisolated static let localTrie: URL = EmojiHoarder.container.appendingPathComponent("_localTrie.json", conformingTo: .fileURL) nonisolated static let localTrieDict: URL = EmojiHoarder.container.appendingPathComponent("_localTrieDict.json", conformingTo: .fileURL) - private let endpoint: URL = URL(string: "https://cachet.dunkirk.sh/emojis")! - private let encoder = JSONEncoder() - private let decoder = JSONDecoder() + let endpoint: URL = URL(string: "https://cachet.dunkirk.sh/emojis")! @Published var emojis: [Emoji] = [] @Published var emojiPacks: [EmojiPack] = [] diff --git a/StickerSlack/Gifs/GifHoarder.swift b/StickerSlack/Gifs/GifHoarder.swift index 4434518..febe1a6 100644 --- a/StickerSlack/Gifs/GifHoarder.swift +++ b/StickerSlack/Gifs/GifHoarder.swift @@ -6,3 +6,9 @@ // import Foundation +import SwiftUI +import Combine + +//class GifHoarder: Hoarder { +// +//} diff --git a/StickerSlack/Hoarder.swift b/StickerSlack/Hoarder.swift new file mode 100644 index 0000000..c1947d2 --- /dev/null +++ b/StickerSlack/Hoarder.swift @@ -0,0 +1,27 @@ +// +// Hoarder.swift +// StickerSlack +// +// Created by neon443 on 10/03/2026. +// + +import Foundation +import SwiftUI +import Combine +import UniformTypeIdentifiers + +protocol Hoarder { + static var container: URL { get } + var endpoint: URL { get } + var encoder: JSONEncoder { get } + var decoder: JSONDecoder { get } + var searchTerm: String { get set } +} + +extension Hoarder { + static var container: URL { FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.com.neon443.StickerSlack")!.appendingPathComponent("Library", conformingTo: .directory) + } + + var encoder: JSONEncoder { JSONEncoder() } + var decoder: JSONDecoder { JSONDecoder() } +}