Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bugfix/dropdown-fix] fix comments property in recording screen in ti… #35

Merged
merged 1 commit into from
Feb 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ extension RecordView {

let storage = try await screenRecordingService.uploadRecording()
let jsonString = try JSONMapper.map(storage)

gleanManager.setScreenRecording(jsonString, identifier: uuid)

let jsonStringToScreenRecording = prepareScreenRecording(jsonString: jsonString)

gleanManager.setScreenRecording(jsonStringToScreenRecording, identifier: uuid)
gleanManager.submitScreenRecording()

state = .success
Expand All @@ -135,6 +137,25 @@ extension RecordView {
}
}

func prepareScreenRecording(jsonString: String) -> String {
var screenRecordingDict: [String: Any] = [:]

if let jsonDataRepresentation = jsonString.data(using: .utf8),
let jsonObject = try? JSONSerialization.jsonObject(with: jsonDataRepresentation) as? [String:Any] {
screenRecordingDict["recordingInfo"] = jsonObject
}

screenRecordingDict["comments"] = videoComments

guard let jsonSerializedData = try? JSONSerialization.data(withJSONObject: screenRecordingDict, options: .prettyPrinted) else {
return jsonString
}

guard let jsonSerializedString = String(data: jsonSerializedData, encoding: .utf8) else { return jsonString }

return jsonSerializedString
}

func cancelRecording() {
try? screenRecordingService.removeRecording()

Expand Down