2021-04-02 14:45:33 +02:00
|
|
|
//
|
|
|
|
// Mastodon+Entity+Account.swift
|
|
|
|
// Mastodon
|
|
|
|
//
|
|
|
|
// Created by xiaojian sun on 2021/4/2.
|
|
|
|
//
|
|
|
|
|
2021-07-07 08:55:41 +02:00
|
|
|
import UIKit
|
2021-04-02 14:45:33 +02:00
|
|
|
import MastodonSDK
|
2021-07-23 13:10:27 +02:00
|
|
|
import MastodonMeta
|
2021-04-02 14:45:33 +02:00
|
|
|
|
|
|
|
extension Mastodon.Entity.Account: Hashable {
|
|
|
|
public func hash(into hasher: inout Hasher) {
|
|
|
|
hasher.combine(id)
|
|
|
|
}
|
|
|
|
|
|
|
|
public static func == (lhs: Mastodon.Entity.Account, rhs: Mastodon.Entity.Account) -> Bool {
|
|
|
|
return lhs.id == rhs.id
|
|
|
|
}
|
|
|
|
}
|
2021-07-07 08:55:41 +02:00
|
|
|
|
|
|
|
extension Mastodon.Entity.Account {
|
|
|
|
public func avatarImageURL() -> URL? {
|
|
|
|
let string = UserDefaults.shared.preferredStaticAvatar ? avatarStatic ?? avatar : avatar
|
|
|
|
return URL(string: string)
|
|
|
|
}
|
|
|
|
|
|
|
|
public func avatarImageURLWithFallback(domain: String) -> URL {
|
|
|
|
return avatarImageURL() ?? URL(string: "https://\(domain)/avatars/original/missing.png")!
|
|
|
|
}
|
|
|
|
}
|
2021-07-23 13:10:27 +02:00
|
|
|
|
|
|
|
extension Mastodon.Entity.Account {
|
|
|
|
var emojiMeta: MastodonContent.Emojis {
|
2021-07-23 13:33:05 +02:00
|
|
|
let isAnimated = !UserDefaults.shared.preferredStaticEmoji
|
|
|
|
|
2021-07-23 13:10:27 +02:00
|
|
|
var dict = MastodonContent.Emojis()
|
|
|
|
for emoji in emojis ?? [] {
|
2021-07-23 13:33:05 +02:00
|
|
|
dict[emoji.shortcode] = isAnimated ? emoji.url : emoji.staticURL
|
2021-07-23 13:10:27 +02:00
|
|
|
}
|
|
|
|
return dict
|
|
|
|
}
|
|
|
|
}
|