Skip to content

Commit

Permalink
Add specific UX for Expected UTDs due to membership
Browse files Browse the repository at this point in the history
  • Loading branch information
BillCarsonFr committed Apr 24, 2024
1 parent f916309 commit b9649b4
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/matrix-org/matrix-analytics-events",
"state" : {
"revision" : "f756bf0756b7349a1d3ccee0d038790d1ab2ec56",
"version" : "0.14.0"
"revision" : "e4e49896331c9dcf7346c90529a9aad7944a3259",
"version" : "0.20.0"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@
"common_poll_end_confirmation" = "Are you sure you want to end this poll?";
"common_poll_summary" = "Poll: %1$@";
"common_something_went_wrong" = "Something went wrong";
"common_unable_to_decrypt_no_access" = "You don't have access to this message";
"common_verify_device" = "Verify device";
"confirm_recovery_key_banner_message" = "Your chat backup is currently out of sync. You need to enter your recovery key to maintain access to your chat backup.";
"confirm_recovery_key_banner_title" = "Enter your recovery key";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,13 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
} else {
timeToDecryptMs = -1
}

analytics.trackError(context: nil, domain: .E2EE, name: .OlmKeysNotSentError, timeToDecryptMillis: timeToDecryptMs)

switch info.cause {
case .unknown:
analytics.trackError(context: nil, domain: .E2EE, name: .OlmKeysNotSentError, timeToDecryptMillis: timeToDecryptMs)
case .membership:
analytics.trackError(context: nil, domain: .E2EE, name: .HistoricalMessage, timeToDecryptMillis: timeToDecryptMs)
}
}
.store(in: &cancellables)
}
Expand Down
2 changes: 2 additions & 0 deletions ElementX/Sources/Generated/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,8 @@ internal enum L10n {
internal static var commonTouchIdIos: String { return L10n.tr("Localizable", "common_touch_id_ios") }
/// Unable to decrypt
internal static var commonUnableToDecrypt: String { return L10n.tr("Localizable", "common_unable_to_decrypt") }
/// You don't have access to this message
internal static var commonUnableToDecryptNoAccess: String { return L10n.tr("Localizable", "common_unable_to_decrypt_no_access") }
/// Invites couldn't be sent to one or more users.
internal static var commonUnableToInviteMessage: String { return L10n.tr("Localizable", "common_unable_to_invite_message") }
/// Unable to send invite(s)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class RoomScreenInteractionHandler {

if let encryptedItem = timelineItem as? EncryptedRoomTimelineItem {
switch encryptedItem.encryptionType {
case .megolmV1AesSha2(let sessionID):
case .megolmV1AesSha2(let sessionID, _):
debugActions.append(.retryDecryption(sessionID: sessionID))
default:
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,30 @@
// limitations under the License.
//

import CompoundDesignTokens
import MatrixRustSDK
import SwiftUI

struct EncryptedRoomTimelineView: View {
let timelineItem: EncryptedRoomTimelineItem

var icon: KeyPath<CompoundIcons, Image> {
switch timelineItem.encryptionType {
case .megolmV1AesSha2(_, let cause):
switch cause {
case .unknown:
return \.time
case .membership:
return \.block
}
default:
return \.time
}
}

var body: some View {
TimelineStyler(timelineItem: timelineItem) {
Label(timelineItem.body, icon: \.time, iconSize: .small, relativeTo: .compound.bodyLG)
Label(timelineItem.body, icon: icon, iconSize: .small, relativeTo: .compound.bodyLG)
.labelStyle(RoomTimelineViewLabelStyle())
.font(.compound.bodyLG)
}
Expand Down Expand Up @@ -68,6 +84,10 @@ struct EncryptedRoomTimelineView_Previews: PreviewProvider, TestablePreview {
timestamp: "Later",
isOutgoing: true,
senderId: "Anne"))

EncryptedRoomTimelineView(timelineItem: expectedItemWith(timestamp: "Now",
isOutgoing: false,
senderId: "Bob"))
}
}

Expand All @@ -81,4 +101,15 @@ struct EncryptedRoomTimelineView_Previews: PreviewProvider, TestablePreview {
canBeRepliedTo: false,
sender: .init(id: senderId))
}

private static func expectedItemWith(timestamp: String, isOutgoing: Bool, senderId: String) -> EncryptedRoomTimelineItem {
EncryptedRoomTimelineItem(id: .random,
body: "You don't have access to this message",
encryptionType: .megolmV1AesSha2(sessionId: "foo", cause: UtdCause.membership),
timestamp: timestamp,
isOutgoing: isOutgoing,
isEditable: false,
canBeRepliedTo: false,
sender: .init(id: senderId))
}
}
12 changes: 11 additions & 1 deletion ElementX/Sources/Services/Analytics/AnalyticsService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,17 @@ extension AnalyticsService {
/// Can be found in `UnableToDecryptInfo`. In case the `UnableToDecryptInfo` contains the value as nil, pass it as `-1`
func trackError(context: String?, domain: AnalyticsEvent.Error.Domain, name: AnalyticsEvent.Error.Name, timeToDecryptMillis: Int? = nil) {
// CryptoModule is deprecated
capture(event: AnalyticsEvent.Error(context: context, cryptoModule: nil, cryptoSDK: .Rust, domain: domain, name: name, timeToDecryptMillis: timeToDecryptMillis))
capture(event: AnalyticsEvent.Error(context: context,
cryptoModule: .Rust,
cryptoSDK: .Rust,
domain: domain,
eventLocalAgeMillis: nil,
isFederated: nil,
isMatrixDotOrg: nil,
name: name,
timeToDecryptMillis: timeToDecryptMillis,
userTrustsOwnIdentity: nil,
wasVisibleToUser: nil))
}

/// Track the creation of a room
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@
// limitations under the License.
//

import CompoundDesignTokens
import MatrixRustSDK
import SwiftUI
import UIKit

struct EncryptedRoomTimelineItem: EventBasedTimelineItemProtocol, Equatable {
enum EncryptionType: Hashable {
case megolmV1AesSha2(sessionId: String)
case megolmV1AesSha2(sessionId: String, cause: UtdCause)
case olmV1Curve25519AesSha2(senderKey: String)
case unknown
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,24 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
_ encryptedMessage: EncryptedMessage,
_ isOutgoing: Bool) -> RoomTimelineItemProtocol {
var encryptionType = EncryptedRoomTimelineItem.EncryptionType.unknown
var errorLabel = L10n.commonWaitingForDecryptionKey
switch encryptedMessage {
case .megolmV1AesSha2(let sessionId):
encryptionType = .megolmV1AesSha2(sessionId: sessionId)
case .megolmV1AesSha2(let sessionId, let cause):
encryptionType = .megolmV1AesSha2(sessionId: sessionId, cause: cause)
switch cause {
case .unknown:
errorLabel = L10n.commonWaitingForDecryptionKey
case .membership:
errorLabel = L10n.commonUnableToDecryptNoAccess
}
case .olmV1Curve25519AesSha2(let senderKey):
encryptionType = .olmV1Curve25519AesSha2(senderKey: senderKey)
default:
break
}

return EncryptedRoomTimelineItem(id: eventItemProxy.id,
body: L10n.commonWaitingForDecryptionKey,
body: errorLabel,
encryptionType: encryptionType,
timestamp: eventItemProxy.timestamp.formatted(date: .omitted, time: .shortened),
isOutgoing: isOutgoing,
Expand Down

0 comments on commit b9649b4

Please sign in to comment.