diff --git a/Pachyderm/Model/Instance.swift b/Pachyderm/Model/Instance.swift index 4f907f4d..c0b20ae1 100644 --- a/Pachyderm/Model/Instance.swift +++ b/Pachyderm/Model/Instance.swift @@ -15,8 +15,10 @@ public class Instance: Decodable { public let email: String public let version: String public let urls: [String: URL] - public let languages: [String] - public let contactAccount: Account + + // pleroma doesn't currently implement these + public let languages: [String]? + public let contactAccount: Account? // MARK: Unofficial additions to the Mastodon API. public let stats: Stats? diff --git a/PachydermTests/CharacterCounterTests.swift b/PachydermTests/CharacterCounterTests.swift index 65220e96..887efe0d 100644 --- a/PachydermTests/CharacterCounterTests.swift +++ b/PachydermTests/CharacterCounterTests.swift @@ -17,6 +17,10 @@ class CharacterCounterTests: XCTestCase { override func tearDown() { } + func testCountEmpty() { + XCTAssertEqual(CharacterCounter.count(text: ""), 0) + } + func testCountPlainText() { XCTAssertEqual(CharacterCounter.count(text: "This is an example message"), 26) XCTAssertEqual(CharacterCounter.count(text: "This is an example message with an Emoji: 😄"), 43) diff --git a/Tusker/AppDelegate.swift b/Tusker/AppDelegate.swift index f3e41416..a25f75de 100644 --- a/Tusker/AppDelegate.swift +++ b/Tusker/AppDelegate.swift @@ -19,6 +19,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { if LocalData.shared.onboardingComplete { MastodonController.shared.createClient() MastodonController.shared.getOwnAccount() + MastodonController.shared.getOwnInstance() } else { showOnboarding() } diff --git a/Tusker/Controllers/MastodonController.swift b/Tusker/Controllers/MastodonController.swift index 65a261d0..d2c997fd 100644 --- a/Tusker/Controllers/MastodonController.swift +++ b/Tusker/Controllers/MastodonController.swift @@ -16,6 +16,7 @@ class MastodonController { var client: Client! var account: Account! + var instance: Instance! private init() { } @@ -61,4 +62,12 @@ class MastodonController { } } + func getOwnInstance() { + let request = client.getInstance() + client.run(request) { (response) in + guard case let .success(instance, _) = response else { fatalError() } + self.instance = instance + } + } + } diff --git a/Tusker/Screens/Compose/Compose.storyboard b/Tusker/Screens/Compose/Compose.storyboard index 42bfb0dd..ffeb548d 100644 --- a/Tusker/Screens/Compose/Compose.storyboard +++ b/Tusker/Screens/Compose/Compose.storyboard @@ -1,10 +1,10 @@ - + - + @@ -109,8 +109,14 @@ -