Add device keys to rageshakes (#2838)

This commit is contained in:
Valere
2024-05-21 10:54:16 +02:00
committed by GitHub
parent 2e35db04db
commit f0ac0a63fb
16 changed files with 198 additions and 39 deletions
@@ -25,8 +25,7 @@ enum BugReportScreenCoordinatorAction {
struct BugReportScreenCoordinatorParameters {
let bugReportService: BugReportServiceProtocol
let userID: String?
let deviceID: String?
let userSession: UserSessionProtocol?
let userIndicatorController: UserIndicatorControllerProtocol?
let screenshot: UIImage?
@@ -47,8 +46,7 @@ final class BugReportScreenCoordinator: CoordinatorProtocol {
self.parameters = parameters
viewModel = BugReportScreenViewModel(bugReportService: parameters.bugReportService,
userID: parameters.userID,
deviceID: parameters.deviceID,
clientProxy: parameters.userSession?.clientProxy,
screenshot: parameters.screenshot,
isModallyPresented: parameters.isModallyPresented)
}
@@ -21,8 +21,7 @@ typealias BugReportScreenViewModelType = StateStoreViewModel<BugReportScreenView
class BugReportScreenViewModel: BugReportScreenViewModelType, BugReportScreenViewModelProtocol {
private let bugReportService: BugReportServiceProtocol
private let userID: String?
private let deviceID: String?
private let clientProxy: ClientProxyProtocol?
private let actionsSubject: PassthroughSubject<BugReportScreenViewModelAction, Never> = .init()
// periphery:ignore - when set to nil this is automatically cancelled
@@ -33,13 +32,11 @@ class BugReportScreenViewModel: BugReportScreenViewModelType, BugReportScreenVie
}
init(bugReportService: BugReportServiceProtocol,
userID: String?,
deviceID: String?,
clientProxy: ClientProxyProtocol?,
screenshot: UIImage?,
isModallyPresented: Bool) {
self.bugReportService = bugReportService
self.userID = userID
self.deviceID = deviceID
self.clientProxy = clientProxy
let bindings = BugReportScreenViewStateBindings(reportText: "", sendingLogsEnabled: true, canContact: false)
super.init(initialViewState: BugReportScreenViewState(screenshot: screenshot,
@@ -86,8 +83,12 @@ class BugReportScreenViewModel: BugReportScreenViewModelType, BugReportScreenVie
// Continue anyway without the screenshot.
}
}
let bugReport = BugReport(userID: userID,
deviceID: deviceID,
let ed25519 = await clientProxy?.ed25519Base64()
let curve25519 = await clientProxy?.curve25519Base64()
let bugReport = BugReport(userID: clientProxy?.userID,
deviceID: clientProxy?.deviceID,
ed25519: ed25519,
curve25519: curve25519,
text: context.reportText,
includeLogs: context.sendingLogsEnabled,
canContact: context.canContact,
@@ -149,18 +149,18 @@ struct BugReportScreen: View {
struct BugReport_Previews: PreviewProvider, TestablePreview {
static var previews: some View {
NavigationStack {
let clientProxy = ClientProxyMock(.init(userID: "@mock:client.com", roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded(.mockRooms)))))
BugReportScreen(context: BugReportScreenViewModel(bugReportService: BugReportServiceMock(),
userID: "@mock.client.com",
deviceID: nil,
clientProxy: clientProxy,
screenshot: nil,
isModallyPresented: false).context)
.previewDisplayName("Without Screenshot")
}
NavigationStack {
let clientProxy = ClientProxyMock(.init(userID: "@mock:client.com", roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded(.mockRooms)))))
BugReportScreen(context: BugReportScreenViewModel(bugReportService: BugReportServiceMock(),
userID: "@mock.client.com",
deviceID: nil,
clientProxy: clientProxy,
screenshot: Asset.Images.appLogo.image,
isModallyPresented: false).context)
.previewDisplayName("With Screenshot")