* provider can now check the current session

* More testable code

* created the test condition

* it works but not always not sure why, need to dig deeper

* sadly we need to use textkit 1 to solve this issue

* removed developer option screen test

* this experimental solution kinda works but I need a way to pill recomputation is weird

* format

* display improvement

* better and faster solution

* pilished the code

* better coloring

* swift format

* just need to solve the caching issue

* fix caching issue

* tests done!

* changelog

* pr comments addressed

* all pr comments addressed

* docs

* line lenght

* updated tests and fixed a parsing permalink issue

* MentionBuilder

* pr comments

* swiftformat

* code blocks should not have links

* Update ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift

Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com>

* Update ElementX/Sources/Services/Client/ClientProxy.swift

Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com>

* Update UnitTests/Sources/AttributedStringBuilderTests.swift

Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com>

* Update ElementX/Sources/UITests/UITestsAppCoordinator.swift

Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com>

* Update ElementX/Sources/Other/Pills/PillAttachmentViewProvider.swift

Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com>

* Update ElementX/Sources/Other/Pills/MentionBuilder.swift

Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com>

* pr comments

* swiftformat

---------

Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com>
This commit is contained in:
Mauro
2023-09-27 19:27:07 +02:00
committed by GitHub
parent 8d4c5e2885
commit 7bde419e85
49 changed files with 530 additions and 97 deletions
@@ -18,7 +18,7 @@
import XCTest
class AttributedStringBuilderTests: XCTestCase {
let attributedStringBuilder = AttributedStringBuilder(permalinkBaseURL: ServiceLocator.shared.settings.permalinkBaseURL)
let attributedStringBuilder = AttributedStringBuilder(permalinkBaseURL: ServiceLocator.shared.settings.permalinkBaseURL, mentionBuilder: MentionBuilder(mentionsEnabled: true))
let maxHeaderPointSize = ceil(UIFont.preferredFont(forTextStyle: .body).pointSize * 1.2)
func testRenderHTMLStringWithHeaders() {
@@ -413,6 +413,14 @@ class AttributedStringBuilderTests: XCTestCase {
XCTAssertEqual(numberOfBlockquotes, 3, "Couldn't find all the blockquotes")
}
func testUserMentionAtachment() {
let string = "https://matrix.to/#/@test:matrix.org"
let attributedStringFromHTML = attributedStringBuilder.fromHTML(string)
XCTAssertNotNil(attributedStringFromHTML?.attachment)
let attributedStringFromPlain = attributedStringBuilder.fromPlain(string)
XCTAssert(attributedStringFromPlain?.attachment.isNil == false)
}
// MARK: - Private
private func checkLinkIn(attributedString: AttributedString?, expectedLink: String, expectedRuns: Int) {
@@ -21,7 +21,7 @@ class AttributedStringTests: XCTestCase {
func testReplacingFontWithPresentationIntent() {
// Given a string parsed from HTML that contains specific fixed size fonts.
let boldString = "Bold"
guard let originalString = AttributedStringBuilder(permalinkBaseURL: ServiceLocator.shared.settings.permalinkBaseURL)
guard let originalString = AttributedStringBuilder(permalinkBaseURL: ServiceLocator.shared.settings.permalinkBaseURL, mentionBuilder: MentionBuilder(mentionsEnabled: true))
.fromHTML("Normal <b>\(boldString)</b> Normal.") else {
XCTFail("The attributed string should be built from the HTML.")
return
@@ -31,7 +31,7 @@ class HomeScreenViewModelTests: XCTestCase {
clientProxy = MockClientProxy(userID: "@mock:client.com")
viewModel = HomeScreenViewModel(userSession: MockUserSession(clientProxy: clientProxy,
mediaProvider: MockMediaProvider()),
attributedStringBuilder: AttributedStringBuilder(permalinkBaseURL: ServiceLocator.shared.settings.permalinkBaseURL),
attributedStringBuilder: AttributedStringBuilder(permalinkBaseURL: ServiceLocator.shared.settings.permalinkBaseURL, mentionBuilder: MentionBuilder(mentionsEnabled: true)),
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
appSettings: ServiceLocator.shared.settings,
analytics: ServiceLocator.shared.analytics,
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:abd682ff45a39c88296804ac67c29c6425b3231a03002c8d0cb5b59df4464707
size 212642
oid sha256:b689d76c95de930e792bfbe6ffb86bb9e006958fa77a55ed0aba7ad69432530f
size 212484
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:62be6e4e83d8797e26070862c8812366346594fec8e1fad8daddb0002611a879
size 185793
oid sha256:16ca3e2a15fd004ff1372409fac07bac16ff8b053c72a8e2acc9975afbe9957f
size 185944
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b7e5576967557d1cea6f5b50383c9db6e7749a0ba3a625c3bac987ccd97e0c81
size 60539
oid sha256:7757fa407df9869e19ef6d59c487e0ce8fb848fbb0f864ec328ecfc86bdc1834
size 62544
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c8f07d6150865cb0f7c4bec8743f552440d2e610fbba850675b0e28143fd83d4
size 98236
oid sha256:40267c3676ec3388535b82f1739a8f80ad19b36d38a5f02ecb2a86539b507092
size 98225
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:86663f46166d096cc67fd32973e99dae7f72aa0d9c3b914dd600a57db54410de
size 74887
oid sha256:f3d7d75000e46cd301244335d46367e03afda48b32328230b2bd0fbaf3e1abc9
size 74667
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:71240349d0bfff7c43c230b5e13165c20b18bd20d9df92df7c7df7acf2aa9c61
size 575946
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b28152066f759f0fb99c4bfab9e51bb915a4f9d12c555c05063a00b13eec1476
size 65700
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:eb935eb860e241bf52bc2b1bd45acf8361f661666721b3d512b6f5afd432cf70
size 64239
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3f4ceb7aab76537608639630780df60331f7ba8ee6d775ff489c320e45773a73
size 313849
oid sha256:2c6e64db92199ab4f6239a2ede5240f4bc22fb1f533e455d9787910c14270ec4
size 313456
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:fbe07e396c2259244e51a31274c4a490ad6c8084d56c34b3a9e1e15d7b992520
size 341255
oid sha256:19348f5dc147cbd87d1fbcdb9f228f18e00b29e6f6bf0a2d4c95a19e12424655
size 341025
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:8a5e6199c9faae906e3d9ae844f6d92153d8bd57c2bae48af22b70902fe96d65
size 337294
oid sha256:1241ae3a54ad3f598748c86df59853a96b6266135816c5c3213b9b45f38b3272
size 337109
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:7c21bd9280faed90b3442f883f40d0dd035172a6ac00025809a5c5c1742fdff6
size 339621
oid sha256:e6be01fcd027b50ca4b6eabf43c82c3530e23a939b22bd5279646d7a935f6989
size 339436
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:65613a6d61b256a3bbf0d9c08992dbd38a45449ab778e9152a00199e6b6cbd0b
size 378575
oid sha256:5ed2fe6d8dbec14cc7f97d0ede2b86d0c1dbbbc559cf95a9fa2fdbbdbe8bd785
size 378187
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3f4ceb7aab76537608639630780df60331f7ba8ee6d775ff489c320e45773a73
size 313849
oid sha256:2c6e64db92199ab4f6239a2ede5240f4bc22fb1f533e455d9787910c14270ec4
size 313456
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3f4ceb7aab76537608639630780df60331f7ba8ee6d775ff489c320e45773a73
size 313849
oid sha256:2c6e64db92199ab4f6239a2ede5240f4bc22fb1f533e455d9787910c14270ec4
size 313456