mirror of
https://github.com/mastodon/mastodon-ios.git
synced 2025-02-01 09:57:21 +01:00
Emojis aren't optional (IOS-192)
meet []
This commit is contained in:
parent
c3d40d260d
commit
6b6ed28134
@ -22,7 +22,7 @@ extension ProfileCardView {
|
||||
viewModel.followersCount = account.followersCount
|
||||
viewModel.authorAvatarImageURL = account.avatarImageURL()
|
||||
|
||||
let emojis = account.emojis?.asDictionary ?? [:]
|
||||
let emojis = account.emojis.asDictionary
|
||||
|
||||
do {
|
||||
let content = MastodonContent(content: account.displayNameWithFallback, emojis: emojis)
|
||||
|
@ -26,7 +26,7 @@ extension UserView {
|
||||
authorUsernameLabel.configure(content: authorUsername)
|
||||
|
||||
do {
|
||||
let emojis = account.emojis?.asDictionary ?? [:]
|
||||
let emojis = account.emojis.asDictionary
|
||||
let content = MastodonContent(content: account.displayNameWithFallback, emojis: emojis)
|
||||
let metaContent = try MastodonMetaContent.convert(document: content)
|
||||
authorNameLabel.configure(content: metaContent)
|
||||
|
@ -91,7 +91,7 @@ final class SuggestionAccountTableViewCell: UITableViewCell {
|
||||
|
||||
let metaContent: MetaContent = {
|
||||
do {
|
||||
let mastodonContent = MastodonContent(content: account.note, emojis: account.emojis?.asDictionary ?? [:])
|
||||
let mastodonContent = MastodonContent(content: account.note, emojis: account.emojis.asDictionary)
|
||||
return try MastodonMetaContent.convert(document: mastodonContent)
|
||||
} catch {
|
||||
assertionFailure()
|
||||
|
@ -76,7 +76,7 @@ class ThreadViewModel {
|
||||
// bind titleView
|
||||
self.navigationBarTitle = {
|
||||
let title = L10n.Scene.Thread.title(status.entity.account.displayNameWithFallback)
|
||||
let content = MastodonContent(content: title, emojis: status.entity.account.emojis?.asDictionary ?? [:])
|
||||
let content = MastodonContent(content: title, emojis: status.entity.account.emojis.asDictionary)
|
||||
return try? MastodonMetaContent.convert(document: content)
|
||||
}()
|
||||
}
|
||||
|
@ -11,14 +11,12 @@ import MastodonSDK
|
||||
import CoreDataStack
|
||||
|
||||
public protocol MastodonEmojiContainer {
|
||||
var emojis: [Mastodon.Entity.Emoji]? { get }
|
||||
var emojis: [Mastodon.Entity.Emoji] { get }
|
||||
}
|
||||
|
||||
extension MastodonEmojiContainer {
|
||||
public var mastodonEmojis: [MastodonEmoji] {
|
||||
return emojis.flatMap { emojis in
|
||||
emojis.map { MastodonEmoji(emoji: $0) }
|
||||
} ?? []
|
||||
return emojis.map { MastodonEmoji(emoji: $0) }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ extension Mastodon.Entity {
|
||||
public let header: String
|
||||
public let headerStatic: String?
|
||||
public let locked: Bool
|
||||
public let emojis: [Emoji]?
|
||||
public let emojis: [Emoji]
|
||||
public let discoverable: Bool?
|
||||
|
||||
// Statistical
|
||||
@ -52,7 +52,7 @@ extension Mastodon.Entity {
|
||||
public let suspended: Bool?
|
||||
public let muteExpiresAt: Date?
|
||||
|
||||
internal init(id: Mastodon.Entity.Account.ID, username: String, acct: String, url: String, displayName: String, note: String, avatar: String, avatarStatic: String? = nil, header: String, headerStatic: String? = nil, locked: Bool, emojis: [Mastodon.Entity.Emoji]? = nil, discoverable: Bool? = nil, createdAt: Date, lastStatusAt: Date? = nil, statusesCount: Int, followersCount: Int, followingCount: Int, moved: Mastodon.Entity.Account? = nil, fields: [Mastodon.Entity.Field]? = nil, bot: Bool? = nil, source: Mastodon.Entity.Source? = nil, suspended: Bool? = nil, muteExpiresAt: Date? = nil) {
|
||||
internal init(id: Mastodon.Entity.Account.ID, username: String, acct: String, url: String, displayName: String, note: String, avatar: String, avatarStatic: String? = nil, header: String, headerStatic: String? = nil, locked: Bool, emojis: [Mastodon.Entity.Emoji] = [], discoverable: Bool? = nil, createdAt: Date, lastStatusAt: Date? = nil, statusesCount: Int, followersCount: Int, followingCount: Int, moved: Mastodon.Entity.Account? = nil, fields: [Mastodon.Entity.Field]? = nil, bot: Bool? = nil, source: Mastodon.Entity.Source? = nil, suspended: Bool? = nil, muteExpiresAt: Date? = nil) {
|
||||
self.id = id
|
||||
self.username = username
|
||||
self.acct = acct
|
||||
|
@ -37,8 +37,8 @@ extension Mastodon.Entity {
|
||||
|
||||
// Rendering
|
||||
public let mentions: [Mention]?
|
||||
public let tags: [Tag]?
|
||||
public let emojis: [Emoji]?
|
||||
public let tags: [Tag]
|
||||
public let emojis: [Emoji]
|
||||
|
||||
// Informational
|
||||
public let reblogsCount: Int
|
||||
|
@ -36,7 +36,7 @@ extension Mastodon.Entity {
|
||||
public let account: Account
|
||||
public let poll: Poll?
|
||||
public let mediaAttachments: [Attachment]?
|
||||
public let emojis: [Emoji]?
|
||||
public let emojis: [Emoji]
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case content
|
||||
|
@ -127,7 +127,7 @@ public class CondensedUserView: UIView {
|
||||
public func configure(with account: Mastodon.Entity.Account, showFollowers: Bool = true) {
|
||||
let displayNameMetaContent: MetaContent
|
||||
do {
|
||||
let content = MastodonContent(content: account.displayNameWithFallback, emojis: account.emojis?.asDictionary ?? [:])
|
||||
let content = MastodonContent(content: account.displayNameWithFallback, emojis: account.emojis.asDictionary)
|
||||
displayNameMetaContent = try MastodonMetaContent.convert(document: content)
|
||||
} catch {
|
||||
displayNameMetaContent = PlaintextMetaContent(string: account.displayNameWithFallback)
|
||||
|
@ -157,7 +157,7 @@ extension StatusView {
|
||||
statusID: inReplyToID,
|
||||
authorization: authenticationBox.userAuthorization
|
||||
).singleOutput().value {
|
||||
let header = createHeader(name: replyTo.account.displayNameWithFallback, emojis: replyTo.account.emojis?.asDictionary ?? [:])
|
||||
let header = createHeader(name: replyTo.account.displayNameWithFallback, emojis: replyTo.account.emojis.asDictionary)
|
||||
viewModel.header = header
|
||||
}
|
||||
}
|
||||
@ -200,7 +200,7 @@ extension StatusView {
|
||||
|
||||
// author avatar
|
||||
viewModel.authorAvatarImageURL = author.avatarImageURL()
|
||||
let emojis = author.emojis?.asDictionary ?? [:]
|
||||
let emojis = author.emojis.asDictionary
|
||||
|
||||
// author name
|
||||
viewModel.authorName = {
|
||||
@ -282,7 +282,7 @@ extension StatusView {
|
||||
|
||||
// content
|
||||
do {
|
||||
let content = MastodonContent(content: translatedContent, emojis: status.entity.emojis?.asDictionary ?? [:])
|
||||
let content = MastodonContent(content: translatedContent, emojis: status.entity.emojis.asDictionary)
|
||||
let metaContent = try MastodonMetaContent.convert(document: content)
|
||||
viewModel.content = metaContent
|
||||
viewModel.isCurrentlyTranslating = false
|
||||
@ -301,7 +301,7 @@ extension StatusView {
|
||||
viewModel.language = (status.reblog ?? status).entity.language
|
||||
// content
|
||||
do {
|
||||
let content = MastodonContent(content: statusEdit.content, emojis: statusEdit.emojis?.asDictionary ?? [:])
|
||||
let content = MastodonContent(content: statusEdit.content, emojis: statusEdit.emojis.asDictionary)
|
||||
let metaContent = try MastodonMetaContent.convert(document: content)
|
||||
viewModel.content = metaContent
|
||||
viewModel.isCurrentlyTranslating = false
|
||||
@ -321,7 +321,7 @@ extension StatusView {
|
||||
// spoilerText
|
||||
if let spoilerText = status.entity.spoilerText, !spoilerText.isEmpty {
|
||||
do {
|
||||
let content = MastodonContent(content: spoilerText, emojis: status.entity.emojis?.asDictionary ?? [:])
|
||||
let content = MastodonContent(content: spoilerText, emojis: status.entity.emojis.asDictionary)
|
||||
let metaContent = try MastodonMetaContent.convert(document: content)
|
||||
viewModel.spoilerContent = metaContent
|
||||
} catch {
|
||||
@ -335,7 +335,7 @@ extension StatusView {
|
||||
viewModel.language = (status.reblog ?? status).entity.language
|
||||
// content
|
||||
do {
|
||||
let content = MastodonContent(content: status.entity.content ?? "", emojis: status.entity.emojis?.asDictionary ?? [:])
|
||||
let content = MastodonContent(content: status.entity.content ?? "", emojis: status.entity.emojis.asDictionary)
|
||||
let metaContent = try MastodonMetaContent.convert(document: content)
|
||||
viewModel.content = metaContent
|
||||
viewModel.isCurrentlyTranslating = false
|
||||
|
Loading…
x
Reference in New Issue
Block a user