Closed selimgr closed 2 years ago
I should create a pinned issue for embeds. Basically, I added embed support over a few days and just left it to develop other features. This meant embeds were kinda half done, usable but not complete. I should've came back to them sooner but basically was caught up making bugfixes/implementing other features so embeds were basically left alone. I will fix all these issues soon, after fixing DMs :D
Thanks for the support!
After installing XCode and learning a bit of Swift & SwiftUI (thanks to the Discord server haha), I found that the markdown is not rendered if the passed string is not a LocalizedStringKey
.
By adding LocalizedStringKey()
around the embeds string variables in the EmbedView
, markdown is correctly rendered on Rich Embeds.
A screenshot of the final result:
(I also added the missing author field + URL support on the title 😄 )
The code should look like this: (example for the description)
if let description = embed.description {
// old: Text(description)
Text(LocalizedStringKey(description))
.textSelection(.enabled)
.opacity(0.9)
.frame(maxWidth: .infinity, alignment: .leading)
}
@selimgr In fact, as you can probably find elsewhere, wrapping the string with .init(str) will work too. i.e.: Text(.init(theMessageStr))
This is also, yet another silly SwiftUI bug
The PR, also by @selimgr, resolves this and has been merged. Thanks for your contribution!
Describe the bug
It seems that RichEmbeds containing markdown text are not properly rendering.
To Reproduce
Expected behavior
See screenshots
Screenshots
First one is SwiftCord, the other one is Discord https://imgur.com/a/rBOkGFO
Additional context
I'm not sure if this is a problem or not as I saw that "Rich message rendering" should work fine on the roadmap. So just in case 🤷♂️ ALSO the "author" field does not appear in the Rich Embed either (see the top part of it in the screenshots)
By the way, I really appreciate your work!! The UI looks soo good and Discord should defintively make a native version instead of electron... Can't wait to see Voice channels haha