diff --git a/Swiftcord.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Swiftcord.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index ecc1ea4b..8d64f64a 100644 --- a/Swiftcord.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Swiftcord.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -15,7 +15,7 @@ "location" : "https://github.com/SwiftcordApp/DiscordKit", "state" : { "branch" : "main", - "revision" : "2587b1df17fc2b18346b630e1a2f5635d209c94b" + "revision" : "5a1cf337615a73855ce20420a76b45c39dcaec63" } }, { diff --git a/Swiftcord/Utils/MergeStructs/MergePartialMessage.swift b/Swiftcord/Utils/MergeStructs/MergePartialMessage.swift index d90f48eb..2c799f42 100644 --- a/Swiftcord/Utils/MergeStructs/MergePartialMessage.swift +++ b/Swiftcord/Utils/MergeStructs/MergePartialMessage.swift @@ -11,29 +11,37 @@ import Foundation import DiscordKitCommon extension Message { - func mergeWithPartialMsg(_ partial: PartialMessage) { - author = partial.author ?? author - member = partial.member ?? member - content = partial.content ?? content - edited_timestamp = partial.edited_timestamp ?? edited_timestamp - tts = partial.tts ?? tts - mention_everyone = partial.mention_everyone ?? mention_everyone - mentions = partial.mentions ?? mentions - mention_roles = partial.mention_roles ?? mention_roles - mention_channels = partial.mention_channels ?? mention_channels - attachments = partial.attachments ?? attachments - embeds = partial.embeds ?? embeds - reactions = partial.reactions ?? reactions - pinned = partial.pinned ?? pinned - webhook_id = partial.webhook_id ?? webhook_id - activity = partial.activity ?? activity - application = partial.application ?? application - application_id = partial.application_id ?? application_id - message_reference = partial.message_reference ?? message_reference - flags = partial.flags ?? flags - interaction = partial.interaction ?? interaction - thread = partial.thread ?? thread - components = partial.components ?? components - sticker_items = partial.sticker_items ?? sticker_items + func mergingWithPartialMsg(_ partial: PartialMessage) -> Message { + Message( + id: id, + channel_id: channel_id, + guild_id: guild_id, + author: partial.author ?? author, + member: partial.member ?? member, + content: partial.content ?? content, + timestamp: timestamp, + edited_timestamp: partial.edited_timestamp ?? edited_timestamp, + tts: partial.tts ?? tts, + mention_everyone: partial.mention_everyone ?? mention_everyone, + mentions: partial.mentions ?? mentions, + mention_roles: partial.mention_roles ?? mention_roles, + mention_channels: partial.mention_channels ?? mention_channels, + attachments: partial.attachments ?? attachments, + embeds: partial.embeds ?? embeds, + reactions: partial.reactions ?? reactions, + pinned: partial.pinned ?? pinned, + webhook_id: webhook_id, + type: type, + activity: partial.activity ?? activity, + application: partial.application ?? application, + application_id: partial.application_id ?? application_id, + message_reference: message_reference, + flags: partial.flags ?? flags, + referenced_message: partial.referenced_message ?? referenced_message, + interaction: partial.interaction ?? interaction, + thread: partial.thread ?? thread, + components: partial.components ?? components, + sticker_items: partial.sticker_items ?? sticker_items + ) } } diff --git a/Swiftcord/Views/Message/MessagesView.swift b/Swiftcord/Views/Message/MessagesView.swift index 4ae73e20..2dc51eb7 100644 --- a/Swiftcord/Views/Message/MessagesView.swift +++ b/Swiftcord/Views/Message/MessagesView.swift @@ -356,9 +356,7 @@ struct MessagesView: View { case .messageUpdate: guard let newMsg = d as? PartialMessage else { break } if let updatedIdx = messages.firstIndex(where: { $0.id == newMsg.id }) { - var updatedMsg = messages[updatedIdx] - updatedMsg.mergeWithPartialMsg(newMsg) - messages[updatedIdx] = updatedMsg + messages[updatedIdx] = messages[updatedIdx].mergingWithPartialMsg(newMsg) } case .messageDelete: guard let deletedMsg = d as? MessageDelete else { break }