From 25772aad7724539b19e9d8ab2e065a9ea6f92925 Mon Sep 17 00:00:00 2001 From: vinkwok Date: Sat, 30 Sep 2023 14:22:42 +0800 Subject: [PATCH 1/6] fix(permission): unable to send messages in DM --- Swiftcord/Views/Message/MessagesView.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Swiftcord/Views/Message/MessagesView.swift b/Swiftcord/Views/Message/MessagesView.swift index 13c2b7ad..007d2b49 100644 --- a/Swiftcord/Views/Message/MessagesView.swift +++ b/Swiftcord/Views/Message/MessagesView.swift @@ -248,9 +248,9 @@ struct MessagesView: View { MessageInfoBarView(isShown: $viewModel.showingInfoBar, state: $viewModel.infoBarData) let hasSendPermission: Bool = { - guard let guildID = ctx.guild?.id, let member = ctx.member else { - return false - } + guard let guildID = ctx.guild?.id else { return false } + guard !guildID.isDM else { return true } + guard let member = ctx.member else { return false } return channel.computedPermissions( guildID: guildID, member: member, basePerms: ctx.basePermissions ) From 87aae42581bb162a92c1cb341fa6f39319c35cd1 Mon Sep 17 00:00:00 2001 From: 12944qwerty Date: Mon, 2 Oct 2023 07:36:19 -0400 Subject: [PATCH 2/6] Exclude Disc from copy username if pomelo (#174) * exclude disc if no pomelo * ternary * ugh formatting --- Swiftcord/Views/User/Profile/MiniUserProfileView.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Swiftcord/Views/User/Profile/MiniUserProfileView.swift b/Swiftcord/Views/User/Profile/MiniUserProfileView.swift index 2946aeda..7399fc64 100644 --- a/Swiftcord/Views/User/Profile/MiniUserProfileView.swift +++ b/Swiftcord/Views/User/Profile/MiniUserProfileView.swift @@ -87,7 +87,12 @@ struct MiniUserProfileView: View { Spacer() Button { pasteboard.declareTypes([.string], owner: nil) - pasteboard.setString("\(user.username)#\(user.discriminator)", forType: .string) + pasteboard.setString( + user.discriminator == "0" + ? user.username + : "\(user.username)#\(user.discriminator)", + forType: .string + ) } label: { Image(systemName: "square.on.square") } From 71cf78daade62d010bc5e760ff6263150caf531f Mon Sep 17 00:00:00 2001 From: vinkwok Date: Thu, 5 Oct 2023 23:09:52 +0800 Subject: [PATCH 3/6] fix(user): update most uses of username to match Discord username update fix(currentUser): show username instead of discrim if account is migrated, in user footer --- .../Utils/Extensions/DiscordAPI/Channel+.swift | 2 +- .../Extensions/DiscordAPI/User+displayName.swift | 15 +++++++++++++++ .../Message/MessageRenderViews/MessageView.swift | 2 +- .../MessageRenderViews/ReferenceMessageView.swift | 2 +- Swiftcord/Views/Message/MessagesView.swift | 4 ++-- Swiftcord/Views/User/CurrentUserFooter.swift | 4 ++-- 6 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 Swiftcord/Utils/Extensions/DiscordAPI/User+displayName.swift diff --git a/Swiftcord/Utils/Extensions/DiscordAPI/Channel+.swift b/Swiftcord/Utils/Extensions/DiscordAPI/Channel+.swift index 30163abf..591fad91 100644 --- a/Swiftcord/Utils/Extensions/DiscordAPI/Channel+.swift +++ b/Swiftcord/Utils/Extensions/DiscordAPI/Channel+.swift @@ -10,7 +10,7 @@ import DiscordKitCore extension Channel { func label(_ users: [Snowflake: User] = [:]) -> String? { name ?? recipient_ids? - .compactMap { users[$0]?.username } + .compactMap { users[$0]?.displayName } .joined(separator: ", ") } } diff --git a/Swiftcord/Utils/Extensions/DiscordAPI/User+displayName.swift b/Swiftcord/Utils/Extensions/DiscordAPI/User+displayName.swift new file mode 100644 index 00000000..23061cd0 --- /dev/null +++ b/Swiftcord/Utils/Extensions/DiscordAPI/User+displayName.swift @@ -0,0 +1,15 @@ +// +// User+displayName.swift +// Swiftcord +// +// Created by Vincent Kwok on 5/10/23. +// + +import Foundation +import DiscordKitCore + +extension User { + var displayName: String { + global_name ?? username + } +} diff --git a/Swiftcord/Views/Message/MessageRenderViews/MessageView.swift b/Swiftcord/Views/Message/MessageRenderViews/MessageView.swift index a452c7e7..336aa5ba 100644 --- a/Swiftcord/Views/Message/MessageRenderViews/MessageView.swift +++ b/Swiftcord/Views/Message/MessageRenderViews/MessageView.swift @@ -87,7 +87,7 @@ struct MessageView: View, Equatable { VStack(alignment: .leading, spacing: Self.lineSpacing) { if !shrunk { HStack(spacing: 6) { - Text(message.member?.nick ?? message.author.username) + Text(message.member?.nick ?? message.author.displayName) .font(.system(size: 15)) .fontWeight(.medium) if message.author.bot ?? false || message.webhook_id != nil { diff --git a/Swiftcord/Views/Message/MessageRenderViews/ReferenceMessageView.swift b/Swiftcord/Views/Message/MessageRenderViews/ReferenceMessageView.swift index 6ca1d27e..3b693bc1 100644 --- a/Swiftcord/Views/Message/MessageRenderViews/ReferenceMessageView.swift +++ b/Swiftcord/Views/Message/MessageRenderViews/ReferenceMessageView.swift @@ -36,7 +36,7 @@ struct ReferenceMessageView: View { ) Group { - Text(quotedMsg.author.username) + Text(quotedMsg.author.displayName) .font(.system(size: 14)) .opacity(0.9) diff --git a/Swiftcord/Views/Message/MessagesView.swift b/Swiftcord/Views/Message/MessagesView.swift index 007d2b49..e9fc4c46 100644 --- a/Swiftcord/Views/Message/MessagesView.swift +++ b/Swiftcord/Views/Message/MessagesView.swift @@ -285,13 +285,13 @@ struct MessagesView: View { } .overlay { let typingMembers = ctx.typingStarted[channel.id]? - .map { $0.member?.nick ?? $0.member?.user?.username ?? "" } ?? [] + .map { $0.member?.nick ?? $0.member?.user?.displayName ?? "" } ?? [] if !typingMembers.isEmpty { HStack { // The dimensions are quite arbitrary // FIXME: The animation broke, will have to fix it - LottieView(name: "typing-animatiokn", play: .constant(true), width: 160, height: 160) + LottieView(name: "typing-animation", play: .constant(true), width: 160, height: 160) .lottieLoopMode(.loop) .frame(width: 32, height: 24) Group { diff --git a/Swiftcord/Views/User/CurrentUserFooter.swift b/Swiftcord/Views/User/CurrentUserFooter.swift index 9100adf4..f6e576a0 100644 --- a/Swiftcord/Views/User/CurrentUserFooter.swift +++ b/Swiftcord/Views/User/CurrentUserFooter.swift @@ -98,14 +98,14 @@ struct CurrentUserFooter: View { .controlSize(.small) VStack(alignment: .leading, spacing: 0) { - Text(user.username).font(.headline) + Text(user.global_name ?? user.username).font(.headline) Group { if let customStatus = customStatus { Text(customStatus.state ?? "") .lineLimit(1) .truncationMode(.tail) } else { - Text("#" + user.discriminator) + Text(user.discriminator == "0" ? user.username : "#" + user.discriminator) } }.font(.system(size: 12)).opacity(0.75) } From 0bef81a8dfe1f4013f184d86e01750e959a66250 Mon Sep 17 00:00:00 2001 From: vinkwok Date: Sat, 14 Oct 2023 15:53:01 +0800 Subject: [PATCH 4/6] patch(deps): update to latest DiscordKit commit --- Swiftcord.xcodeproj/project.pbxproj | 10 ++++++++-- .../xcshareddata/swiftpm/Package.resolved | 7 ++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Swiftcord.xcodeproj/project.pbxproj b/Swiftcord.xcodeproj/project.pbxproj index ef90dc77..cf118304 100644 --- a/Swiftcord.xcodeproj/project.pbxproj +++ b/Swiftcord.xcodeproj/project.pbxproj @@ -121,6 +121,8 @@ DA2384BB27CBC2CE009E15E0 /* GintoMedium.otf in Resources */ = {isa = PBXBuildFile; fileRef = DA2384B927CBC2CE009E15E0 /* GintoMedium.otf */; }; DA2384BF27CCBB26009E15E0 /* EmbedView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA2384BE27CCBB26009E15E0 /* EmbedView.swift */; }; DA2384C627CD1921009E15E0 /* LoadingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA2384C527CD1921009E15E0 /* LoadingView.swift */; }; + DA251ED72ACF077F0030C845 /* User+displayName.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA251ED62ACF077F0030C845 /* User+displayName.swift */; }; + DA251ED82ACF077F0030C845 /* User+displayName.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA251ED62ACF077F0030C845 /* User+displayName.swift */; }; DA264C1528C8852900FBB4B5 /* FlatMenuStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA264C1428C8852900FBB4B5 /* FlatMenuStyle.swift */; }; DA264C1728C89FE300FBB4B5 /* PresenceStatus+.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA264C1628C89FE300FBB4B5 /* PresenceStatus+.swift */; }; DA264C1A28C8E27E00FBB4B5 /* CustomStatusDialog.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA264C1928C8E27E00FBB4B5 /* CustomStatusDialog.swift */; }; @@ -294,6 +296,7 @@ DA2384B927CBC2CE009E15E0 /* GintoMedium.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = GintoMedium.otf; sourceTree = ""; }; DA2384BE27CCBB26009E15E0 /* EmbedView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmbedView.swift; sourceTree = ""; }; DA2384C527CD1921009E15E0 /* LoadingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadingView.swift; sourceTree = ""; }; + DA251ED62ACF077F0030C845 /* User+displayName.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "User+displayName.swift"; sourceTree = ""; }; DA264C1428C8852900FBB4B5 /* FlatMenuStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlatMenuStyle.swift; sourceTree = ""; }; DA264C1628C89FE300FBB4B5 /* PresenceStatus+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PresenceStatus+.swift"; sourceTree = ""; }; DA264C1928C8E27E00FBB4B5 /* CustomStatusDialog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomStatusDialog.swift; sourceTree = ""; }; @@ -839,6 +842,7 @@ DA54D5752844B9C500B11857 /* CurrentUser+.swift */, DAC437782900F3FD00D3A894 /* Snowflake+.swift */, DA9029562A0CC450008E05FA /* Permissions+.swift */, + DA251ED62ACF077F0030C845 /* User+displayName.swift */, ); path = DiscordAPI; sourceTree = ""; @@ -1134,6 +1138,7 @@ 36429958286801C900483D0A /* AppSettingsView.swift in Sources */, 36429959286801C900483D0A /* WebView.swift in Sources */, 3642995A286801C900483D0A /* DebugSettingsView.swift in Sources */, + DA251ED82ACF077F0030C845 /* User+displayName.swift in Sources */, 3642995B286801C900483D0A /* LoginView.swift in Sources */, 3642995C286801C900483D0A /* UIStateEnv.swift in Sources */, 3642995D286801C900483D0A /* MessageView.swift in Sources */, @@ -1251,6 +1256,7 @@ DA57F44628065209001DC46E /* ChannelButton.swift in Sources */, DA32EF6627CB772300A9ED72 /* CacheModel.xcdatamodeld in Sources */, 03A188C02A0FDB8A00D5F4BC /* MessageStickerView.swift in Sources */, + DA251ED72ACF077F0030C845 /* User+displayName.swift in Sources */, E7AF1C33282FB02A001F78DF /* UserSettingsAccount.swift in Sources */, DA520AE227D76BEB009FD740 /* Bool+.swift in Sources */, 03A188BE2A0FDB7500D5F4BC /* BasicStickerView.swift in Sources */, @@ -1828,8 +1834,8 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/SwiftcordApp/DiscordKit"; requirement = { - kind = revision; - revision = 2b6151e35a328d47f9f920c43179c1aa1fabd82c; + branch = main; + kind = branch; }; }; DA8AEA6629029747007BAAEA /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */ = { diff --git a/Swiftcord.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Swiftcord.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index bb38e157..4316c748 100644 --- a/Swiftcord.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Swiftcord.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -23,7 +23,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/SwiftcordApp/DiscordKit", "state" : { - "revision" : "2b6151e35a328d47f9f920c43179c1aa1fabd82c" + "branch" : "main", + "revision" : "2d42c69cafe592300a1a9d3a307bf485294026c7" } }, { @@ -121,8 +122,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-protobuf.git", "state" : { - "revision" : "cf62cdaea48b77f1a631e5cb3aeda6047c2cba1d", - "version" : "1.23.0" + "revision" : "3c54ab05249f59f2c6641dd2920b8358ea9ed127", + "version" : "1.24.0" } }, { From a442cbb8c18e3589f3de39f5b5a308f27e9d55a3 Mon Sep 17 00:00:00 2001 From: vinkwok Date: Fri, 10 Nov 2023 00:00:09 +0800 Subject: [PATCH 5/6] patch(ci): disable push trigger for build had been causing build failures for quite a while due to expired certs --- .github/workflows/build.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 89a33bae..fdbdc0ed 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,7 +1,8 @@ name: Build Swiftcord Nightly on: - push: + # Build is broken due to expired certs, disabling the workflow for now + # push: workflow_dispatch: concurrency: From 87e647c6c2631cfbff7fbe88bab15a83bb03f481 Mon Sep 17 00:00:00 2001 From: vinkwok Date: Fri, 10 Nov 2023 00:02:49 +0800 Subject: [PATCH 6/6] bump: 0.7.0(17) lock DiscordKit dep --- Swiftcord.xcodeproj/project.pbxproj | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Swiftcord.xcodeproj/project.pbxproj b/Swiftcord.xcodeproj/project.pbxproj index cf118304..c11c4071 100644 --- a/Swiftcord.xcodeproj/project.pbxproj +++ b/Swiftcord.xcodeproj/project.pbxproj @@ -1428,7 +1428,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 17; + CURRENT_PROJECT_VERSION = 18; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = "\"Swiftcord/Preview Content\""; DEVELOPMENT_TEAM = Q382QLKDG3; @@ -1446,7 +1446,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 12.0; - MARKETING_VERSION = 0.7.0; + MARKETING_VERSION = 0.7.1; PRODUCT_BUNDLE_IDENTIFIER = io.cryptoalgo.swiftcord; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_ACTIVE_COMPILATION_CONDITIONS = APP_STORE; @@ -1692,7 +1692,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 17; + CURRENT_PROJECT_VERSION = 18; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = "\"Swiftcord/Preview Content\""; DEVELOPMENT_TEAM = Q382QLKDG3; @@ -1710,7 +1710,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 12.0; - MARKETING_VERSION = 0.7.0; + MARKETING_VERSION = 0.7.1; PRODUCT_BUNDLE_IDENTIFIER = io.cryptoalgo.swiftcord; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; @@ -1728,7 +1728,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 17; + CURRENT_PROJECT_VERSION = 18; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = "\"Swiftcord/Preview Content\""; DEVELOPMENT_TEAM = Q382QLKDG3; @@ -1746,7 +1746,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 12.0; - MARKETING_VERSION = 0.7.0; + MARKETING_VERSION = 0.7.1; PRODUCT_BUNDLE_IDENTIFIER = io.cryptoalgo.swiftcord; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; @@ -1834,8 +1834,8 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/SwiftcordApp/DiscordKit"; requirement = { - branch = main; - kind = branch; + kind = revision; + revision = 2d42c69cafe592300a1a9d3a307bf485294026c7; }; }; DA8AEA6629029747007BAAEA /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */ = {