Skip to content

Commit 13f90d5

Browse files
Do not try to load roles for DM users
1 parent 63677dc commit 13f90d5

File tree

1 file changed

+31
-29
lines changed

1 file changed

+31
-29
lines changed

Swiftcord/Views/User/UserAvatarView.swift

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -133,36 +133,38 @@ struct UserAvatarView: View {
133133
Text("NO ABOUT").font(.headline)
134134
}
135135

136-
if let profile = profile, let guildRoles = guildRoles {
137-
let roles = guildRoles.filter({ r in
138-
profile.guild_member!.roles.contains(r.id)
139-
})
140-
141-
Text(roles.isEmpty
142-
? "NO ROLES"
143-
: (roles.count == 1 ? "ROLE" : "ROLES")
144-
).font(.headline).padding(.top, 8)
145-
if !roles.isEmpty {
146-
TagCloudView(content: roles.map({ role in
147-
HStack(spacing: 6) {
148-
Circle()
149-
.fill(Color(hex: role.color))
150-
.frame(width: 14, height: 14)
151-
.padding(.leading, 6)
152-
Text(role.name)
153-
.font(.system(size: 12))
154-
.padding(.trailing, 8)
155-
}
156-
.frame(height: 24)
157-
.background(Color.gray.opacity(0.2))
158-
.cornerRadius(7)
159-
})).padding(-2)
136+
if let profile = profile, guildID != "@me" {
137+
if let guildRoles = guildRoles {
138+
let roles = guildRoles.filter({ r in
139+
profile.guild_member!.roles.contains(r.id)
140+
})
141+
142+
Text(roles.isEmpty
143+
? "NO ROLES"
144+
: (roles.count == 1 ? "ROLE" : "ROLES")
145+
).font(.headline).padding(.top, 8)
146+
if !roles.isEmpty {
147+
TagCloudView(content: roles.map({ role in
148+
HStack(spacing: 6) {
149+
Circle()
150+
.fill(Color(hex: role.color))
151+
.frame(width: 14, height: 14)
152+
.padding(.leading, 6)
153+
Text(role.name)
154+
.font(.system(size: 12))
155+
.padding(.trailing, 8)
156+
}
157+
.frame(height: 24)
158+
.background(Color.gray.opacity(0.2))
159+
.cornerRadius(7)
160+
})).padding(-2)
161+
}
162+
} else {
163+
ProgressView("Loading roles...")
164+
.progressViewStyle(.linear)
165+
.frame(maxWidth: .infinity)
166+
.tint(.blue)
160167
}
161-
} else {
162-
ProgressView("Loading roles...")
163-
.progressViewStyle(.linear)
164-
.frame(maxWidth: .infinity)
165-
.tint(.blue)
166168
}
167169

168170
Text("NOTE").font(.headline).padding(.top, 8)

0 commit comments

Comments
 (0)