1
0
mirror of https://github.com/mastodon/mastodon-ios.git synced 2024-12-14 01:26:05 +01:00
mastodon-app-ufficiale-ipho.../MastodonSDK/Sources/MastodonCore/Service/Emoji/EmojiService.swift

46 lines
1.2 KiB
Swift
Raw Normal View History

2021-03-15 07:40:10 +01:00
//
// EmojiService.swift
// Mastodon
//
// Created by MainasuK Cirno on 2021-3-15.
//
import Foundation
import Combine
import MastodonSDK
public final class EmojiService {
2021-03-15 07:40:10 +01:00
weak var apiService: APIService?
let workingQueue = DispatchQueue(label: "org.joinmastodon.app.EmojiService.working-queue")
private(set) var customEmojiViewModelDict: [String: CustomEmojiViewModel] = [:]
2021-03-15 07:40:10 +01:00
init(apiService: APIService) {
self.apiService = apiService
}
}
extension EmojiService {
2022-10-08 07:43:06 +02:00
public func dequeueCustomEmojiViewModel(for domain: String) -> CustomEmojiViewModel? {
var _customEmojiViewModel: CustomEmojiViewModel?
workingQueue.sync {
if let viewModel = customEmojiViewModelDict[domain] {
_customEmojiViewModel = viewModel
} else {
let viewModel = CustomEmojiViewModel(domain: domain, service: self)
_customEmojiViewModel = viewModel
// trigger loading
viewModel.stateMachine.enter(CustomEmojiViewModel.LoadState.Loading.self)
}
}
return _customEmojiViewModel
}
2021-03-15 07:40:10 +01:00
}