Merge pull request #36 from tootsuite/fix/html-server-description

Fix server description may display in HTML format issue
This commit is contained in:
CMK 2021-03-04 10:55:18 +08:00 committed by GitHub
commit fab1deb7c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 4 deletions

View File

@ -17,12 +17,12 @@
<key>Mastodon - Release.xcscheme_^#shared#^_</key> <key>Mastodon - Release.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>1</integer> <integer>2</integer>
</dict> </dict>
<key>Mastodon.xcscheme_^#shared#^_</key> <key>Mastodon.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>0</integer> <integer>1</integer>
</dict> </dict>
</dict> </dict>
<key>SuppressBuildableAutocreation</key> <key>SuppressBuildableAutocreation</key>

View File

@ -8,6 +8,7 @@
import UIKit import UIKit
import MastodonSDK import MastodonSDK
import Kingfisher import Kingfisher
import Kanna
protocol PickServerCellDelegate: class { protocol PickServerCellDelegate: class {
func pickServerCell(modeChange server: Mastodon.Entity.Server, newMode: PickServerCell.Mode, updates: (() -> Void)) func pickServerCell(modeChange server: Mastodon.Entity.Server, newMode: PickServerCell.Mode, updates: (() -> Void))
@ -326,7 +327,13 @@ extension PickServerCell {
private func updateServerInfo() { private func updateServerInfo() {
guard let serverInfo = server else { return } guard let serverInfo = server else { return }
domainLabel.text = serverInfo.domain domainLabel.text = serverInfo.domain
descriptionLabel.text = serverInfo.description descriptionLabel.text = {
guard let html = try? HTML(html: serverInfo.description, encoding: .utf8) else {
return serverInfo.description
}
return html.text ?? serverInfo.description
}()
let processor = RoundCornerImageProcessor(cornerRadius: 3) let processor = RoundCornerImageProcessor(cornerRadius: 3)
thumbImageView.kf.indicatorType = .activity thumbImageView.kf.indicatorType = .activity
thumbImageView.kf.setImage(with: URL(string: serverInfo.proxiedThumbnail ?? "")!, placeholder: UIImage.placeholder(color: Asset.Colors.lightBackground.color), options: [ thumbImageView.kf.setImage(with: URL(string: serverInfo.proxiedThumbnail ?? "")!, placeholder: UIImage.placeholder(color: Asset.Colors.lightBackground.color), options: [

View File

@ -13,11 +13,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
let appContext = AppContext() let appContext = AppContext()
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
return true
// Update app version info. See: `Settings.bundle` // Update app version info. See: `Settings.bundle`
UserDefaults.standard.setValue(UIApplication.appVersion(), forKey: "Mastodon.appVersion") UserDefaults.standard.setValue(UIApplication.appVersion(), forKey: "Mastodon.appVersion")
UserDefaults.standard.setValue(UIApplication.appBuild(), forKey: "Mastodon.appBundle") UserDefaults.standard.setValue(UIApplication.appBuild(), forKey: "Mastodon.appBundle")
return true
} }
// MARK: UISceneSession Lifecycle // MARK: UISceneSession Lifecycle