Skip to content

Commit

Permalink
Clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
yostyle committed Oct 12, 2022
1 parent dd9cc41 commit fbbc4ee
Showing 1 changed file with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,23 @@ public class VoiceBroadcastService: NSObject {
/// - samples: an array of floating point values normalized to [0, 1], boxed within NSNumbers
/// - success: A block object called when the operation succeeds. It returns the event id of the event generated on the homeserver
/// - failure: A block object called when the operation fails.
func sendChunkOfVoiceBroadcast(audioFileLocalURL: URL, mimeType: String?, duration: UInt, samples: [Float]?, success:@escaping ((String?) -> Void), failure:@escaping ((Error?) -> Void)) {
func sendChunkOfVoiceBroadcast(audioFileLocalURL: URL,
mimeType: String?,
duration: UInt,
samples: [Float]?,
success:@escaping ((String?) -> Void),
failure:@escaping ((Error?) -> Void)) {
guard let voiceBroadcastInfoEventId = self.voiceBroadcastInfoEventId else {
return failure(VoiceBroadcastServiceError.notStarted)
}

self.room.sendChunkOfVoiceBroadcast(localURL: audioFileLocalURL, voiceBroadcastInfoEventId: voiceBroadcastInfoEventId, mimeType: mimeType, duration: duration, samples: samples, success: success, failure: failure)
self.room.sendChunkOfVoiceBroadcast(localURL: audioFileLocalURL,
voiceBroadcastInfoEventId: voiceBroadcastInfoEventId,
mimeType: mimeType,
duration: duration,
samples: samples,
success: success,
failure: failure)
}

// MARK: - Private
Expand Down Expand Up @@ -153,7 +164,8 @@ public class VoiceBroadcastService: NSObject {
return nil
}

return self.room.sendStateEvent(.custom(VoiceBroadcastSettings.eventType), content: stateEventContent, stateKey: stateKey) { [weak self] response in
return self.room.sendStateEvent(.custom(VoiceBroadcastSettings.eventType),
content: stateEventContent, stateKey: stateKey) { [weak self] response in
guard let self = self else { return }

switch response {
Expand Down Expand Up @@ -264,7 +276,8 @@ extension MXRoom {
let boxedSamples = samples?.compactMap { NSNumber(value: $0) }


guard let relatesTo = MXEventContentRelatesTo(relationType: MXEventRelationTypeReference, eventId: voiceBroadcastInfoEventId).jsonDictionary() as? [String: Any] else {
guard let relatesTo = MXEventContentRelatesTo(relationType: MXEventRelationTypeReference,
eventId: voiceBroadcastInfoEventId).jsonDictionary() as? [String: Any] else {
failure(VoiceBroadcastServiceError.unknown)
return nil
}
Expand Down

0 comments on commit fbbc4ee

Please sign in to comment.