mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Permalink Tweaks 2 (#2766)
* Missing changelog. * Parse bare room aliases as permalinks. Update the SDK. * Fix tapping the same permalink twice. Add a test. Don't clear the focussed item when reaching the bottom of the timeline. * Make sure sending a message returns to live.
This commit is contained in:
@@ -218,6 +218,16 @@ struct AttributedStringBuilder: AttributedStringBuilderProtocol {
|
||||
return TextParsingMatch(type: .userID(identifier: identifier), range: match.range)
|
||||
}
|
||||
|
||||
matches.append(contentsOf: MatrixEntityRegex.roomAliasRegex.matches(in: string, options: []).compactMap { match in
|
||||
guard let matchRange = Range(match.range, in: string) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
let alias = String(string[matchRange])
|
||||
|
||||
return TextParsingMatch(type: .roomAlias(alias: alias), range: match.range)
|
||||
})
|
||||
|
||||
matches.append(contentsOf: MatrixEntityRegex.linkRegex.matches(in: string, options: []).compactMap { match in
|
||||
guard let matchRange = Range(match.range, in: string) else {
|
||||
return nil
|
||||
@@ -257,6 +267,10 @@ struct AttributedStringBuilder: AttributedStringBuilderProtocol {
|
||||
switch match.type {
|
||||
case .atRoom:
|
||||
attributedString.addAttribute(.MatrixAllUsersMention, value: true, range: match.range)
|
||||
case .roomAlias(let alias):
|
||||
if let url = try? matrixToRoomAliasPermalink(roomAlias: alias) {
|
||||
attributedString.addAttribute(.link, value: url, range: match.range)
|
||||
}
|
||||
case .userID, .link:
|
||||
if let url = match.link {
|
||||
attributedString.addAttribute(.link, value: url, range: match.range)
|
||||
@@ -363,6 +377,7 @@ protocol MentionBuilderProtocol {
|
||||
private struct TextParsingMatch {
|
||||
enum MatchType {
|
||||
case userID(identifier: String)
|
||||
case roomAlias(alias: String)
|
||||
case link(urlString: String)
|
||||
case atRoom
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user