Fix build for real

This commit is contained in:
Thomas Ricouard 2025-02-10 10:51:39 +01:00
parent fa92284592
commit 7e167705ac
2 changed files with 26 additions and 23 deletions

View file

@ -3,16 +3,17 @@ import Foundation
import Models
import SwiftUI
@MainActor
public struct EmojiTextApp: View {
private let markdown: HTMLString
private let emojis: [any CustomEmoji]
private let language: String?
private let append: (() -> Text)?
private let append: (@Sendable () -> Text)?
private let lineLimit: Int?
public init(
_ markdown: HTMLString, emojis: [Emoji], language: String? = nil, lineLimit: Int? = nil,
append: (() -> Text)? = nil
append: (@Sendable () -> Text)? = nil
) {
self.markdown = markdown
self.emojis = emojis.map { RemoteEmoji(shortcode: $0.shortcode, url: $0.url) }
@ -24,9 +25,7 @@ public struct EmojiTextApp: View {
public var body: some View {
if let append {
EmojiText(markdown: markdown.asMarkdown, emojis: emojis)
.append {
append()
}
.append(text: append)
.lineLimit(lineLimit)
} else if emojis.isEmpty {
Text(markdown.asSafeMarkdownAttributedString)

View file

@ -104,24 +104,7 @@ struct NotificationRowView: View {
EmojiTextApp(
.init(stringValue: notification.accounts[0].safeDisplayName),
emojis: notification.accounts[0].emojis,
append: {
(notification.accounts.count > 1
? Text("notifications-others-count \(notification.accounts.count - 1)")
.font(.scaledSubheadline)
.fontWeight(.regular)
: Text(" "))
+ Text(type.label(count: notification.accounts.count))
.font(.scaledSubheadline)
.fontWeight(.regular)
+ Text("")
.font(.scaledFootnote)
.fontWeight(.regular)
.foregroundStyle(.secondary)
+ Text(notification.createdAt.relativeFormatted)
.font(.scaledFootnote)
.fontWeight(.regular)
.foregroundStyle(.secondary)
}
append: { makeAppendView(type: type) }
)
.font(.scaledSubheadline)
.emojiText.size(Font.scaledSubheadlineFont.emojiSize)
@ -157,6 +140,27 @@ struct NotificationRowView: View {
}
.accessibilityElement(children: .combine)
}
nonisolated private func makeAppendView(type: Models.Notification.NotificationType) -> Text {
if notification.accounts.count > 1 {
Text("notifications-others-count \(notification.accounts.count - 1)")
.font(.subheadline)
.fontWeight(.regular)
} else {
Text(" ")
+ Text(type.label(count: notification.accounts.count))
.font(.subheadline)
.fontWeight(.regular)
+ Text("")
.font(.footnote)
.fontWeight(.regular)
.foregroundStyle(.secondary)
+ Text(notification.createdAt.relativeFormatted)
.font(.footnote)
.fontWeight(.regular)
.foregroundStyle(.secondary)
}
}
@ViewBuilder
private func makeContent(type: Models.Notification.NotificationType) -> some View {