Run SwiftFormat.

This commit is contained in:
Doug
2026-05-27 14:38:50 +01:00
committed by Doug
parent 5138e05e47
commit fa67713726
573 changed files with 2426 additions and 2426 deletions
@@ -26,11 +26,11 @@ extension EventBasedTimelineItemProtocol {
var description: String {
"\(String(describing: Self.self)): id: \(id), timestamp: \(timestamp), isOutgoing: \(isOutgoing), properties: \(properties)"
}
var isForwardable: Bool {
isRemoteMessage && !(self is PollRoomTimelineItem)
}
var isRemoteMessage: Bool {
id.eventID != nil
}
@@ -50,11 +50,11 @@ extension EventBasedTimelineItemProtocol {
var hasFailedToSend: Bool {
properties.deliveryStatus?.isSendingFailed == true
}
var hasFailedDecryption: Bool {
self is EncryptedRoomTimelineItem
}
var timelineMenuDescription: String {
switch self {
case is VoiceMessageRoomTimelineItem:
@@ -63,7 +63,7 @@ extension EventBasedTimelineItemProtocol {
return body.trimmingCharacters(in: .whitespacesAndNewlines)
}
}
/// The inline area to reserve at the trailing edge of the message text so the
/// bubble's natural size accommodates the timestamp (which is overlaid on the
/// bubble's bottom-trailing corner). Text wraps around this area: if it fits on
@@ -86,7 +86,7 @@ extension EventBasedTimelineItemProtocol {
width += 4
return CGSize(width: ceil(width), height: ceil(height))
}
/// contains the timestamp and an optional edited localised prefix
/// example: (edited) 12:17 PM
var localizedSendInfo: String {
@@ -96,12 +96,12 @@ extension EventBasedTimelineItemProtocol {
}
return start + timestamp.formattedTime()
}
var isCopyable: Bool {
guard let messageBasedItem = self as? EventBasedMessageTimelineItemProtocol else {
return false
}
switch messageBasedItem.contentType {
case .audio, .file, .image, .video, .location, .voice:
return false
@@ -19,7 +19,7 @@ struct AudioRoomTimelineItem: EventBasedMessageTimelineItemProtocol, Equatable {
let sender: TimelineItemSender
let content: AudioRoomTimelineItemContent
var properties = RoomTimelineItemProperties()
var body: String {
@@ -14,7 +14,7 @@ struct LiveLocationRoomTimelineItem: EventBasedTimelineItemProtocol, Equatable {
var body: String {
""
}
let timestamp: Date
let isOutgoing: Bool
let isEditable: Bool
@@ -16,15 +16,15 @@ struct LocationRoomTimelineItem: EventBasedMessageTimelineItemProtocol, Equatabl
let canBeRepliedTo: Bool
let sender: TimelineItemSender
let content: LocationRoomTimelineItemContent
var properties = RoomTimelineItemProperties()
var body: String {
content.body
}
var contentType: EventBasedMessageTimelineItemContentType {
.location(content)
}
@@ -12,7 +12,7 @@ struct LocationRoomTimelineItemContent: Hashable {
let body: String
let geoURI: GeoURI?
let kind: StaticLocationKind
init(body: String,
geoURI: GeoURI? = nil,
kind: StaticLocationKind = .sender) {
@@ -18,7 +18,7 @@ struct VideoRoomTimelineItem: EventBasedMessageTimelineItemProtocol, Equatable {
var shouldBoost = false
let sender: TimelineItemSender
let content: VideoRoomTimelineItemContent
var properties = RoomTimelineItemProperties()
@@ -18,7 +18,7 @@ struct VoiceMessageRoomTimelineItem: EventBasedMessageTimelineItemProtocol, Equa
let sender: TimelineItemSender
let content: AudioRoomTimelineItemContent
var properties = RoomTimelineItemProperties()
var body: String {
@@ -29,11 +29,11 @@ struct Poll: Hashable {
let endDate: Date?
/// Whether the poll has been created by the account owner
let createdByAccountOwner: Bool
var hasEnded: Bool {
endDate != nil
}
enum Kind: Hashable {
case disclosed
case undisclosed
@@ -42,7 +42,7 @@ struct Poll: Hashable {
var hasMaxSelections: Bool {
options.filter(\.isSelected).count == maxSelections
}
struct Option: Hashable {
let id: String
let text: String
@@ -384,9 +384,9 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
let allVotes = votes.reduce(0) { count, pair in
count + pair.value.count
}
let maxOptionVotes = votes.map(\.value.count).max()
let options = answers.map { answer in
let optionVotesCount = votes[answer.id]?.count
@@ -404,7 +404,7 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
case .undisclosed:
.undisclosed
}
let poll = Poll(question: question,
kind: pollKind,
maxSelections: Int(maxSelections),
@@ -412,7 +412,7 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
votes: votes,
endDate: endTime.map { Date(timeIntervalSince1970: TimeInterval($0 / 1000)) },
createdByAccountOwner: eventItemProxy.sender.id == userID)
return PollRoomTimelineItem(id: eventItemProxy.id,
poll: poll,
body: poll.question,
@@ -538,7 +538,7 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
if let audioWaveform = messageContent.audio?.waveform {
waveform = EstimatedWaveform(data: audioWaveform)
}
return AudioRoomTimelineItemContent(filename: messageContent.filename,
caption: messageContent.caption,
formattedCaption: formattedCaption,
@@ -602,13 +602,13 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
blurhash: messageContent.info?.blurhash,
contentType: UTType(mimeType: messageContent.info?.mimetype, fallbackFilename: messageContent.filename))
}
private func buildLocationTimelineItemContent(_ locationContent: LocationContent) -> LocationRoomTimelineItemContent {
LocationRoomTimelineItemContent(body: locationContent.body,
geoURI: .init(string: locationContent.geoUri),
kind: .init(from: locationContent.asset))
}
private func buildFileTimelineItemContent(_ messageContent: FileMessageContent) -> FileRoomTimelineItemContent {
let htmlCaption = messageContent.formattedCaption?.format == .html ? messageContent.formattedCaption?.body : nil
let formattedCaption = htmlCaption != nil ? attributedStringBuilder.fromHTML(htmlCaption) : attributedStringBuilder.fromPlain(messageContent.caption)
@@ -636,7 +636,7 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
let name = senderDisplayName ?? senderID
let htmlBody = messageContent.formatted?.format == .html ? messageContent.formatted?.body : nil
var formattedBody: AttributedString?
if let htmlBody {
formattedBody = buildEmoteFormattedBodyFromHTML(html: htmlBody, name: name)
@@ -686,7 +686,7 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
return a.count > b.count
}
}
private func buildOrderedReadReceipts(_ receipts: [String: Receipt]) -> [ReadReceipt] {
receipts
.sorted { firstElement, secondElement in
@@ -25,7 +25,7 @@ struct RoomTimelineItemView: View {
context?.send(viewAction: .itemDisappeared(itemID: viewState.identifier))
}
}
@ViewBuilder private var timelineView: some View {
switch viewState.type {
case .text(let item):
@@ -12,17 +12,17 @@ import MatrixRustSDK
final class RoomTimelineItemViewState: Identifiable, Equatable, ObservableObject {
@Published var type: RoomTimelineItemType
@Published var groupStyle: TimelineGroupStyle
/// Contains all the identification info of the item, `uniqueID`, `eventID` and `transactionID`
var identifier: TimelineItemIdentifier {
type.id
}
init(type: RoomTimelineItemType, groupStyle: TimelineGroupStyle) {
self.type = type
self.groupStyle = groupStyle
}
convenience init(item: RoomTimelineItemProtocol, groupStyle: TimelineGroupStyle) {
self.init(type: .init(item: item), groupStyle: groupStyle)
}
@@ -70,7 +70,7 @@ enum RoomTimelineItemType: Equatable {
case callInvite(CallInviteRoomTimelineItem)
case callNotification(CallNotificationRoomTimelineItem)
case liveLocation(LiveLocationRoomTimelineItem)
init(item: RoomTimelineItemProtocol) {
switch item {
case let item as TextRoomTimelineItem:
@@ -123,7 +123,7 @@ enum RoomTimelineItemType: Equatable {
fatalError("Unknown timeline item")
}
}
var id: TimelineItemIdentifier {
switch self {
case .text(let item as RoomTimelineItemProtocol),