2022-04-14 15:15:21 +02:00
|
|
|
//
|
|
|
|
// ProfileCardView+Configuration.swift
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Created by MainasuK on 2022-4-14.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import Combine
|
|
|
|
import CoreDataStack
|
|
|
|
import Meta
|
2022-10-08 07:43:06 +02:00
|
|
|
import MastodonCore
|
2022-04-14 15:15:21 +02:00
|
|
|
import MastodonMeta
|
2022-05-16 13:42:03 +02:00
|
|
|
import MastodonSDK
|
2022-04-14 15:15:21 +02:00
|
|
|
|
|
|
|
extension ProfileCardView {
|
|
|
|
|
2023-11-20 13:51:20 +01:00
|
|
|
public func configure(account: Mastodon.Entity.Account, relationship: Mastodon.Entity.Relationship?) {
|
2023-11-17 14:48:23 +01:00
|
|
|
viewModel.authorBannerImageURL = URL(string: account.header)
|
2023-11-20 12:27:10 +01:00
|
|
|
viewModel.statusesCount = account.statusesCount
|
|
|
|
viewModel.followingCount = account.followingCount
|
|
|
|
viewModel.followersCount = account.followersCount
|
|
|
|
viewModel.authorAvatarImageURL = account.avatarImageURL()
|
|
|
|
|
|
|
|
let emojis = account.emojis?.asDictionary ?? [:]
|
|
|
|
|
2023-11-17 14:48:23 +01:00
|
|
|
do {
|
2023-11-20 12:27:10 +01:00
|
|
|
let content = MastodonContent(content: account.displayNameWithFallback, emojis: emojis)
|
2023-11-17 14:48:23 +01:00
|
|
|
let metaContent = try MastodonMetaContent.convert(document: content)
|
|
|
|
viewModel.authorName = metaContent
|
|
|
|
} catch {
|
|
|
|
assertionFailure(error.localizedDescription)
|
|
|
|
let metaContent = PlaintextMetaContent(string: account.displayNameWithFallback)
|
|
|
|
viewModel.authorName = metaContent
|
|
|
|
}
|
|
|
|
|
2023-11-20 12:27:10 +01:00
|
|
|
viewModel.authorUsername = account.acct
|
2023-11-17 14:48:23 +01:00
|
|
|
|
2023-11-20 12:27:10 +01:00
|
|
|
do {
|
|
|
|
let content = MastodonContent(content: account.note, emojis: emojis)
|
|
|
|
let metaContent = try MastodonMetaContent.convert(document: content)
|
|
|
|
viewModel.bioContent = metaContent
|
|
|
|
} catch {
|
|
|
|
assertionFailure(error.localizedDescription)
|
|
|
|
let metaContent = PlaintextMetaContent(string: account.note)
|
|
|
|
viewModel.bioContent = metaContent
|
2022-04-14 15:15:21 +02:00
|
|
|
}
|
2023-11-20 13:51:20 +01:00
|
|
|
|
|
|
|
updateButtonState(with: relationship, isMe: false)
|
2022-04-14 15:15:21 +02:00
|
|
|
}
|
|
|
|
}
|