diff --git a/Ring/Cartfile.resolved b/Ring/Cartfile.resolved index ffb71a370639f89dac3d0733f10fb376817df177..48e40c031d9400b97133bf5aafe29ee31ee0d511 100644 --- a/Ring/Cartfile.resolved +++ b/Ring/Cartfile.resolved @@ -1,5 +1,5 @@ github "AliSoftware/Reusable" "4.1.1" -github "ReactiveX/RxSwift" "5.1.1" +github "ReactiveX/RxSwift" "6.2.0" github "RxSwiftCommunity/RxDataSources" "4.0.1" github "RxSwiftCommunity/RxRealm" "3.1.0" github "SwiftyBeaver/SwiftyBeaver" "1.9.2" @@ -7,5 +7,5 @@ github "andreamazz/AMPopTip" "4.5.0" github "ashleymills/Reachability.swift" "v5.1.0" github "gskbyte/GSKStretchyHeaderView" "1.0.4" github "pkluz/PKHUD" "5.4.0" -github "realm/realm-cocoa" "v5.5.0" +github "realm/realm-cocoa" "v10.7.4" github "stephencelis/SQLite.swift" "0.12.2" diff --git a/Ring/Ring/Account/VCardUtils.swift b/Ring/Ring/Account/VCardUtils.swift index 1043d20eeaef00531fa998e4d47b99b035f86ea1..81351268f6b63d21b8638a5aaaaeeafccec61561 100644 --- a/Ring/Ring/Account/VCardUtils.swift +++ b/Ring/Ring/Account/VCardUtils.swift @@ -38,18 +38,18 @@ class VCardUtils { if let vCard = contactRequest.vCard { single(.success(vCard)) } else { - single(.error(ContactServiceError.loadVCardFailed)) + single(.failure(ContactServiceError.loadVCardFailed)) } } else if let directoryURL = VCardUtils.getFilePath(forFile: name, inFolder: folder, createIfNotExists: false) { if let data = FileManager.default.contents(atPath: directoryURL.path) { if let vCard = CNContactVCardSerialization.parseToVCard(data: data) { single(.success(vCard)) } else { - single(.error(ContactServiceError.loadVCardFailed)) + single(.failure(ContactServiceError.loadVCardFailed)) } } } else { - single(.error(ContactServiceError.loadVCardFailed)) + single(.failure(ContactServiceError.loadVCardFailed)) } return Disposables.create { } }) diff --git a/Ring/Ring/AppDelegate.swift b/Ring/Ring/AppDelegate.swift index 998c6bf5cbbe5381a7ef91d350e02bb9755e09f1..1f018e89c2ae6e92be53cc0384bbdffd5d146f4d 100644 --- a/Ring/Ring/AppDelegate.swift +++ b/Ring/Ring/AppDelegate.swift @@ -97,7 +97,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // ignore sigpipe - // swiftlint:disable nesting typealias SigHandler = @convention(c) (Int32) -> Void let SIG_IGN = unsafeBitCast(OpaquePointer(bitPattern: 1), to: SigHandler.self) signal(SIGPIPE, SIG_IGN) @@ -196,7 +195,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD .disposed(by: self.disposeBag) self.accountService.initialAccountsLoading() .subscribe(onCompleted: { - //set selected account if exists + // set selected account if exists self.appCoordinator.start() if self.accountService.hasAccountWithProxyEnabled() { self.registerVoipNotifications() @@ -209,7 +208,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD } guard let currentAccount = self.accountService.currentAccount else { self.log.error("Can't get current account!") - //if we don't have any account means it is first run, so enable hardware acceleration + // if we don't have any account means it is first run, so enable hardware acceleration self.videoService.setHardwareAccelerated(withState: true) UserDefaults.standard.set(true, forKey: hardareAccelerationKey) return @@ -405,15 +404,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD } func findContactAndStartCall(hash: String, isVideo: Bool) { - //if saved jami hash + // if saved jami hash if hash.isSHA1() { let contactUri = JamiURI(schema: URIType.ring, infoHach: hash) self.findAccountAndStartCall(uri: contactUri, isVideo: isVideo, type: AccountType.ring) return } - //if saved jami registered name + // if saved jami registered name self.nameService.usernameLookupStatus - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .filter({ usernameLookupStatus in usernameLookupStatus.name == hash }) @@ -424,7 +423,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD let contactUri = JamiURI(schema: URIType.ring, infoHach: address) self.findAccountAndStartCall(uri: contactUri, isVideo: isVideo, type: AccountType.ring) } else { - //if saved sip contact + // if saved sip contact let contactUri = JamiURI(schema: URIType.sip, infoHach: hash) self.findAccountAndStartCall(uri: contactUri, isVideo: isVideo, type: AccountType.sip) } diff --git a/Ring/Ring/Calls/ButtonsContainerView.swift b/Ring/Ring/Calls/ButtonsContainerView.swift index 55595b5bc501e9d35b26d20e187cab8b1f23769a..a02d06abb0713c08062121e0a9ab389ec463a844 100644 --- a/Ring/Ring/Calls/ButtonsContainerView.swift +++ b/Ring/Ring/Calls/ButtonsContainerView.swift @@ -24,7 +24,7 @@ import RxSwift class ButtonsContainerView: UIView, NibLoadable, UIScrollViewDelegate { - //Outlets + // Outlets @IBOutlet var containerView: UIView! @IBOutlet weak var container: UIView! @IBOutlet weak var stackView: UIStackView! @@ -35,13 +35,13 @@ class ButtonsContainerView: UIView, NibLoadable, UIScrollViewDelegate { @IBOutlet weak var pageControl: UIPageControl! @IBOutlet weak var scrollView: UIScrollView! - //Constraints + // Constraints @IBOutlet weak var cancelButtonWidthConstraint: NSLayoutConstraint! @IBOutlet weak var cancelButtonHeightConstraint: NSLayoutConstraint! @IBOutlet weak var cancelButtonBottomConstraint: NSLayoutConstraint! @IBOutlet weak var containerHeightConstraint: NSLayoutConstraint! - //Buttons + // Buttons var muteAudioButton: UIButton! var muteVideoButton: UIButton! var pauseCallButton: UIButton! @@ -57,7 +57,7 @@ class ButtonsContainerView: UIView, NibLoadable, UIScrollViewDelegate { var viewModel: ButtonsContainerViewModel? { didSet { self.viewModel?.observableCallOptions - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] callOptions in switch callOptions { case .none: @@ -159,7 +159,7 @@ class ButtonsContainerView: UIView, NibLoadable, UIScrollViewDelegate { } else { let screenRect = UIScreen.main.bounds let screenWidth: CGFloat = screenRect.size.width - let buttonsWidth: CGFloat = 7 * 50 + 30 * 6 //540 + let buttonsWidth: CGFloat = 7 * 50 + 30 * 6 // 540 havePages = screenWidth < buttonsWidth firstPageStackView.removeSubviews() secondPageStackView.removeSubviews() diff --git a/Ring/Ring/Calls/CallViewController.swift b/Ring/Ring/Calls/CallViewController.swift index 13d8e01e2004938b043ad8eeaa7682b67d2e84ed..0f96b617016d91bc359399abf136b22e105c026a 100644 --- a/Ring/Ring/Calls/CallViewController.swift +++ b/Ring/Ring/Calls/CallViewController.swift @@ -29,7 +29,7 @@ import SwiftyBeaver // swiftlint:disable file_length class CallViewController: UIViewController, StoryboardBased, ViewModelBased, ContactPickerDelegate { - //preview screen + // preview screen @IBOutlet private weak var profileImageView: UIImageView! @IBOutlet private weak var nameLabel: UILabel! @IBOutlet private weak var durationLabel: UILabel! @@ -40,7 +40,7 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased, Con @IBOutlet private weak var mainView: UIView! - //video screen + // video screen @IBOutlet private weak var callView: UIView! @IBOutlet private weak var incomingVideo: UIImageView! @IBOutlet weak var beforeIncomingVideo: UIView! @@ -55,7 +55,7 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased, Con @IBOutlet weak var infoBlurEffect: UIVisualEffectView! @IBOutlet weak var leftArrow: UIImageView! - //Constraints + // Constraints @IBOutlet weak var capturedVideoWidthConstraint: NSLayoutConstraint! @IBOutlet weak var capturedVideoTrailingConstraint: NSLayoutConstraint! @IBOutlet weak var capturedVideoTopConstraint: NSLayoutConstraint! @@ -127,7 +127,7 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased, Con } NotificationCenter.default.rx .notification(UIDevice.orientationDidChangeNotification) - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: {[weak self] (_) in guard let self = self, UIDevice.current.portraitOrLandscape else { @@ -150,7 +150,7 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased, Con self.updateconferenceLayoutSize() self.viewModel.layoutUpdated .asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] updated in guard let self = self, updated else { return } self.updateconferenceLayoutSize() @@ -196,7 +196,7 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased, Con @objc func hideCapturedVideo() { - //if self.isMenuShowed { return } + // if self.isMenuShowed { return } UIView.animate(withDuration: 0.3, animations: { [weak self] in if self?.capturedVideoBlurEffect.alpha == 0 { self?.isVideoHidden = true @@ -205,7 +205,7 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased, Con self?.isVideoHidden = false self?.capturedVideoBlurEffect.alpha = 0 } - //guard let hidden = self?.infoContainer.isHidden else {return} + // guard let hidden = self?.infoContainer.isHidden else {return} self?.resizeCapturedVideo(withInfoContainer: false) self?.view.layoutIfNeeded() }) @@ -306,26 +306,26 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased, Con self.viewModel.showContactPickerVC() }) .disposed(by: self.disposeBag) - //Data bindings + // Data bindings self.viewModel.videoButtonState - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .bind(to: self.buttonsContainer.muteVideoButton.rx.image()) .disposed(by: self.disposeBag) self.buttonsContainer.muteVideoButton.isEnabled = !(self.viewModel.call?.isAudioOnly ?? false) self.viewModel.audioButtonState - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .bind(to: self.buttonsContainer.muteAudioButton.rx.image()) .disposed(by: self.disposeBag) self.viewModel.speakerButtonState - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .bind(to: self.buttonsContainer.switchSpeakerButton.rx.image()) .disposed(by: self.disposeBag) self.viewModel.pauseCallButtonState - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .bind(to: self.buttonsContainer.pauseCallButton.rx.image()) .disposed(by: self.disposeBag) } @@ -335,7 +335,7 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased, Con func setupBindings() { self.viewModel.contactImageData?.asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] dataOrNil in if let imageData = dataOrNil { if let image = UIImage(data: imageData) { @@ -346,7 +346,7 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased, Con .disposed(by: self.disposeBag) self.viewModel.dismisVC - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] dismiss in if dismiss { self?.removeFromScreen() @@ -365,7 +365,7 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased, Con self.viewModel.callDuration .asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] _ in if self?.durationLabel.text != "" { if self?.viewModel.isAudioOnly ?? true { @@ -384,12 +384,12 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased, Con .disposed(by: self.disposeBag) self.viewModel.bottomInfo - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .bind(to: self.infoBottomLabel.rx.text) .disposed(by: self.disposeBag) self.viewModel.incomingFrame - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] frame in if let image = frame { self?.spinner.stopAnimating() @@ -409,7 +409,7 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased, Con .disposed(by: self.disposeBag) self.viewModel.capturedFrame - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] frame in if let image = frame { DispatchQueue.main.async { @@ -420,7 +420,7 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased, Con .disposed(by: self.disposeBag) self.viewModel.showCallOptions - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] show in if show { self?.showContactInfo() @@ -429,7 +429,7 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased, Con .disposed(by: self.disposeBag) self.viewModel.showCancelOption - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] show in if show { self?.showCancelButton() @@ -441,23 +441,23 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased, Con self.resizeCapturedFrame() } self.viewModel.videoMuted - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .bind(to: self.capturedVideo.rx.isHidden) .disposed(by: self.disposeBag) self.viewModel.videoMuted - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .bind(to: self.capturedVideoBlurEffect.rx.isHidden) .disposed(by: self.disposeBag) self.viewModel.videoMuted - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .bind(to: self.leftArrow.rx.isHidden) .disposed(by: self.disposeBag) if !self.viewModel.isAudioOnly { self.viewModel.callPaused - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] show in self?.setAvatarView(show) }) @@ -466,7 +466,7 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased, Con self.viewModel.conferenceMode .asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] enteredConference in guard let call = self?.viewModel.call, let self = self else { return } @@ -522,7 +522,7 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased, Con .disposed(by: self.disposeBag) self.viewModel.callForConference - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] call in guard let self = self else { return } // for moderator participants will be added in layoutUpdated @@ -546,7 +546,7 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased, Con .disposed(by: self.disposeBag) self.viewModel.callPaused - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] show in if show { self?.showCallOptions() @@ -606,12 +606,12 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased, Con func resizeCapturedFrame() { self.viewModel.showCapturedFrame - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] dontShow in if dontShow && (!(self?.isCallStarted ?? false)) { self?.isCallStarted = true let device = UIDevice.modelName - //Reduce the cancel button for small iPhone + // Reduce the cancel button for small iPhone switch device { case "iPhone 5", "iPhone 5c", "iPhone 5s", "iPhone SE" : self?.buttonsContainer.cancelButtonWidthConstraint.constant = 50 @@ -668,7 +668,7 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased, Con DispatchQueue.global(qos: .background).async { sleep(UInt32(0.5)) DispatchQueue.main.async { [weak self] in - //guard let hidden = self?.infoContainer.isHidden else {return} + // guard let hidden = self?.infoContainer.isHidden else {return} self?.resizeCapturedVideo(withInfoContainer: false) self?.buttonsContainer.updateView() if UIDevice.current.hasNotch && (UIDevice.current.orientation == .landscapeRight || UIDevice.current.orientation == .landscapeLeft) && self?.infoContainer.isHidden == false { @@ -685,7 +685,7 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased, Con if self.viewModel.call?.state != .current { return } - //Don't change anything if the orientation change to portraitUpsideDown, faceUp or faceDown + // Don't change anything if the orientation change to portraitUpsideDown, faceUp or faceDown if UIDevice.current.orientation.rawValue != 5 && UIDevice.current.orientation.rawValue != 6 && UIDevice.current.orientation.rawValue != 2 { self.orientation = UIDevice.current.orientation } @@ -707,7 +707,7 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased, Con self.capturedVideoTopConstraint.constant = -15 } } else { - //Keep the 4:3 format of the video + // Keep the 4:3 format of the video let widthCapturedVideo = ((self.infoContainerHeightConstraint.constant - 20) / 3) * 4 self.capturedVideoHeightConstraint.constant = conference ? -UIScreen.main.bounds.height : -UIScreen.main.bounds.height + self.infoContainerHeightConstraint.constant - 20 self.capturedVideoWidthConstraint.constant = -UIScreen.main.bounds.width + widthCapturedVideo @@ -733,7 +733,7 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased, Con self.capturedVideoTopConstraint.constant = -5 } } else { - //Keep the 4:3 format of the video + // Keep the 4:3 format of the video let widthCapturedVideo = ((self.infoContainerHeightConstraint.constant - 20) / 4) * 3 self.capturedVideoHeightConstraint.constant = conference ? -UIScreen.main.bounds.height : -UIScreen.main.bounds.height + self.infoContainerHeightConstraint.constant - 20 self.capturedVideoWidthConstraint.constant = -UIScreen.main.bounds.width + widthCapturedVideo diff --git a/Ring/Ring/Calls/CallViewModel.swift b/Ring/Ring/Calls/CallViewModel.swift index 175524aba139b41bcb09da3e53ed96aa2191d3ed..d1362261c4d4aff72b958e934ac3b3837f5367c4 100644 --- a/Ring/Ring/Calls/CallViewModel.swift +++ b/Ring/Ring/Calls/CallViewModel.swift @@ -27,7 +27,7 @@ import Contacts import RxCocoa class CallViewModel: Stateable, ViewModel { - //stateable + // stateable private let stateSubject = PublishSubject<State>() lazy var state: Observable<State> = { return self.stateSubject.asObservable() @@ -197,9 +197,9 @@ class CallViewModel: Stateable, ViewModel { }) .map({ [weak self] call in let hide = !call.isExists() - //if it was conference call switch to another running call + // if it was conference call switch to another running call if hide && call.participantsCallId.count > 1 { - //switch to another call + // switch to another call let anotherCalls = call.participantsCallId.filter { (callID) -> Bool in self?.callService.call(callID: callID) != nil && callID != call.callId } @@ -230,7 +230,7 @@ class CallViewModel: Stateable, ViewModel { lazy var callDuration: Driver<String> = { let timer = Observable<Int>.interval(Durations.oneSecond.toTimeInterval(), scheduler: MainScheduler.instance) - .takeUntil(currentCall + .take(until: currentCall .filter { call in !call.isExists() }) @@ -435,8 +435,8 @@ class CallViewModel: Stateable, ViewModel { .subscribe(onNext: { [weak self] _ in guard let self = self else { return } self.audioService.startAudio() - //for outgoing calls ve create audio sesion with default parameters. - //for incoming call audio session is created, ve need to override it + // for outgoing calls ve create audio sesion with default parameters. + // for incoming call audio session is created, ve need to override it let overrideOutput = self.call?.callTypeValue == CallType.incoming.rawValue self.audioService.setDefaultOutput(toSpeaker: !self.isAudioOnly, override: overrideOutput) @@ -679,7 +679,7 @@ extension CallViewModel { guard let uri = participant.uri else { return } // master call if uri.isEmpty { - //check if master call is local or remote + // check if master call is local or remote if !self.isHostCall { participant.displayName = call.getDisplayName() } else { diff --git a/Ring/Ring/Calls/Conference/ConferenceLayout.swift b/Ring/Ring/Calls/Conference/ConferenceLayout.swift index bb40aba654fb7fcadd648b4bf2aafb904080b285..1568ae7c3fd443245a25a72b4a83b41dbc8cc078 100644 --- a/Ring/Ring/Calls/Conference/ConferenceLayout.swift +++ b/Ring/Ring/Calls/Conference/ConferenceLayout.swift @@ -36,7 +36,7 @@ class ConferenceLayout: UIView { self.conferenceLayoutHelper.setVideoSize(size: size) NotificationCenter.default.rx .notification(UIDevice.orientationDidChangeNotification) - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: {[weak self] (_) in guard UIDevice.current.portraitOrLandscape else { return } self?.updateViewSize() diff --git a/Ring/Ring/Calls/Conference/ContactPickerViewController.swift b/Ring/Ring/Calls/Conference/ContactPickerViewController.swift index 6141e7aec254bc873a0f7696133998c81db6d43e..2456f14421f0609270b4674c3f8c99536686351a 100644 --- a/Ring/Ring/Calls/Conference/ContactPickerViewController.swift +++ b/Ring/Ring/Calls/Conference/ContactPickerViewController.swift @@ -157,7 +157,7 @@ class ContactPickerViewController: UIViewController, StoryboardBased, ViewModelB } status .asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .startWith(status.value) .subscribe(onNext: { precence in cell.presenceIndicator?.isHidden = !precence diff --git a/Ring/Ring/Calls/views/ConferenceParticipantView.swift b/Ring/Ring/Calls/views/ConferenceParticipantView.swift index c747caad1de622221f00eb1306a021cda3c7c259..96752c8379185058bf47f1206d8cb03be51f4ab2 100644 --- a/Ring/Ring/Calls/views/ConferenceParticipantView.swift +++ b/Ring/Ring/Calls/views/ConferenceParticipantView.swift @@ -22,7 +22,7 @@ import UIKit import Reusable import RxSwift -protocol ConferenceParticipantViewDelegate: class { +protocol ConferenceParticipantViewDelegate: AnyObject { func addConferenceParticipantMenu(origin: CGPoint, displayName: String, participantId: String, callId: String?, hangup: @escaping (() -> Void)) func removeConferenceParticipantMenu() } @@ -81,7 +81,7 @@ class ConferenceParticipantView: UIView { private func bindViewToViewModel() { self.viewModel?.removeView? - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] remove in if remove { self?.delegate?.removeConferenceParticipantMenu() @@ -90,7 +90,7 @@ class ConferenceParticipantView: UIView { }) .disposed(by: self.disposeBag) self.viewModel?.avatarObservable - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe({ [weak self] profileData -> Void in let photoData = NSData(base64Encoded: profileData.element?.0 ?? "", options: NSData.Base64DecodingOptions.ignoreUnknownCharacters) as Data? let nameData = profileData.element?.1 diff --git a/Ring/Ring/Constants/Generated/Strings.swift b/Ring/Ring/Constants/Generated/Strings.swift index 4fa18e2d5fad5597d4cfa963468c767b78e66d34..369328c52ca94623394e546bff31ef65d259f2b3 100644 --- a/Ring/Ring/Constants/Generated/Strings.swift +++ b/Ring/Ring/Constants/Generated/Strings.swift @@ -14,7 +14,7 @@ internal enum L10n { internal enum Account { /// Account Status internal static let accountStatus = L10n.tr("Localizable", "account.accountStatus") - /// Create Sip Account + /// Create a SIP Account internal static let createSipAccount = L10n.tr("Localizable", "account.createSipAccount") /// Enable Account internal static let enableAccount = L10n.tr("Localizable", "account.enableAccount") diff --git a/Ring/Ring/Contact/ContactViewController.swift b/Ring/Ring/Contact/ContactViewController.swift index 673d83d64d346fbfbc9fa24dc2185b2aa216ecb2..0181c5c29395d3d8082a6875ea1326ec0f57b88c 100644 --- a/Ring/Ring/Contact/ContactViewController.swift +++ b/Ring/Ring/Contact/ContactViewController.swift @@ -73,7 +73,7 @@ class ContactViewController: UIViewController, StoryboardBased, ViewModelBased { return (profileImage, username) } .startWith((self.viewModel.profileImageData.value, self.viewModel.userName.value)) - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe({ [weak self] profileData -> Void in guard let data = profileData.element?.1 else { return } self?.stretchyHeader @@ -116,7 +116,7 @@ class ContactViewController: UIViewController, StoryboardBased, ViewModelBased { self.stretchyHeader.jamiID.text = self.viewModel.conversation.hash self.viewModel.titleName - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] name in self?.titleView.text = name }) @@ -148,12 +148,12 @@ class ContactViewController: UIViewController, StoryboardBased, ViewModelBased { let dataSource = RxTableViewSectionedReloadDataSource<SectionModel<String, ContactActions>>(configureCell: configureCell) self.viewModel.tableSection - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .bind(to: self.tableView.rx.items(dataSource: dataSource)) .disposed(by: disposeBag) self.tableView.rx.itemSelected - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] indexPath in if self?.tableView.cellForRow(at: indexPath) != nil { switch indexPath.row { @@ -220,7 +220,7 @@ extension ContactViewController: UITableViewDelegate { var titlViewThreshold: CGFloat = 0 let screenSize = UIScreen.main.bounds.size if let height = navigationHeight { - //height for iphoneX + // height for iphoneX if UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.phone, screenSize.height == 812.0 { size.height -= (height - 10) diff --git a/Ring/Ring/Coordinators/AppCoordinator.swift b/Ring/Ring/Coordinators/AppCoordinator.swift index 0e3e69ec3f6c5a67c48778faaa71dad0710585de..32a1db677f13a397e4ff633714a59b0ca614a5a7 100644 --- a/Ring/Ring/Coordinators/AppCoordinator.swift +++ b/Ring/Ring/Coordinators/AppCoordinator.swift @@ -95,9 +95,9 @@ final class AppCoordinator: Coordinator, StateableResponsive { /// Starts the coordinator func start () { - //~ By default, always present the initial loading at start + // ~ By default, always present the initial loading at start self.stateSubject.onNext(AppState.initialLoading) - //~ Dispatch to the proper screen + // ~ Dispatch to the proper screen self.dispatchApplication() } diff --git a/Ring/Ring/Database/DBContainer.swift b/Ring/Ring/Database/DBContainer.swift index e3689578be736c0ea58fa7b9f06408fbb89d9566..ec2d853131dd3e51ae73a911ad903f5cbd09b539 100644 --- a/Ring/Ring/Database/DBContainer.swift +++ b/Ring/Ring/Database/DBContainer.swift @@ -21,7 +21,7 @@ import SQLite import SwiftyBeaver -//================================================================================ +// ================================================================================ // jami files structure // // Jami Documents folder @@ -38,7 +38,7 @@ import SwiftyBeaver // │ └── ... // ├── ring_device.crt // └── ring_device.key -//================================================================================ +// ================================================================================ enum DataAccessError: Error { case datastoreConnectionError diff --git a/Ring/Ring/Database/DBHelpers/InteractionDataHelper.swift b/Ring/Ring/Database/DBHelpers/InteractionDataHelper.swift index 6d6d0d52e722355509f5d015e151102f84c472ee..e2b8c847c51c08de64259ec9c1dd75d9432c6ec5 100644 --- a/Ring/Ring/Database/DBHelpers/InteractionDataHelper.swift +++ b/Ring/Ring/Database/DBHelpers/InteractionDataHelper.swift @@ -48,12 +48,12 @@ final class InteractionDataHelper { let daemonId = Expression<String>("daemon_id") let incoming = Expression<Bool>("incoming") - //foreign keys references + // foreign keys references let tableProfiles = Table("profiles") let tableConversations = Table("conversations") let uri = Expression<String>("uri") - //migrations from legacy db + // migrations from legacy db let authorId = Expression<Int64>("author_id") let conversationId = Expression<Int64>("conversation_id") @@ -82,7 +82,7 @@ final class InteractionDataHelper { func migrateMessageBody(body: String, type: String) -> (body: String, duration: Int64) { switch type { case InteractionType.call.rawValue: - //check if have call duration + // check if have call duration if let index = body.firstIndex(of: "-") { let timeIndex = body.index(index, offsetBy: 2) let durationString = body.suffix(from: timeIndex) diff --git a/Ring/Ring/Database/DBManager.swift b/Ring/Ring/Database/DBManager.swift index 71726f8237d6bbe660e3390be39867218d39295b..7f208f8dd97b038e6098fb0ac75ce88c0f2d5aeb 100644 --- a/Ring/Ring/Database/DBManager.swift +++ b/Ring/Ring/Database/DBManager.swift @@ -285,7 +285,7 @@ class DBManager { message: MessageModel, incoming: Bool, interactionType: InteractionType, duration: Int) -> Observable<SavedMessageForConversation> { - //create completable which will be executed on background thread + // create completable which will be executed on background thread return Observable.create { [weak self] observable in do { guard let dataBase = self?.dbConnections.forAccount(account: accountId) else { diff --git a/Ring/Ring/Dialpad/DialpadViewController.swift b/Ring/Ring/Dialpad/DialpadViewController.swift index 7d6051f0445a31d2f87950bdf36e9900e6932cc8..a7cecd907e36fa8ba4db776503024a2027a8fe7c 100644 --- a/Ring/Ring/Dialpad/DialpadViewController.swift +++ b/Ring/Ring/Dialpad/DialpadViewController.swift @@ -50,7 +50,7 @@ class DialpadViewController: UIViewController, StoryboardBased, ViewModelBased { } self.viewModel.observableNumber .asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .bind(to: numberLabel.rx.text) .disposed(by: self.disposeBag) placeCallButton.rx.tap @@ -73,14 +73,14 @@ class DialpadViewController: UIViewController, StoryboardBased, ViewModelBased { .disposed(by: self.disposeBag) self.viewModel.observableNumber .asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { text in self.clearButton.isHidden = text.isEmpty }) .disposed(by: self.disposeBag) self.viewModel.playDefaultSound .asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { play in if !play { return } AudioServicesPlaySystemSound(1057) diff --git a/Ring/Ring/EditProfileViewController.swift b/Ring/Ring/EditProfileViewController.swift index 5342dc8ec2a00f6ee3286241f2f9ceae4fb794e3..2df4ebc4f848fc5154ef130783f6a8fe511ec7dd 100644 --- a/Ring/Ring/EditProfileViewController.swift +++ b/Ring/Ring/EditProfileViewController.swift @@ -45,7 +45,7 @@ class EditProfileViewController: UIViewController, UITextFieldDelegate, UIImageP .bind(to: self.profileName.rx.text) .disposed(by: disposeBag) - //Binds the keyboard Send button action to the ViewModel + // Binds the keyboard Send button action to the ViewModel self.profileName.rx.controlEvent(.editingDidEndOnExit) .subscribe(onNext: { [weak self] _ in guard let self = self else { return } diff --git a/Ring/Ring/Extensions/UIImage+Helpers.swift b/Ring/Ring/Extensions/UIImage+Helpers.swift index 8cb51c6f8eac7818ba66349f533bc80ef586db7b..11eb97ae04f313bae671866dbe59c4573cba5cb1 100644 --- a/Ring/Ring/Extensions/UIImage+Helpers.swift +++ b/Ring/Ring/Extensions/UIImage+Helpers.swift @@ -195,7 +195,7 @@ extension UIImage { } func drawText(text: String, backgroundColor: UIColor, textColor: UIColor, size: CGSize) -> UIImage? { - //Setups up the font attributes that will be later used to dictate how the text should be drawn + // Setups up the font attributes that will be later used to dictate how the text should be drawn let textFont = UIFont.systemFont(ofSize: 20, weight: .semibold) let textFontAttributes = [ NSAttributedString.Key.font: textFont, @@ -204,7 +204,7 @@ extension UIImage { UIGraphicsBeginImageContextWithOptions(size, false, 0) backgroundColor.setFill() UIRectFill(rect) - //Put the image into a rectangle as large as the original image. + // Put the image into a rectangle as large as the original image. self.draw(in: rect) // Our drawing bounds let textSize = text.size(withAttributes: [NSAttributedString.Key.font: textFont]) diff --git a/Ring/Ring/Extensions/UIView+Rx.swift b/Ring/Ring/Extensions/UIView+Rx.swift index eb6615864ee88b8e31032fb654837555d919aa6a..8f5cd8caf7a07b58fe513a66ae695fe13e3ecb11 100644 --- a/Ring/Ring/Extensions/UIView+Rx.swift +++ b/Ring/Ring/Extensions/UIView+Rx.swift @@ -24,7 +24,7 @@ import RxCocoa extension Reactive where Base: UIView { - //show view with animation and hide without + // show view with animation and hide without public var isVisible: AnyObserver<Bool> { return Binder(self.base) { view, hidden in if hidden == true { diff --git a/Ring/Ring/Extensions/UIViewController+Ring.swift b/Ring/Ring/Extensions/UIViewController+Ring.swift index 8b75b9816da1aef11fa2376e7e0bb3fc982a3aac..48dbaff7b0d113b307dd1a5bbd9e3bbdcccb30d1 100644 --- a/Ring/Ring/Extensions/UIViewController+Ring.swift +++ b/Ring/Ring/Extensions/UIViewController+Ring.swift @@ -74,7 +74,7 @@ extension UIViewController { /// - disposeBag: The RxSwift DisposeBag linked to the UIViewController life cycle func adaptToKeyboardState (for scrollView: UIScrollView, with disposeBag: DisposeBag) { - NotificationCenter.keyboardHeight.observeOn(MainScheduler.instance) + NotificationCenter.keyboardHeight.observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self, weak scrollView] (height) in guard let self = self, let scrollView = scrollView else { return } let trueHeight = height > 0 ? height + 100 : 0.0 @@ -98,7 +98,7 @@ extension UIViewController { func adaptTableToKeyboardState (for tableView: UITableView, with disposeBag: DisposeBag, topOffset: CGFloat? = nil, bottomOffset: CGFloat? = nil) { NotificationCenter.keyboardHeight - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self, weak tableView] (height) in guard let self = self, let tableView = tableView else { return } let trueHeight = height > 0 ? height + 100 : 0.0 diff --git a/Ring/Ring/Features/ContactRequests/Cells/ContactRequestCell.swift b/Ring/Ring/Features/ContactRequests/Cells/ContactRequestCell.swift index 7738ca401bd1ad59a51ed160a8a50c852b7cd6c7..e270781c88e21e4d9dc8e52959c3e9633edd73a1 100644 --- a/Ring/Ring/Features/ContactRequests/Cells/ContactRequestCell.swift +++ b/Ring/Ring/Features/ContactRequests/Cells/ContactRequestCell.swift @@ -85,7 +85,7 @@ class ContactRequestCell: UITableViewCell, NibReusable { return (profileImage, username) } .startWith((item.profileImageData.value, item.userName.value)) - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe({ [weak self] profileData -> Void in guard let data = profileData.element?.1 else { return @@ -103,7 +103,7 @@ class ContactRequestCell: UITableViewCell, NibReusable { // name item.bestName .asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .bind(to: self.nameLabel.rx.text) .disposed(by: self.disposeBag) diff --git a/Ring/Ring/Features/ContactRequests/ContactRequestsViewController.swift b/Ring/Ring/Features/ContactRequests/ContactRequestsViewController.swift index afcbc5d545f401e76afbd1ca967feaa234b4e600..d79a32bf45b0ba7f95afb76082fb15fcf2bdeadc 100644 --- a/Ring/Ring/Features/ContactRequests/ContactRequestsViewController.swift +++ b/Ring/Ring/Features/ContactRequests/ContactRequestsViewController.swift @@ -75,17 +75,17 @@ class ContactRequestsViewController: UIViewController, StoryboardBased, ViewMode self.tableView.allowsSelection = true self.tableView.tableFooterView = UIView() - //Register cell + // Register cell self.tableView.register(cellType: ContactRequestCell.self) - //Bind the TableView to the ViewModel + // Bind the TableView to the ViewModel self.viewModel .contactRequestItems - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .bind(to: tableView.rx.items(cellIdentifier: cellIdentifier, cellType: ContactRequestCell.self)) { [weak self] _, item, cell in cell.configureFromItem(item) - //Accept button + // Accept button cell.acceptButton.backgroundColor = UIColor.clear cell.acceptButton.rx.tap .subscribe(onNext: { [weak self] in @@ -96,7 +96,7 @@ class ContactRequestsViewController: UIViewController, StoryboardBased, ViewMode }) .disposed(by: cell.disposeBag) - //Discard button + // Discard button cell.discardButton.backgroundColor = UIColor.clear cell.discardButton.rx.tap .subscribe(onNext: { [weak self] in @@ -105,7 +105,7 @@ class ContactRequestsViewController: UIViewController, StoryboardBased, ViewMode }) .disposed(by: cell.disposeBag) - //Ban button + // Ban button cell.banButton.backgroundColor = UIColor.clear cell.banButton.rx.tap .subscribe(onNext: { [weak self] in @@ -121,13 +121,13 @@ class ContactRequestsViewController: UIViewController, StoryboardBased, ViewMode self.viewModel .hasInvitations - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .bind(to: self.noInvitationsPlaceholder.rx.isHidden) .disposed(by: self.disposeBag) self.viewModel .hasInvitations - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: {[weak self] hasInvitation in if !hasInvitation { self?.view.isHidden = true diff --git a/Ring/Ring/Features/Conversations/Conversation/Cells/MessageCell.swift b/Ring/Ring/Features/Conversations/Conversation/Cells/MessageCell.swift index 36579cbc4e965f387755f2eec282e059aec2806a..74a9e7dc4a727efb424c1e8b3c84d932315a5ff7 100644 --- a/Ring/Ring/Features/Conversations/Conversation/Cells/MessageCell.swift +++ b/Ring/Ring/Features/Conversations/Conversation/Cells/MessageCell.swift @@ -527,12 +527,12 @@ class MessageCell: UITableViewCell, NibReusable, PlayerDelegate, PreviewViewCont } else { // sent message status item.status.asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .map { value in value == MessageStatus.sending ? true : false } .bind(to: self.sendingIndicator.rx.isAnimating) .disposed(by: self.disposeBag) item.status.asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .map { value in value == MessageStatus.failure ? false : true } .bind(to: self.failedStatusLabel.rx.isHidden) .disposed(by: self.disposeBag) @@ -638,7 +638,7 @@ class MessageCell: UITableViewCell, NibReusable, PlayerDelegate, PreviewViewCont Observable<(Data?, String)>.combineLatest(conversationViewModel.profileImageData.asObservable(), conversationViewModel.bestName.asObservable()) { ($0, $1) } .startWith((conversationViewModel.profileImageData.value, conversationViewModel.userName.value)) - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe({ [weak self] profileData in guard let data = profileData.element?.1 else { return } self?.avatarView.subviews.forEach({ $0.removeFromSuperview() }) @@ -655,7 +655,7 @@ class MessageCell: UITableViewCell, NibReusable, PlayerDelegate, PreviewViewCont Observable<(Data?, String, Bool)>.combineLatest(conversationViewModel.profileImageData.asObservable(), conversationViewModel.bestName.asObservable(), item.displayReadIndicator.asObservable()) { ($0, $1, $2) } - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .startWith((conversationViewModel.profileImageData.value, conversationViewModel.userName.value, item.displayReadIndicator.value)) .subscribe({ [weak self] profileData in guard let bestName = profileData.element?.1 else { return } @@ -704,13 +704,13 @@ class MessageCell: UITableViewCell, NibReusable, PlayerDelegate, PreviewViewCont func getMaxDimensionForTransfer() -> CGFloat { let screenWidth = UIScreen.main.bounds.width - //iPhone 5 width + // iPhone 5 width if screenWidth <= 320 { return 200 - //iPhone 6, iPhone 6 Plus and iPhone XR width + // iPhone 6, iPhone 6 Plus and iPhone XR width } else if screenWidth > 320 && screenWidth <= 414 { return 250 - //iPad width + // iPad width } else if screenWidth > 414 { return 300 } diff --git a/Ring/Ring/Features/Conversations/Conversation/Cells/MessageCellLocationSharing.swift b/Ring/Ring/Features/Conversations/Conversation/Cells/MessageCellLocationSharing.swift index 2ce58e4b35a627b37955d956222272459c0078dd..7ebd0b158c8c6fc255ee5564a5b7834e62708fd3 100644 --- a/Ring/Ring/Features/Conversations/Conversation/Cells/MessageCellLocationSharing.swift +++ b/Ring/Ring/Features/Conversations/Conversation/Cells/MessageCellLocationSharing.swift @@ -267,7 +267,7 @@ extension MessageCellLocationSharing { let shouldExpand = !self.locationTapped.value.1 self.updateHeight(shouldExpand) - //self.updateWidth(shouldExpand) now in controller, for animation + // self.updateWidth(shouldExpand) now in controller, for animation self.toggleMaplyGesture(shouldExpand) if shouldExpand { diff --git a/Ring/Ring/Features/Conversations/Conversation/Cells/MessageCellReceived.swift b/Ring/Ring/Features/Conversations/Conversation/Cells/MessageCellReceived.swift index 7f1b049db3d499180c779c2cff83eff0eaea95c5..d8bdfad9ec7483693aa9fe5c95a0c2a7ac9dde5d 100644 --- a/Ring/Ring/Features/Conversations/Conversation/Cells/MessageCellReceived.swift +++ b/Ring/Ring/Features/Conversations/Conversation/Cells/MessageCellReceived.swift @@ -23,7 +23,7 @@ import UIKit import Reusable class MessageCellReceived: MessageCell { - //Constraints + // Constraints @IBOutlet weak var messageLabelTrailingConstraint: NSLayoutConstraint! @IBOutlet weak var messageLabelLeadingConstraint: NSLayoutConstraint! diff --git a/Ring/Ring/Features/Conversations/Conversation/Cells/MessageCellSent.swift b/Ring/Ring/Features/Conversations/Conversation/Cells/MessageCellSent.swift index 97a06d1d0c34d8db21e920e8e2ba04c2cb782994..6f26cc443a9107c66b5e13137c245dd897ba239b 100644 --- a/Ring/Ring/Features/Conversations/Conversation/Cells/MessageCellSent.swift +++ b/Ring/Ring/Features/Conversations/Conversation/Cells/MessageCellSent.swift @@ -23,7 +23,7 @@ import UIKit import Reusable class MessageCellSent: MessageCell { - //Constraints + // Constraints @IBOutlet weak var messageLabelTrailingConstraint: NSLayoutConstraint! @IBOutlet weak var messageLabelLeadingConstraint: NSLayoutConstraint! diff --git a/Ring/Ring/Features/Conversations/Conversation/ConversationViewController.swift b/Ring/Ring/Features/Conversations/Conversation/ConversationViewController.swift index 98072ab55564f6aa3465371df9caf551d7023dc0..7fb638b42e0614ea759f7ef63cabfcc576a0008b 100644 --- a/Ring/Ring/Features/Conversations/Conversation/ConversationViewController.swift +++ b/Ring/Ring/Features/Conversations/Conversation/ConversationViewController.swift @@ -547,7 +547,7 @@ class ConversationViewController: UIViewController, self.viewModel.userName.asObservable()) { profileImage, displayName, username in return (profileImage, displayName, username) } - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe({ [weak self] profileData -> Void in self?.setupNavTitle(profileImageData: profileData.element?.0, displayName: profileData.element?.1, @@ -559,7 +559,7 @@ class ConversationViewController: UIViewController, self.tableView.contentInset.bottom = messageAccessoryView.frame.size.height self.tableView.scrollIndicatorInsets.bottom = messageAccessoryView.frame.size.height - //set navigation buttons - call and send contact request + // set navigation buttons - call and send contact request let inviteItem = UIBarButtonItem() inviteItem.image = UIImage(named: "add_person") inviteItem.rx.tap.throttle(Durations.halfSecond.toTimeInterval(), scheduler: MainScheduler.instance) @@ -605,14 +605,14 @@ class ConversationViewController: UIViewController, } return buttons }) - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] buttons in self?.navigationItem.rightBarButtonItems = buttons }) .disposed(by: self.disposeBag) } self.viewModel.showCallButton - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .startWith(self.viewModel.haveCurrentCall()) .subscribe(onNext: { [weak self] show in if show { @@ -639,7 +639,7 @@ class ConversationViewController: UIViewController, .disposed(by: self.disposeBag) viewModel.bestName .asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] name in guard !name.isEmpty else { return } let placeholder = L10n.Conversation.messagePlaceholder + name @@ -689,7 +689,7 @@ class ConversationViewController: UIViewController, self.tableView.rowHeight = UITableView.automaticDimension self.tableView.separatorStyle = .none - //Register cell + // Register cell self.tableView.register(cellType: MessageCellSent.self) self.tableView.register(cellType: MessageCellReceived.self) self.tableView.register(cellType: MessageCellDataTransferSent.self) @@ -698,9 +698,9 @@ class ConversationViewController: UIViewController, self.tableView.register(cellType: MessageCellLocationSharingSent.self) self.tableView.register(cellType: MessageCellLocationSharingReceived.self) - //Bind the TableView to the ViewModel + // Bind the TableView to the ViewModel self.viewModel.messages.asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] (messageViewModels) in self?.messageViewModels = messageViewModels self?.computeSequencing() @@ -708,7 +708,7 @@ class ConversationViewController: UIViewController, }) .disposed(by: self.disposeBag) - //Scroll to bottom when reloaded + // Scroll to bottom when reloaded self.tableView.rx.methodInvoked(#selector(UITableView.reloadData)) .subscribe(onNext: { [weak self] _ in self?.scrollToBottomIfNeed() @@ -1104,7 +1104,7 @@ extension ConversationViewController: UITableViewDataSource { private func deleteCellSetup(_ cell: MessageCell) { cell.deleteMessage - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self, weak cell] (shouldDelete) in guard shouldDelete, let self = self, let cell = cell, let messageId = cell.messageId else { return } @@ -1122,35 +1122,35 @@ extension ConversationViewController: UITableViewDataSource { private func messageCellActionsSetUp(_ cell: MessageCell, item: MessageViewModel) { cell.shareMessage - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self, weak item] (shouldShare) in guard shouldShare, let item = item else { return } self?.showShareMenu(messageModel: item) }) .disposed(by: cell.disposeBag) cell.forwardMessage - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self, weak item] (shouldForward) in guard shouldForward, let item = item else { return } self?.viewModel.slectContactsToShareMessage(message: item) }) .disposed(by: cell.disposeBag) cell.saveMessage - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self, weak cell] (shouldSave) in guard shouldSave, let cell = cell, let image = cell.transferedImage else { return } self?.saveImageToGalery(image: image) }) .disposed(by: cell.disposeBag) cell.resendMessage - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self, weak item] (shouldResend) in guard shouldResend, let item = item else { return } self?.viewModel.resendMessage(message: item) }) .disposed(by: cell.disposeBag) cell.previewMessage - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self, weak item, weak cell] (shouldPreview) in guard shouldPreview, let item = item, let cell = cell, let self = self, let initialFrame = cell.getInitialFrame() else { return } let player = item.getPlayer(conversationViewModel: self.viewModel) @@ -1167,7 +1167,7 @@ extension ConversationViewController: UITableViewDataSource { private func tapToShowTimeCellSetup(_ cell: MessageCell) { cell.tappedToShowTime - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self, weak cell] (tappedToShowTime) in guard tappedToShowTime, let self = self, let cell = cell else { return } @@ -1187,7 +1187,7 @@ extension ConversationViewController: UITableViewDataSource { guard item.isLocationSharingBubble, let cell = cell as? MessageCellLocationSharing else { return } cell.locationTapped - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self, weak cell] (locationTapped) in guard locationTapped.0, let self = self, let cell = cell else { return } @@ -1226,7 +1226,7 @@ extension ConversationViewController: UITableViewDataSource { item.lastTransferStatus = .unknown changeTransferStatus(cell, nil, item.message.transferStatus, item, viewModel) item.transferStatus.asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .filter { return $0 != DataTransferStatus.unknown && $0 != item.lastTransferStatus && $0 != item.initialTransferStatus } @@ -1277,7 +1277,7 @@ extension ConversationViewController: UITableViewDataSource { cell.playerHeight .asObservable() .share() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: {[weak tableView] height in if height > 0 { UIView.performWithoutAnimation { diff --git a/Ring/Ring/Features/Conversations/Conversation/ConversationViewModel.swift b/Ring/Ring/Features/Conversations/Conversation/ConversationViewModel.swift index ae8fd8f2fdd749fc50d225c93509227ba652c529..65e4bddd84c6770f46834cc04e580c7e596cd7bf 100644 --- a/Ring/Ring/Features/Conversations/Conversation/ConversationViewModel.swift +++ b/Ring/Ring/Features/Conversations/Conversation/ConversationViewModel.swift @@ -33,7 +33,7 @@ class ConversationViewModel: Stateable, ViewModel { /// Logger private let log = SwiftyBeaver.self - //Services + // Services private let conversationsService: ConversationsService private let accountService: AccountsService private let nameService: NameService @@ -193,14 +193,14 @@ class ConversationViewModel: Stateable, ViewModel { } } - //Displays the entire date ( for messages received before the current week ) + // Displays the entire date ( for messages received before the current week ) private lazy var dateFormatter: DateFormatter = { let formatter = DateFormatter() formatter.dateStyle = .medium return formatter }() - //Displays the hour of the message reception ( for messages received today ) + // Displays the hour of the message reception ( for messages received today ) private lazy var hourFormatter: DateFormatter = { let formatter = DateFormatter() formatter.dateFormat = "HH:mm" @@ -224,13 +224,13 @@ class ConversationViewModel: Stateable, ViewModel { let dateToday = Date() - //Get components from today date + // Get components from today date let todayWeekOfYear = Calendar.current.component(.weekOfYear, from: dateToday) let todayDay = Calendar.current.component(.day, from: dateToday) let todayMonth = Calendar.current.component(.month, from: dateToday) let todayYear = Calendar.current.component(.year, from: dateToday) - //Get components from last message date + // Get components from last message date let weekOfYear = Calendar.current.component(.weekOfYear, from: lastMessageDate) let day = Calendar.current.component(.day, from: lastMessageDate) let month = Calendar.current.component(.month, from: lastMessageDate) @@ -265,7 +265,7 @@ class ConversationViewModel: Stateable, ViewModel { receipientURI = contactURI } guard let account = self.accountService.currentAccount else { return } - //if in call send sip msg + // if in call send sip msg if let call = self.callService.call(participantHash: self.conversation.value.hash, accountID: self.conversation.value.accountId) { self.callService.sendTextMessage(callID: call.callId, message: content, accountId: account) return @@ -540,7 +540,7 @@ extension ConversationViewModel { return message! }) }) - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] messageViewModels in guard let self = self else { return } var msg = messageViewModels diff --git a/Ring/Ring/Features/Conversations/ConversationsCoordinator.swift b/Ring/Ring/Features/Conversations/ConversationsCoordinator.swift index 158c84cbd415142d99a176b00121e7f29c68968a..b25be1b17dade056a7701521196785b34e674e6a 100644 --- a/Ring/Ring/Features/Conversations/ConversationsCoordinator.swift +++ b/Ring/Ring/Features/Conversations/ConversationsCoordinator.swift @@ -55,7 +55,7 @@ class ConversationsCoordinator: Coordinator, StateableResponsive, ConversationNa self.addLockFlags() self.stateSubject - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] (state) in guard let self = self, let state = state as? ConversationState else { return } switch state { @@ -91,7 +91,7 @@ class ConversationsCoordinator: Coordinator, StateableResponsive, ConversationNa self.callService.newCall .asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { (call) in self.showIncomingCall(call: call) }) @@ -260,7 +260,7 @@ class ConversationsCoordinator: Coordinator, StateableResponsive, ConversationNa } let smartViewController = SmartlistViewController.instantiate(with: self.injectionBag) let contactRequestsViewController = ContactRequestsViewController.instantiate(with: self.injectionBag) - contactRequestsViewController.viewModel.state.takeUntil(contactRequestsViewController.rx.deallocated) + contactRequestsViewController.viewModel.state.take(until: contactRequestsViewController.rx.deallocated) .subscribe(onNext: { [weak self] (state) in self?.stateSubject.onNext(state) }) diff --git a/Ring/Ring/Features/Conversations/Preview/PreviewViewController.swift b/Ring/Ring/Features/Conversations/Preview/PreviewViewController.swift index a70802744239ef133f6df2c6a90cd945a7631155..589ab656a41776e6232b68dd07967113d39c13cb 100644 --- a/Ring/Ring/Features/Conversations/Preview/PreviewViewController.swift +++ b/Ring/Ring/Features/Conversations/Preview/PreviewViewController.swift @@ -27,7 +27,7 @@ enum PrevewType { case image } -protocol PreviewViewControllerDelegate: class { +protocol PreviewViewControllerDelegate: AnyObject { func deleteFile() func shareFile() func forwardFile() @@ -65,7 +65,7 @@ class PreviewViewController: UIViewController, StoryboardBased, ViewModelBased { self.gradientView.applyGradient(with: [UIColor(red: 0, green: 0, blue: 0, alpha: 1), UIColor(red: 0, green: 0, blue: 0, alpha: 0)], gradient: .vertical) NotificationCenter.default.rx .notification(UIDevice.orientationDidChangeNotification) - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] (_) in guard UIDevice.current.portraitOrLandscape else { return } self?.gradientView.layoutIfNeeded() diff --git a/Ring/Ring/Features/Conversations/SendFile/SendFileViewController.swift b/Ring/Ring/Features/Conversations/SendFile/SendFileViewController.swift index 464402b72a0daea1ed9584314f2659e83908a590..28d2877c9d258401e22ebc5e7853018674f3df6d 100644 --- a/Ring/Ring/Features/Conversations/SendFile/SendFileViewController.swift +++ b/Ring/Ring/Features/Conversations/SendFile/SendFileViewController.swift @@ -74,7 +74,7 @@ class SendFileViewController: UIViewController, StoryboardBased, ViewModelBased self.bindViewsToViewModel() NotificationCenter.default.rx .notification(UIDevice.orientationDidChangeNotification) - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] (_) in guard let self = self, UIDevice.current.portraitOrLandscape else { return } @@ -92,7 +92,7 @@ class SendFileViewController: UIViewController, StoryboardBased, ViewModelBased func bindViewsToViewModel() { self.viewModel.playBackFrame - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] frame in if let image = frame { DispatchQueue.main.async { @@ -122,11 +122,11 @@ class SendFileViewController: UIViewController, StoryboardBased, ViewModelBased }) .disposed(by: self.disposeBag) self.viewModel.hideVideoControls - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .bind(to: self.preview.rx.isHidden) .disposed(by: self.disposeBag) self.viewModel.hideVideoControls - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .bind(to: self.placeholderButton.rx.isHidden) .disposed(by: self.disposeBag) self.viewModel.readyToSend @@ -139,7 +139,7 @@ class SendFileViewController: UIViewController, StoryboardBased, ViewModelBased .disposed(by: self.disposeBag) self.viewModel.readyToSend .asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] ready in let audioOnly: Bool = self?.viewModel.audioOnly ?? false self?.switchButton.isHidden = ready || audioOnly @@ -152,7 +152,7 @@ class SendFileViewController: UIViewController, StoryboardBased, ViewModelBased .drive(self.timerLabel.rx.text) .disposed(by: self.disposeBag) self.viewModel.finished - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] finished in if finished { let animated: Bool = !(self?.viewModel.audioOnly ?? false) @@ -161,7 +161,7 @@ class SendFileViewController: UIViewController, StoryboardBased, ViewModelBased }) .disposed(by: self.disposeBag) self.viewModel.recording - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] recording in if recording { self?.animateRecordingButton() @@ -182,14 +182,14 @@ class SendFileViewController: UIViewController, StoryboardBased, ViewModelBased .bind(to: self.playerControls.rx.isHidden) .disposed(by: self.disposeBag) self.viewModel.playerPosition - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] position in self?.progressSlider.value = position }) .disposed(by: self.disposeBag) self.viewModel.playerDuration .asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] duration in let durationString = self?.durationString(microcec: duration) ?? "" self?.durationLabel.text = durationString @@ -197,7 +197,7 @@ class SendFileViewController: UIViewController, StoryboardBased, ViewModelBased .disposed(by: self.disposeBag) self.viewModel.pause .asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] pause in var image = UIImage(asset: Asset.pauseCall) if pause { @@ -208,7 +208,7 @@ class SendFileViewController: UIViewController, StoryboardBased, ViewModelBased .disposed(by: self.disposeBag) self.viewModel.audioMuted .asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] muted in var image = UIImage(asset: Asset.audioOn) if muted { diff --git a/Ring/Ring/Features/Conversations/SendFile/SendFileViewModel.swift b/Ring/Ring/Features/Conversations/SendFile/SendFileViewModel.swift index 3e6f972b29da1ed5733dc903f706c5fce7e600e9..de63940a67cd30f00b01e6bee551bd029a3b5e49 100644 --- a/Ring/Ring/Features/Conversations/SendFile/SendFileViewModel.swift +++ b/Ring/Ring/Features/Conversations/SendFile/SendFileViewModel.swift @@ -31,7 +31,7 @@ enum RecordingState { } class SendFileViewModel: Stateable, ViewModel { - //stateable + // stateable private let stateSubject = PublishSubject<State>() lazy var state: Observable<State> = { return self.stateSubject.asObservable() @@ -84,7 +84,7 @@ class SendFileViewModel: Stateable, ViewModel { let emptyString = Observable.just("") let durationTimer = Observable<Int> .interval(Durations.oneSecond.toTimeInterval(), scheduler: MainScheduler.instance) - .takeUntil(self.recordingState + .take(until: self.recordingState .asObservable() .filter { state in return state == .recorded @@ -183,7 +183,7 @@ class SendFileViewModel: Stateable, ViewModel { func stopRecording() { self.videoService.stopLocalRecorder(path: fileName) recordingState.accept(.recorded) - //create player after delay so recording could be finished + // create player after delay so recording could be finished DispatchQueue.main.asyncAfter(deadline: (.now() + 1)) { [weak self] in self?.createPlayer() } @@ -230,13 +230,13 @@ class SendFileViewModel: Stateable, ViewModel { self.videoService.switchCamera() } - //player + // player var player: PlayerViewModel? var playerDuration = BehaviorRelay<Float>(value: 0) var playerPosition = PublishSubject<Float>() - var seekTimeVariable = BehaviorRelay<Float>(value: 0) //player position set by user + var seekTimeVariable = BehaviorRelay<Float>(value: 0) // player position set by user let playBackFrame = PublishSubject<UIImage?>() var pause = BehaviorRelay<Bool>(value: true) diff --git a/Ring/Ring/Features/Conversations/SmartList/Cells/ConversationCell.swift b/Ring/Ring/Features/Conversations/SmartList/Cells/ConversationCell.swift index bea6b9c769c52b48b14576f71b84b818155783f6..6bcab0fc0b427f3747f9769811241fc2a0b5e6b6 100644 --- a/Ring/Ring/Features/Conversations/SmartList/Cells/ConversationCell.swift +++ b/Ring/Ring/Features/Conversations/SmartList/Cells/ConversationCell.swift @@ -67,7 +67,7 @@ class ConversationCell: UITableViewCell, NibReusable { Observable<(Data?, String)>.combineLatest(item.profileImageData.asObservable(), item.bestName.asObservable()) { ($0, $1) } .startWith((item.profileImageData.value, item.userName.value)) - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe({ [weak self] profileData in guard let data = profileData.element?.1 else { return } @@ -85,7 +85,7 @@ class ConversationCell: UITableViewCell, NibReusable { // presence if self.presenceIndicator != nil { item.contactPresence.asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .map { value in !value } .bind(to: self.presenceIndicator!.rx.isHidden) .disposed(by: self.disposeBag) @@ -93,7 +93,7 @@ class ConversationCell: UITableViewCell, NibReusable { // username item.bestName.asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .bind(to: self.nameLabel.rx.text) .disposed(by: self.disposeBag) self.nameLabel.lineBreakMode = .byTruncatingTail diff --git a/Ring/Ring/Features/Conversations/SmartList/IncognitoSmartListViewController.swift b/Ring/Ring/Features/Conversations/SmartList/IncognitoSmartListViewController.swift index f4781e8774e2fc73c66a105ef4759d17531afa2f..7f79a95102bc122979d697d15912dba29da2fecb 100644 --- a/Ring/Ring/Features/Conversations/SmartList/IncognitoSmartListViewController.swift +++ b/Ring/Ring/Features/Conversations/SmartList/IncognitoSmartListViewController.swift @@ -54,7 +54,7 @@ class IncognitoSmartListViewController: UIViewController, StoryboardBased, ViewM self.tabBarController?.tabBar.layer.zPosition = -1 NotificationCenter.default.rx .notification(UIDevice.orientationDidChangeNotification) - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: {[weak self](_) in guard UIDevice.current.portraitOrLandscape else { return } self?.placeVideoCall.updateGradientFrame() diff --git a/Ring/Ring/Features/Conversations/SmartList/IncognitoSmartListViewModel.swift b/Ring/Ring/Features/Conversations/SmartList/IncognitoSmartListViewModel.swift index 6f0b295a2ff451e765c08207b855b7d20c9c3281..4cf1ce80e9d717534c8691d5f738d4ad279a120e 100644 --- a/Ring/Ring/Features/Conversations/SmartList/IncognitoSmartListViewModel.swift +++ b/Ring/Ring/Features/Conversations/SmartList/IncognitoSmartListViewModel.swift @@ -31,7 +31,7 @@ class IncognitoSmartListViewModel: Stateable, ViewModel, FilterConversationDataS private let disposeBag = DisposeBag() - //Services + // Services private let accountService: AccountsService private let networkService: NetworkService private let contactService: ContactsService diff --git a/Ring/Ring/Features/Conversations/SmartList/SmartlistViewController.swift b/Ring/Ring/Features/Conversations/SmartList/SmartlistViewController.swift index 2f96e5c88b712af8b65722e7a6fbcdf7c86ed89a..8c06c2a1d65d0a34a8bede47b39abe7a03696254 100644 --- a/Ring/Ring/Features/Conversations/SmartList/SmartlistViewController.swift +++ b/Ring/Ring/Features/Conversations/SmartList/SmartlistViewController.swift @@ -29,7 +29,7 @@ import SwiftyBeaver import ContactsUI import QuartzCore -//Constants +// Constants struct SmartlistConstants { static let smartlistRowHeight: CGFloat = 70.0 static let tableHeaderViewHeight: CGFloat = 30.0 @@ -161,11 +161,11 @@ class SmartlistViewController: UIViewController, StoryboardBased, ViewModelBased guard let controller = contactRequestVC else { return } addChild(controller) - //make sure that the child view controller's view is the right size + // make sure that the child view controller's view is the right size controller.view.frame = containerView.bounds containerView.addSubview(controller.view) - //you must call this at the end per Apple's documentation + // you must call this at the end per Apple's documentation controller.didMove(toParent: self) controller.view.isHidden = true self.searchView.searchBar.rx.text.orEmpty @@ -349,7 +349,7 @@ class SmartlistViewController: UIViewController, StoryboardBased, ViewModelBased }) .disposed(by: self.disposeBag) self.viewModel.currentAccountChanged - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] currentAccount in if let account = currentAccount { let accountSip = account.type == AccountType.sip @@ -360,7 +360,7 @@ class SmartlistViewController: UIViewController, StoryboardBased, ViewModelBased .disposed(by: disposeBag) self.navigationItem.rightBarButtonItem = settingsButtonItem - //create accounts button + // create accounts button let accountButton = UIButton(type: .custom) self.viewModel.profileImage.bind(to: accountButton.rx.image(for: .normal)) .disposed(by: disposeBag) @@ -634,7 +634,7 @@ class SmartlistViewController: UIViewController, StoryboardBased, ViewModelBased accountPickerTextView.inputView = accounPicker accounPicker.backgroundColor = .jamiBackgroundSecondaryColor self.viewModel.accounts - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .bind(to: accounPicker.rx.items(adapter: accountsAdapter)) .disposed(by: disposeBag) if let account = self.viewModel.currentAccount, @@ -643,7 +643,7 @@ class SmartlistViewController: UIViewController, StoryboardBased, ViewModelBased dialpadButtonShadow.isHidden = account.type == AccountType.ring } self.viewModel.currentAccountChanged - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] currentAccount in guard let self = self else { return } if let account = currentAccount, @@ -708,7 +708,7 @@ class SmartlistViewController: UIViewController, StoryboardBased, ViewModelBased } func setupDataSources() { - //Configure cells closure for the datasources + // Configure cells closure for the datasources let configureCell: (TableViewSectionedDataSource, UITableView, IndexPath, ConversationSection.Item) -> UITableViewCell = { ( _: TableViewSectionedDataSource<ConversationSection>, @@ -721,26 +721,26 @@ class SmartlistViewController: UIViewController, StoryboardBased, ViewModelBased return cell } - //Create DataSources for conversations and filtered conversations + // Create DataSources for conversations and filtered conversations let conversationsDataSource = RxTableViewSectionedReloadDataSource<ConversationSection>(configureCell: configureCell) - //Allows to delete + // Allows to delete conversationsDataSource.canEditRowAtIndexPath = { _, _ in return true } - //Bind TableViews to DataSources + // Bind TableViews to DataSources self.viewModel.conversations .bind(to: self.conversationsTableView.rx.items(dataSource: conversationsDataSource)) .disposed(by: disposeBag) } func setupTableView() { - //Set row height + // Set row height self.conversationsTableView.rowHeight = SmartlistConstants.smartlistRowHeight - //Register Cell + // Register Cell self.conversationsTableView.register(cellType: SmartListCell.self) - //Deselect the rows + // Deselect the rows self.conversationsTableView.rx.itemSelected .subscribe(onNext: { [weak self] indexPath in self?.conversationsTableView.deselectRow(at: indexPath, animated: true) diff --git a/Ring/Ring/Features/Conversations/SmartList/SmartlistViewModel.swift b/Ring/Ring/Features/Conversations/SmartList/SmartlistViewModel.swift index 8e0bbeeba01aeb9622d8888056b05b766866706f..c075f83547ab275b3af9cf190879bbb18ac215f3 100644 --- a/Ring/Ring/Features/Conversations/SmartList/SmartlistViewModel.swift +++ b/Ring/Ring/Features/Conversations/SmartList/SmartlistViewModel.swift @@ -38,7 +38,7 @@ class SmartlistViewModel: Stateable, ViewModel, FilterConversationDataSource { private let disposeBag = DisposeBag() private var tempBag = DisposeBag() - //Services + // Services private let conversationsService: ConversationsService private let nameService: NameService private let accountsService: AccountsService @@ -64,7 +64,7 @@ class SmartlistViewModel: Stateable, ViewModel, FilterConversationDataSource { } return false }) - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) }() var connectionState = PublishSubject<ConnectionType>() @@ -90,7 +90,7 @@ class SmartlistViewModel: Stateable, ViewModel, FilterConversationDataSource { } let injectionBag: InjectionBag - //Values need to be updated when selected account changed + // Values need to be updated when selected account changed var profileImageForCurrentAccount = PublishSubject<Profile>() lazy var profileImage: Observable<UIImage> = { [weak self] in @@ -138,11 +138,11 @@ class SmartlistViewModel: Stateable, ViewModel, FilterConversationDataSource { lazy var conversations: Observable<[ConversationSection]> = { [weak self] in guard let self = self else { return Observable.empty() } - //get initial value + // get initial value DispatchQueue.main.asyncAfter(deadline: .now() + 0.01, execute: { self.conversationsService .conversationsForCurrentAccount - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { (conversations) in self.conversationsForCurrentAccount.onNext(conversations) }) @@ -229,7 +229,7 @@ class SmartlistViewModel: Stateable, ViewModel, FilterConversationDataSource { resultSelector: {(messages, requests) -> BageValues in return (messages, requests) }) - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) }() var conversationsForCurrentAccount = PublishSubject<[ConversationModel]>() @@ -242,7 +242,7 @@ class SmartlistViewModel: Stateable, ViewModel, FilterConversationDataSource { }) .disposed(by: self.tempBag) self.conversationsService.conversationsForCurrentAccount - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] conversations in self?.conversationsForCurrentAccount.onNext(conversations) }) @@ -265,7 +265,7 @@ class SmartlistViewModel: Stateable, ViewModel, FilterConversationDataSource { self.callService.newCall .asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] _ in self?.closeAllPlayers() }) diff --git a/Ring/Ring/Features/Conversations/views/JamiSearchView/JamiSearchView.swift b/Ring/Ring/Features/Conversations/views/JamiSearchView/JamiSearchView.swift index 6bcf3fe841ba37af89d7b03b3a7332ef47e24e8f..049001887c50f2fdf2367f8c5b26e3ab6a5aa65c 100644 --- a/Ring/Ring/Features/Conversations/views/JamiSearchView/JamiSearchView.swift +++ b/Ring/Ring/Features/Conversations/views/JamiSearchView/JamiSearchView.swift @@ -101,9 +101,9 @@ class JamiSearchView: NSObject { searchResultsDatasource.titleForHeaderInSection = { dataSource, index in return dataSource.sectionModels[index].header } - //search status label + // search status label self.viewModel.searchStatus - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .bind(to: self.searchingLabel.rx.text) .disposed(by: disposeBag) searchingLabel.textColor = UIColor.jamiLabelColor @@ -124,7 +124,7 @@ class JamiSearchView: NSObject { .bind(to: self.viewModel.searchBarText) .disposed(by: disposeBag) - //Show Cancel button + // Show Cancel button self.searchBar.rx.textDidBeginEditing .subscribe(onNext: { [weak self] in self?.editSearch.onNext(true) @@ -132,7 +132,7 @@ class JamiSearchView: NSObject { }) .disposed(by: disposeBag) - //Hide Cancel button + // Hide Cancel button self.searchBar.rx.textDidEndEditing .subscribe(onNext: { [weak self] in guard let self = self else { return } @@ -144,14 +144,14 @@ class JamiSearchView: NSObject { }) .disposed(by: disposeBag) - //Cancel button event + // Cancel button event self.searchBar.rx.cancelButtonClicked .subscribe(onNext: { [weak self] in self?.cancelSearch() }) .disposed(by: disposeBag) - //Search button event + // Search button event self.searchBar.rx.searchButtonClicked .subscribe(onNext: { [weak self] in self?.searchBar.resignFirstResponder() diff --git a/Ring/Ring/Features/Conversations/views/JamiSearchView/JamiSearchViewModel.swift b/Ring/Ring/Features/Conversations/views/JamiSearchView/JamiSearchViewModel.swift index 803344cd42d61fb148649421ac3120da1a8f9028..8612774dac58178c4cf6528a7ec791314eaf5905 100644 --- a/Ring/Ring/Features/Conversations/views/JamiSearchView/JamiSearchViewModel.swift +++ b/Ring/Ring/Features/Conversations/views/JamiSearchView/JamiSearchViewModel.swift @@ -37,7 +37,7 @@ class JamiSearchViewModel { let log = SwiftyBeaver.self - //Services + // Services private let nameService: NameService private let accountsService: AccountsService private let injectionBag: InjectionBag @@ -67,7 +67,7 @@ class JamiSearchViewModel { } return sections }) - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) }() private var contactFoundConversation = BehaviorRelay<ConversationViewModel?>(value: nil) @@ -85,25 +85,25 @@ class JamiSearchViewModel { self.injectionBag = injectionBag self.dataSource = source - //Observes if the user is searching + // Observes if the user is searching self.isSearching = searchBarText.asObservable() .map({ text in return !text.isEmpty }) - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) - //Observes search bar text + // Observes search bar text searchBarText.asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .distinctUntilChanged() .subscribe(onNext: { [weak self] text in self?.search(withText: text) }) .disposed(by: disposeBag) - //Observe username lookup + // Observe username lookup self.nameService.usernameLookupStatus - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self, weak injectionBag] lookupResponse in guard let self = self else { return } if lookupResponse.state == .found && (lookupResponse.name == self.searchBarText.value || lookupResponse.address == self.searchBarText.value) { @@ -120,7 +120,7 @@ class JamiSearchViewModel { let injectionBag = injectionBag { let uri = JamiURI.init(schema: URIType.ring, infoHach: lookupResponse.address) - //Create new converation + // Create new converation let conversation = ConversationModel(withParticipantUri: uri, accountId: account.id) let newConversation = ConversationViewModel(with: injectionBag) if lookupResponse.name == self.searchBarText.value { @@ -143,7 +143,7 @@ class JamiSearchViewModel { self.nameService .userSearchResponseShared - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] nameSearchResponse in guard let self = self, let results = nameSearchResponse.results as? [[String: String]], @@ -205,7 +205,7 @@ class JamiSearchViewModel { if text.isEmpty { return } - //Filter conversations + // Filter conversations let filteredConversations = self.dataSource.conversationViewModels .filter({conversationViewModel in diff --git a/Ring/Ring/Features/Conversations/views/PlayerView.swift b/Ring/Ring/Features/Conversations/views/PlayerView.swift index 5f4af02e426f1cd422108b00792b52de407cfec3..328055104613ac3588a1c9ba574655f18212d43c 100644 --- a/Ring/Ring/Features/Conversations/views/PlayerView.swift +++ b/Ring/Ring/Features/Conversations/views/PlayerView.swift @@ -141,7 +141,7 @@ class PlayerView: UIView { func bindViews() { self.viewModel.playBackFrame - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] frame in if let image = frame { DispatchQueue.main.async { @@ -151,14 +151,14 @@ class PlayerView: UIView { }) .disposed(by: self.disposeBag) self.viewModel.playerPosition - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] position in self?.progressSlider.value = position }) .disposed(by: self.disposeBag) self.viewModel.playerDuration .asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] duration in let durationString = self?.durationString(microcec: duration) ?? "" self?.durationLabel.text = durationString @@ -166,7 +166,7 @@ class PlayerView: UIView { .disposed(by: self.disposeBag) self.viewModel.pause .asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] pause in if #available(iOS 13.0, *) { var image = UIImage(systemName: "pause.fill") @@ -186,7 +186,7 @@ class PlayerView: UIView { self.viewModel.audioMuted .asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] muted in var image = UIImage(asset: Asset.audioOn) if muted { @@ -198,7 +198,7 @@ class PlayerView: UIView { self.viewModel.hasVideo .asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] hasVideo in self?.muteAudio.isHidden = !hasVideo }) diff --git a/Ring/Ring/Features/Conversations/views/PlayerViewModel.swift b/Ring/Ring/Features/Conversations/views/PlayerViewModel.swift index 02382ec73a0279960c00db227f786c9ca0a9bc1f..477ff422de6a8714a577e4b465c4f6ae3b6e6dec 100644 --- a/Ring/Ring/Features/Conversations/views/PlayerViewModel.swift +++ b/Ring/Ring/Features/Conversations/views/PlayerViewModel.swift @@ -21,7 +21,7 @@ import RxSwift import RxCocoa -protocol PlayerDelegate: class { +protocol PlayerDelegate: AnyObject { func extractedVideoFrame(with height: CGFloat) } @@ -67,7 +67,7 @@ class PlayerViewModel { self.pause.accept(true) self.playerPosition.onNext(0) // subscribe for frame playback - //get first frame, pause player and seek back to first frame + // get first frame, pause player and seek back to first frame self.playBackDisposeBag = DisposeBag() self.incomingFrame.filter { [weak self] (render) -> Bool in render?.rendererId == self?.playerId @@ -123,7 +123,7 @@ class PlayerViewModel { self?.audioMuted.accept(true) self?.videoService.mutePlayerAudio(playerId: player.playerId, mute: self?.audioMuted.value ?? true) - //unpause player to get first video frame + // unpause player to get first video frame self?.toglePause() }) .disposed(by: self.playBackDisposeBag) diff --git a/Ring/Ring/Features/Me/LinkNewDeviceViewController.swift b/Ring/Ring/Features/Me/LinkNewDeviceViewController.swift index a93f45de3e55a7a13f672e76170128b2227206b2..540343a1cc0d87d6ed080d6817bb1eef81d012a4 100644 --- a/Ring/Ring/Features/Me/LinkNewDeviceViewController.swift +++ b/Ring/Ring/Features/Me/LinkNewDeviceViewController.swift @@ -34,7 +34,7 @@ class LinkNewDeviceViewController: UIViewController, StoryboardBased, ViewModelB super.viewDidLoad() self.viewModel.observableState - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] (state) in switch state { case .generatingPin: diff --git a/Ring/Ring/Features/Me/Me/BlockListViewController.swift b/Ring/Ring/Features/Me/Me/BlockListViewController.swift index d59c610d8488dc28472cfb976c2e9ab90faf63a4..6f9eab22e092c1b0107f12792298169e80a7ab30 100644 --- a/Ring/Ring/Features/Me/Me/BlockListViewController.swift +++ b/Ring/Ring/Features/Me/Me/BlockListViewController.swift @@ -48,7 +48,7 @@ class BlockListViewController: UIViewController, StoryboardBased, ViewModelBased noBlockedContactLabel.text = L10n.BlockListPage.noBlockedContacts self.viewModel.contactListNotEmpty - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .bind(to: self.noBlockedContactLabel.rx.isHidden) .disposed(by: self.disposeBag) self.navigationController?.navigationBar @@ -60,11 +60,11 @@ class BlockListViewController: UIViewController, StoryboardBased, ViewModelBased self.tableView.rowHeight = 64.0 self.tableView.allowsSelection = false - //Register cell + // Register cell self.tableView.register(cellType: BannedContactCell.self) self.viewModel .blockedContactsItems - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .bind(to: tableView.rx.items(cellIdentifier: cellIdentifier, cellType: BannedContactCell.self)) { [weak self] _, item, cell in cell.configureFromItem(item) cell.unblockButton.rx.tap diff --git a/Ring/Ring/Features/Me/Me/MeViewController.swift b/Ring/Ring/Features/Me/Me/MeViewController.swift index 65c0e19c28bc3d9a600c5b03e89ce8e0d245db70..966d6a4c5febd20ef2485324efacc9209a772d3a 100644 --- a/Ring/Ring/Features/Me/Me/MeViewController.swift +++ b/Ring/Ring/Features/Me/Me/MeViewController.swift @@ -121,7 +121,7 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas qrCodeButton.setImage(imageQrCode, for: .normal) self.viewModel.isAccountSip .asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak qrCodeButton](isSip) in qrCodeButton?.isHidden = isSip qrCodeButton?.isEnabled = !isSip @@ -134,7 +134,7 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas }) .disposed(by: self.disposeBag) self.viewModel.showActionState.asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self](action) in switch action { case .noAction: @@ -156,12 +156,12 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas .disposed(by: self.disposeBag) self.navigationItem.rightBarButtonItem = qrCodeButtonItem - //setup Table + // setup Table self.settingsTable.estimatedRowHeight = 35 self.settingsTable.rowHeight = UITableView.automaticDimension self.settingsTable.tableFooterView = UIView() - //Register cell + // Register cell self.setUpDataSource() self.settingsTable.register(cellType: DeviceCell.self) } @@ -278,7 +278,7 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas self.viewModel.keepAliveEnabled .asObservable() .startWith(self.viewModel.keepAliveEnabled.value) - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .bind(to: switchView.rx.value) .disposed(by: cell.disposeBag) switchView.rx @@ -455,7 +455,7 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas cell.accessoryType = UITableViewCell.AccessoryType.disclosureIndicator cell.accessoryView = switchView self.viewModel.notificationsEnabledObservable - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .bind(to: switchView.rx.value) .disposed(by: cell.disposeBag) switchView.setOn(self.viewModel.notificationsEnabled, animated: false) @@ -480,7 +480,7 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas self.viewModel.peerDiscoveryEnabled .asObservable() .startWith(self.viewModel.peerDiscoveryEnabled.value) - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .bind(to: switchView.rx.value) .disposed(by: cell.disposeBag) switchView.rx @@ -528,7 +528,7 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas cell.detailTextLabel?.font = UIFont.preferredFont(forTextStyle: .callout) cell.detailTextLabel?.text = state.value state.asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { (status) in cell.detailTextLabel?.text = status }) @@ -551,7 +551,7 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas cell.sizeToFit() cell.layoutIfNeeded() self.viewModel.switchBoothModeState - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .bind(to: switchView.rx.value) .disposed(by: self.disposeBag) switchView.rx @@ -581,7 +581,7 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas animated: false) self.viewModel.accountEnabled .asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .bind(to: switchView.rx.value) .disposed(by: cell.disposeBag) switchView.rx @@ -657,7 +657,7 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas text.text = value text.sizeToFit() text.rx.controlEvent(.editingDidEndOnExit) - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] _ in self?.viewModel.updateSipSettings() }) @@ -680,14 +680,14 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas cell.textLabel?.text = L10n.Account.sipServer case .sipPassword: cell.textLabel?.text = L10n.Account.sipPassword - //show password button + // show password button let rightButton = UIButton(type: .custom) var insets = rightButton.contentEdgeInsets insets.right = 20.0 rightButton.contentEdgeInsets = insets self.viewModel.secureTextEntry .asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { (secure) in text.isSecureTextEntry = secure if secure { @@ -879,7 +879,7 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas } self.present(controller, animated: true, completion: nil) if self.viewModel.hasPassword() { - //remove border around text view + // remove border around text view controller.textFields?[1].superview?.backgroundColor = .clear controller.textFields?[1].superview?.superview?.subviews[0].removeFromSuperview() } @@ -915,11 +915,11 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas } controller.addAction(actionCancel) controller.addAction(actionRegister) - //username textfield + // username textfield controller.addTextField {(textField) in textField.placeholder = L10n.AccountPage.usernamePlaceholder } - //error rext field + // error rext field controller.addTextField {(textField) in textField.text = "" textField.isUserInteractionEnabled = false @@ -929,7 +929,7 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas textField.backgroundColor = UIColor.clear textField.font = UIFont.systemFont(ofSize: 11, weight: .thin) } - //password text field + // password text field if self.viewModel.hasPassword() { controller.addTextField {(textField) in textField.placeholder = L10n.AccountPage.passwordPlaceholder @@ -939,9 +939,9 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas self.present(controller, animated: true, completion: nil) self.viewModel.subscribeForNameLokup(disposeBug: nameRegistrationBag) self.viewModel.usernameValidationState.asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak controller] (state) in - //update name lookup message + // update name lookup message guard let textFields = controller?.textFields, textFields.count >= 2 else { return } textFields[1].text = state.message @@ -998,7 +998,7 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas .bind(to: actionRegister.rx.isEnabled) .disposed(by: nameRegistrationBag) } - //remove border around text view + // remove border around text view controller.textFields?[1].superview?.backgroundColor = .clear controller.textFields?[1].superview?.superview?.subviews[0].removeFromSuperview() } @@ -1069,7 +1069,7 @@ extension MeViewController: UITableViewDelegate { var size = self.view.bounds.size let screenSize = UIScreen.main.bounds.size if let height = navigationHeight { - //height for ihoneX + // height for ihoneX if UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.phone, screenSize.height == 812.0 { size.height -= (height - 10) diff --git a/Ring/Ring/Features/Me/Me/MeViewModel.swift b/Ring/Ring/Features/Me/Me/MeViewModel.swift index 7b7e19b56b8a939c9536c16b29e7786b045f5aaf..fbf5ab1e8e81365d7090b512a95e2545f0218f6c 100644 --- a/Ring/Ring/Features/Me/Me/MeViewModel.swift +++ b/Ring/Ring/Features/Me/Me/MeViewModel.swift @@ -229,8 +229,8 @@ class MeViewModel: ViewModel, Stateable { var items = items if let currentAccount = self.accountService.currentAccount, self.accountService.isJams(for: currentAccount.id) { - items.remove(at: items.count - 2) //remove .boothMode - items.remove(at: items.count - 2) //remove .changePassword + items.remove(at: items.count - 2) // remove .boothMode + items.remove(at: items.count - 2) // remove .changePassword } return SettingsSection.accountSettings(items: items) }) @@ -284,7 +284,7 @@ class MeViewModel: ViewModel, Stateable { self.port.accept(port) self.proxyServer.accept(proxyServer) } - //isIP2IP + // isIP2IP if server.isEmpty { return .accountSettings( items: [.sectionHeader(title: ""), .sipUserName(value: username), @@ -420,7 +420,7 @@ class MeViewModel: ViewModel, Stateable { func showBlockedContacts() { self.stateSubject.onNext(MeState.blockedContacts) } - //rigistering username + // rigistering username let newUsername = BehaviorRelay<String>(value: "") let usernameValidationState = BehaviorRelay<UsernameValidationState>(value: .unknown) @@ -516,11 +516,11 @@ class MeViewModel: ViewModel, Stateable { case DeviceRevocationState.success.rawValue: self.showActionState.accept(.deviceRevokedWithSuccess(deviceId: deviceID)) case DeviceRevocationState.wrongPassword.rawValue: - self.showActionState.accept(.deviceRevokationError(deviceId:deviceID, errorMessage: L10n.AccountPage.deviceRevocationWrongPassword)) + self.showActionState.accept(.deviceRevokationError(deviceId: deviceID, errorMessage: L10n.AccountPage.deviceRevocationWrongPassword)) case DeviceRevocationState.unknownDevice.rawValue: - self.showActionState.accept(.deviceRevokationError(deviceId:deviceID, errorMessage: L10n.AccountPage.deviceRevocationUnknownDevice)) + self.showActionState.accept(.deviceRevokationError(deviceId: deviceID, errorMessage: L10n.AccountPage.deviceRevocationUnknownDevice)) default: - self.showActionState.accept(.deviceRevokationError(deviceId:deviceID, errorMessage: L10n.AccountPage.deviceRevocationError)) + self.showActionState.accept(.deviceRevokationError(deviceId: deviceID, errorMessage: L10n.AccountPage.deviceRevocationError)) } } }) diff --git a/Ring/Ring/Features/Me/MeCoordinator.swift b/Ring/Ring/Features/Me/MeCoordinator.swift index 3a3f561ae5eb6f68d429dcfa835485a08e57f380..ea69af3c54cfc388503d52586ffb0f1a18c7706d 100644 --- a/Ring/Ring/Features/Me/MeCoordinator.swift +++ b/Ring/Ring/Features/Me/MeCoordinator.swift @@ -55,7 +55,7 @@ class MeCoordinator: Coordinator, StateableResponsive { self.presentingVC[VCType.blockList.rawValue] = false self.stateSubject - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] (state) in guard let self = self, let state = state as? MeState else { return } switch state { diff --git a/Ring/Ring/Features/Walkthrough/CreateAccount/CreateAccountViewController.swift b/Ring/Ring/Features/Walkthrough/CreateAccount/CreateAccountViewController.swift index bb8b01a5a6662bafff1b74f80e149f9ecfc6aa34..25eb329eeed0545bd5e0034c65d4963dd5c2a5f8 100644 --- a/Ring/Ring/Features/Walkthrough/CreateAccount/CreateAccountViewController.swift +++ b/Ring/Ring/Features/Walkthrough/CreateAccount/CreateAccountViewController.swift @@ -88,7 +88,7 @@ class CreateAccountViewController: UIViewController, StoryboardBased, ViewModelB keyboardDismissTapRecognizer = UITapGestureRecognizer(target: self, action: #selector(dismissKeyboard)) NotificationCenter.default.rx .notification(UIDevice.orientationDidChangeNotification) - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] (_) in guard UIDevice.current.portraitOrLandscape else { return } self?.createAccountButton.updateGradientFrame() @@ -191,7 +191,7 @@ class CreateAccountViewController: UIViewController, StoryboardBased, ViewModelB private func bindViewModelToView() { // handle username registration visibility self.viewModel.registerUsername.asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] (isOn) in guard let self = self else { return } UIView.animate(withDuration: 0.3, animations: { @@ -220,29 +220,29 @@ class CreateAccountViewController: UIViewController, StoryboardBased, ViewModelB // handle password error self.viewModel.passwordValidationState.map { $0.isValidated } - .skipUntil(self.passwordTextField.rx.controlEvent(UIControl.Event.editingDidEnd)) + .skip(until: self.passwordTextField.rx.controlEvent(UIControl.Event.editingDidEnd)) .bind(to: self.passwordErrorLabel.rx.isHidden) .disposed(by: self.disposeBag) self.viewModel.passwordValidationState.map { $0.message } - .skipUntil(self.passwordTextField.rx.controlEvent(UIControl.Event.editingDidEnd)) + .skip(until: self.passwordTextField.rx.controlEvent(UIControl.Event.editingDidEnd)) .bind(to: self.passwordErrorLabel.rx.text) .disposed(by: self.disposeBag) // handle registration error self.viewModel.usernameValidationState.asObservable() .map { $0.isDefault } - .skipUntil(self.usernameTextField.rx.controlEvent(UIControl.Event.editingDidBegin)) + .skip(until: self.usernameTextField.rx.controlEvent(UIControl.Event.editingDidBegin)) .bind(to: self.registerUsernameErrorLabel.rx.isHidden) .disposed(by: self.disposeBag) self.viewModel.usernameValidationState.asObservable() .map { $0.message } - .skipUntil(self.usernameTextField.rx.controlEvent(UIControl.Event.editingDidBegin)) + .skip(until: self.usernameTextField.rx.controlEvent(UIControl.Event.editingDidBegin)) .bind(to: self.registerUsernameErrorLabel.rx.text) .disposed(by: self.disposeBag) self.viewModel.usernameValidationState.asObservable() .map { $0.isAvailable } - .skipUntil(self.usernameTextField.rx.controlEvent(UIControl.Event.editingDidBegin)) - .observeOn(MainScheduler.instance) + .skip(until: self.usernameTextField.rx.controlEvent(UIControl.Event.editingDidBegin)) + .observe(on: MainScheduler.instance) .subscribe { [weak self] available in self?.registerUsernameErrorLabel.textColor = available ? UIColor.jamiSuccess : UIColor.jamiFailure } @@ -250,7 +250,7 @@ class CreateAccountViewController: UIViewController, StoryboardBased, ViewModelB // handle creation state self.viewModel.createState - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] (state) in switch state { case .started: diff --git a/Ring/Ring/Features/Walkthrough/CreateAccount/CreateAccountViewModel.swift b/Ring/Ring/Features/Walkthrough/CreateAccount/CreateAccountViewModel.swift index 301586fe4cc56f20467bd0a3f3adc026c575eabb..ffa4464e2c31f17714ca4aca1f70f06caf5fcda8 100644 --- a/Ring/Ring/Features/Walkthrough/CreateAccount/CreateAccountViewModel.swift +++ b/Ring/Ring/Features/Walkthrough/CreateAccount/CreateAccountViewModel.swift @@ -269,7 +269,7 @@ class CreateAccountViewModel: Stateable, ViewModel { self.accountService = injectionBag.accountService self.nameService = injectionBag.nameService - //Loookup name request observer + // Loookup name request observer self.username.asObservable() .subscribe(onNext: { [weak self] username in self?.nameService.lookupName(withAccount: "", nameserver: "", name: username) diff --git a/Ring/Ring/Features/Walkthrough/CreateProfile/CreateProfileViewController.swift b/Ring/Ring/Features/Walkthrough/CreateProfile/CreateProfileViewController.swift index b7aa0adf1b8d6fddb04f25a7230c875dd5b154d9..e57b6fcacafb88d3e7b47674eaf8e3e91c940032 100644 --- a/Ring/Ring/Features/Walkthrough/CreateProfile/CreateProfileViewController.swift +++ b/Ring/Ring/Features/Walkthrough/CreateProfile/CreateProfileViewController.swift @@ -91,7 +91,7 @@ class CreateProfileViewController: EditProfileViewController, StoryboardBased, V self.applyL10n() - //bind view model to view + // bind view model to view tapGesture.rx.event .bind(onNext: { [weak self] _ in self?.dismissInfoView() @@ -129,7 +129,7 @@ class CreateProfileViewController: EditProfileViewController, StoryboardBased, V self.adaptToKeyboardState(for: self.scrollView, with: self.disposeBag) keyboardDismissTapRecognizer = UITapGestureRecognizer(target: self, action: #selector(dismissKeyboard)) NotificationCenter.default.rx.notification(UIDevice.orientationDidChangeNotification) - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] (_) in guard UIDevice.current.portraitOrLandscape else { return } self?.skipButton.updateGradientFrame() diff --git a/Ring/Ring/Features/Walkthrough/CreateSipAccount/CreateSipAccountViewController.swift b/Ring/Ring/Features/Walkthrough/CreateSipAccount/CreateSipAccountViewController.swift index a0ca91bd4128fec4e622e7509b462fdfaf58c0f6..03e59a28ce1134ebcdefcbd5cecdb25603f9efed 100644 --- a/Ring/Ring/Features/Walkthrough/CreateSipAccount/CreateSipAccountViewController.swift +++ b/Ring/Ring/Features/Walkthrough/CreateSipAccount/CreateSipAccountViewController.swift @@ -56,7 +56,7 @@ class CreateSipAccountViewController: UIViewController, StoryboardBased, ViewMod keyboardDismissTapRecognizer = UITapGestureRecognizer(target: self, action: #selector(dismissKeyboard)) NotificationCenter.default.rx .notification(UIDevice.orientationDidChangeNotification) - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] (_) in guard UIDevice.current.portraitOrLandscape else { return } self?.createAccountButton.updateGradientFrame() diff --git a/Ring/Ring/Features/Walkthrough/LinkDevice/LinkDeviceViewController.swift b/Ring/Ring/Features/Walkthrough/LinkDevice/LinkDeviceViewController.swift index 1f84c6e239fb063bdb182daf03de88a4d22b04f1..ff3b9268bfaf931a0b06db0236f523d9736dff00 100644 --- a/Ring/Ring/Features/Walkthrough/LinkDevice/LinkDeviceViewController.swift +++ b/Ring/Ring/Features/Walkthrough/LinkDevice/LinkDeviceViewController.swift @@ -65,7 +65,7 @@ class LinkDeviceViewController: UIViewController, StoryboardBased, ViewModelBase self.applyL10n() - //bind view model to view + // bind view model to view self.pinInfoButton.rx.tap .subscribe(onNext: { [weak self] (_) in self?.showPinInfo() @@ -80,7 +80,7 @@ class LinkDeviceViewController: UIViewController, StoryboardBased, ViewModelBase // handle linking state self.viewModel.createState - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] (state) in switch state { case .started: @@ -88,7 +88,7 @@ class LinkDeviceViewController: UIViewController, StoryboardBased, ViewModelBase case .success: self?.hideHud() self?.showLinkedSuccess() - case .error (let error): + case .error(let error): self?.hideHud() self?.showAccountCreationError(error: error) default: @@ -115,7 +115,7 @@ class LinkDeviceViewController: UIViewController, StoryboardBased, ViewModelBase self.adaptToKeyboardState(for: self.scrollView, with: self.disposeBag) keyboardDismissTapRecognizer = UITapGestureRecognizer(target: self, action: #selector(dismissKeyboard)) NotificationCenter.default.rx.notification(UIDevice.orientationDidChangeNotification) - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] (_) in guard UIDevice.current.portraitOrLandscape else { return } self?.linkButton.updateGradientFrame() diff --git a/Ring/Ring/Features/Walkthrough/LinkToAccountManager/LinkToAccountManagerViewController.swift b/Ring/Ring/Features/Walkthrough/LinkToAccountManager/LinkToAccountManagerViewController.swift index 0840e367fbdaeef51a26ec6e1c6e57e05f19653e..4b33df9742e1cd7b947f85e27329ae8092c6a1a7 100644 --- a/Ring/Ring/Features/Walkthrough/LinkToAccountManager/LinkToAccountManagerViewController.swift +++ b/Ring/Ring/Features/Walkthrough/LinkToAccountManager/LinkToAccountManagerViewController.swift @@ -52,7 +52,7 @@ var viewModel: LinkToAccountManagerViewModel! self.adaptToKeyboardState(for: self.scrollView, with: self.disposeBag) keyboardDismissTapRecognizer = UITapGestureRecognizer(target: self, action: #selector(dismissKeyboard)) NotificationCenter.default.rx.notification(UIDevice.orientationDidChangeNotification) - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] (_) in guard UIDevice.current.portraitOrLandscape else { return } self?.signInButton.updateGradientFrame() @@ -105,14 +105,14 @@ var viewModel: LinkToAccountManagerViewModel! }) .disposed(by: self.disposeBag) self.viewModel.createState - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] (state) in switch state { case .started: self?.showLinkHUD() case .success: self?.hideHud() - case .error (let error): + case .error(let error): self?.hideHud() self?.showAccountCreationError(error: error) default: diff --git a/Ring/Ring/Features/Walkthrough/Welcome/WelcomeViewController.swift b/Ring/Ring/Features/Walkthrough/Welcome/WelcomeViewController.swift index cddc7cd5db2dba35c32d2392ae29b7cf7e584083..1ce33beb72632f0db48a78f0c5fcf6f3f2bbbd39 100644 --- a/Ring/Ring/Features/Walkthrough/Welcome/WelcomeViewController.swift +++ b/Ring/Ring/Features/Walkthrough/Welcome/WelcomeViewController.swift @@ -113,7 +113,7 @@ class WelcomeViewController: UIViewController, StoryboardBased, ViewModelBased { self.createSipAccountButton.setTitleColor(UIColor.jamiTextBlue, for: .normal) NotificationCenter.default.rx .notification(UIDevice.orientationDidChangeNotification) - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] (_) in guard UIDevice.current.portraitOrLandscape else { return } self?.configureWalkrhroughNavigationBar() diff --git a/Ring/Ring/GeneralSettings/GeneralSettingsViewController.swift b/Ring/Ring/GeneralSettings/GeneralSettingsViewController.swift index 47f6be8f65e46d2457b8a44f81cf051e321997ab..0f41f79d0575e3f128ca0941269b557911ee1b32 100644 --- a/Ring/Ring/GeneralSettings/GeneralSettingsViewController.swift +++ b/Ring/Ring/GeneralSettings/GeneralSettingsViewController.swift @@ -77,11 +77,11 @@ class GeneralSettingsViewController: UIViewController, StoryboardBased, ViewMode animated: false) self.viewModel.hardwareAccelerationEnabled .asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .bind(to: switchView.rx.value) .disposed(by: cell.disposeBag) switchView.rx.value - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] (enable) in self?.viewModel.togleHardwareAcceleration(enable: enable) }) diff --git a/Ring/Ring/Helpers/LocalNotificationsHelper.swift b/Ring/Ring/Helpers/LocalNotificationsHelper.swift index 573a216f6305a3e66376c6ffac70b41aa7061942..5800f54f2ef511dbc4648101b1e8ae87dfe195e1 100644 --- a/Ring/Ring/Helpers/LocalNotificationsHelper.swift +++ b/Ring/Ring/Helpers/LocalNotificationsHelper.swift @@ -41,7 +41,7 @@ enum NotificationCallTitle: String { } } -//L10n.Calls.connecting +// L10n.Calls.connecting enum CallAcition: String { case accept = "ACCEPT_ACTION" diff --git a/Ring/Ring/MigrateAccount/MigrateAccountViewController.swift b/Ring/Ring/MigrateAccount/MigrateAccountViewController.swift index b4497bebfa361176823f87809524c0d1005c066d..89caafb63dceee314f34f307074fab94e55bcaa5 100644 --- a/Ring/Ring/MigrateAccount/MigrateAccountViewController.swift +++ b/Ring/Ring/MigrateAccount/MigrateAccountViewController.swift @@ -62,7 +62,7 @@ class MigrateAccountViewController: UIViewController, StoryboardBased, ViewModel keyboardDismissTapRecognizer = UITapGestureRecognizer(target: self, action: #selector(dismissKeyboard)) NotificationCenter.default.rx .notification(UIDevice.orientationDidChangeNotification) - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] (_) in guard UIDevice.current.portraitOrLandscape else { return @@ -165,7 +165,7 @@ class MigrateAccountViewController: UIViewController, StoryboardBased, ViewModel } self.viewModel.migrationState.asObservable() - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self](action) in switch action { case .unknown: diff --git a/Ring/Ring/Models/AccountConfigModel.swift b/Ring/Ring/Models/AccountConfigModel.swift index 61782cd934e8009eb798ba71812eeb5b560370aa..fce34ee54d75e6a8a9f462c7018dd8f987c98e67 100644 --- a/Ring/Ring/Models/AccountConfigModel.swift +++ b/Ring/Ring/Models/AccountConfigModel.swift @@ -18,7 +18,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -import RealmSwift import SwiftyBeaver /** @@ -64,7 +63,7 @@ enum AccountType: String { - expose a clear interface to manipulate the configuration of an account - keep this configuration */ -class AccountConfigModel: Object { +class AccountConfigModel { /** The collection of configuration elements. */ @@ -90,7 +89,7 @@ class AccountConfigModel: Object { let configKeyModel = ConfigKeyModel(withKey: confKey) configValues.updateValue(value, forKey: configKeyModel) } else { - //~ The key given in parameter is not known from Ring. + // ~ The key given in parameter is not known from Ring. log.warning("Can't find key: \(key)") } } diff --git a/Ring/Ring/Models/AccountCredentialsModel.swift b/Ring/Ring/Models/AccountCredentialsModel.swift index 6142afdd26e9ac5e117e07cb355094b08c15bca3..d2083dde15000574f12652a5fca07e23e610be4d 100644 --- a/Ring/Ring/Models/AccountCredentialsModel.swift +++ b/Ring/Ring/Models/AccountCredentialsModel.swift @@ -18,8 +18,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -import RealmSwift - /** Errors that can be thrown when trying create an AccountCredentialsModel @@ -35,10 +33,10 @@ enum CredentialsError: Error { Its responsability: - keep the credentials of an account. */ -class AccountCredentialsModel: Object { - @objc dynamic var username: String = "" - @objc dynamic var password: String = "" - @objc dynamic var accountRealm: String = "" +class AccountCredentialsModel { + var username: String = "" + var password: String = "" + var accountRealm: String = "" /** Constructor. diff --git a/Ring/Ring/Models/ContactModel.swift b/Ring/Ring/Models/ContactModel.swift index 5e1d8993150e5035136d6054e9b93b52d9993bb4..b5dadf682ebb88dfc32348cd57ae90d8ce01f57a 100644 --- a/Ring/Ring/Models/ContactModel.swift +++ b/Ring/Ring/Models/ContactModel.swift @@ -38,7 +38,7 @@ class ContactModel: Equatable { self.hash = contactUri.hash ?? "" } - //only jami contacts + // only jami contacts init(withDictionary dictionary: [String: String]) { if let hash = dictionary["id"] { self.hash = hash diff --git a/Ring/Ring/Protocols/ContactPickerDelegate.swift b/Ring/Ring/Protocols/ContactPickerDelegate.swift index ce9854a076de83ca50a2b62483e71b59f7738af5..a94eaca55a7bbd84c39e4e6524feebedbeff93e6 100644 --- a/Ring/Ring/Protocols/ContactPickerDelegate.swift +++ b/Ring/Ring/Protocols/ContactPickerDelegate.swift @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -protocol ContactPickerDelegate: class { +protocol ContactPickerDelegate: AnyObject { func presentContactPicker(contactPickerVC: ContactPickerViewController) func contactPickerDismissed() } diff --git a/Ring/Ring/Protocols/ConversationNavigation.swift b/Ring/Ring/Protocols/ConversationNavigation.swift index d84951c9050df7c339b2ce8727d923f644a6cf73..a4f6250c60c0f3503ba1804a1d8786f0a64f1aec 100644 --- a/Ring/Ring/Protocols/ConversationNavigation.swift +++ b/Ring/Ring/Protocols/ConversationNavigation.swift @@ -45,7 +45,7 @@ enum ConversationState: State { case migrateAccount(accountId: String) } -protocol ConversationNavigation: class { +protocol ConversationNavigation: AnyObject { var injectionBag: InjectionBag { get } @@ -64,7 +64,7 @@ extension ConversationNavigation where Self: Coordinator, Self: StateableRespons self.startOutgoingCall(contactRingId: contactRingId, userName: name) case .startAudioCall(let contactRingId, let name): self.startOutgoingCall(contactRingId: contactRingId, userName: name, isAudioOnly: true) - case .conversationDetail (let conversationViewModel): + case .conversationDetail(let conversationViewModel): self.showConversation(withConversationViewModel: conversationViewModel) case .contactDetail(let conversationModel): self.presentContactInfo(conversation: conversationModel) diff --git a/Ring/Ring/Protocols/Coordinator.swift b/Ring/Ring/Protocols/Coordinator.swift index cd85a9becebc541dee1346db0152af101ff27a5b..be0c465426cab0c033601d09dede5e56512c803a 100644 --- a/Ring/Ring/Protocols/Coordinator.swift +++ b/Ring/Ring/Protocols/Coordinator.swift @@ -38,7 +38,7 @@ public enum PresentationStyle { } /// A Coordinator drives the navigation of a whole part of the application -protocol Coordinator: class { +protocol Coordinator: AnyObject { /// the root View Controller to display var rootViewController: UIViewController { get } @@ -49,8 +49,8 @@ protocol Coordinator: class { /// Parent coordinator var parentCoordinator: Coordinator? { get set } - ///flag to be setting to true during particular viewController is presenting - ///this property is added to prevent controller to be presenting multiple times, caused by UI lag + /// flag to be setting to true during particular viewController is presenting + /// this property is added to prevent controller to be presenting multiple times, caused by UI lag var presentingVC: [String: Bool] { get set } /// Initializes a new Coordinator with a dependancy injection bag diff --git a/Ring/Ring/Protocols/StateableResponsive.swift b/Ring/Ring/Protocols/StateableResponsive.swift index c0aa52a7aa24df5f86fbed58d4c6e4f1f979f20e..df46e82b4707441944636281db2619b7ab457e8d 100644 --- a/Ring/Ring/Protocols/StateableResponsive.swift +++ b/Ring/Ring/Protocols/StateableResponsive.swift @@ -51,7 +51,7 @@ extension StateableResponsive where Self: Coordinator { self.present(viewController: viewController, withStyle: style, withAnimation: animation, lockWhilePresenting: VCType, disposeBag: self.disposeBag) // bind the stateable to the inner state subject - stateable.state.takeUntil(viewController.rx.deallocated) + stateable.state.take(until: viewController.rx.deallocated) .subscribe(onNext: { [weak self] (state) in self?.stateSubject.onNext(state) }) diff --git a/Ring/Ring/Protocols/ViewModelBased.swift b/Ring/Ring/Protocols/ViewModelBased.swift index 5d7efb38e1a1e13ac83aba8a702e50b5e0665e23..aa5d7b6ea166777d400c05ec79588a17f3744091 100644 --- a/Ring/Ring/Protocols/ViewModelBased.swift +++ b/Ring/Ring/Protocols/ViewModelBased.swift @@ -24,7 +24,7 @@ import UIKit /// We assume that every application ViewModel should be aware of the injection bag /// it allows the factorize a ViewModelBased UIViewController instantiation -protocol ViewModel: class { +protocol ViewModel: AnyObject { /// Initializes a new ViewModel with a dependancy injection bag /// @@ -32,7 +32,7 @@ protocol ViewModel: class { init(with injectionBag: InjectionBag) } -protocol ViewModelBased: class { +protocol ViewModelBased: AnyObject { associatedtype VMType: ViewModel /// The viewModel that will be automagically instantiated by instantiate(with injectionBag: InjectionBag) diff --git a/Ring/Ring/QRCode/ScanViewController.swift b/Ring/Ring/QRCode/ScanViewController.swift index f3a43f0a48f0f4679a1ec834d0c2d18a8dc671b4..7df29e0782ae8931903502de34fdd2c82945d99b 100644 --- a/Ring/Ring/QRCode/ScanViewController.swift +++ b/Ring/Ring/QRCode/ScanViewController.swift @@ -39,11 +39,11 @@ class ScanViewController: UIViewController, StoryboardBased, AVCaptureMetadataOu typealias VMType = ScanViewModel var scannedQrCode: Bool = false - //captureSession manages capture activity and coordinates between input device and captures outputs + // captureSession manages capture activity and coordinates between input device and captures outputs var captureSession: AVCaptureSession? var videoPreviewLayer: AVCaptureVideoPreviewLayer? var viewModel: ScanViewModel! - //Empty Rectangle with border to outline detected QR or BarCode + // Empty Rectangle with border to outline detected QR or BarCode lazy var codeFrame: UIView = { let cFrame = UIView() cFrame.layer.borderColor = UIColor.cyan.cgColor @@ -74,7 +74,7 @@ class ScanViewController: UIViewController, StoryboardBased, AVCaptureMetadataOu self.bottomMarginTitleConstraint.constant = 35 self.bottomCloseButtonConstraint.constant = 25 } - //AVCaptureDevice allows us to reference a physical capture device (video in our case) + // AVCaptureDevice allows us to reference a physical capture device (video in our case) let captureDevice = AVCaptureDevice.default(for: AVMediaType.video) if let captureDevice = captureDevice { @@ -91,14 +91,14 @@ class ScanViewController: UIViewController, StoryboardBased, AVCaptureMetadataOu let captureMetadataOutput = AVCaptureMetadataOutput() captureSession?.addOutput(captureMetadataOutput) - //We tell our Output the expected Meta-data type + // We tell our Output the expected Meta-data type captureMetadataOutput.setMetadataObjectsDelegate(self, queue: DispatchQueue.main) captureMetadataOutput.metadataObjectTypes = [.code128, .qr, .ean13, .ean8, .code39, .upce, .aztec, .pdf417] - //AVMetadataObject.ObjectType + // AVMetadataObject.ObjectType captureSession?.startRunning() - //The videoPreviewLayer displays video in conjunction with the captureSession + // The videoPreviewLayer displays video in conjunction with the captureSession videoPreviewLayer = AVCaptureVideoPreviewLayer(session: captureSession!) if videoPreviewLayer?.connection?.isVideoMirroringSupported ?? false { videoPreviewLayer?.connection?.automaticallyAdjustsVideoMirroring = false @@ -115,7 +115,7 @@ class ScanViewController: UIViewController, StoryboardBased, AVCaptureMetadataOu self.updateOrientation() NotificationCenter.default.rx .notification(UIDevice.orientationDidChangeNotification) - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: {[weak self] (_) in guard let self = self, UIDevice.current.portraitOrLandscape else { return } @@ -160,12 +160,12 @@ class ScanViewController: UIViewController, StoryboardBased, AVCaptureMetadataOu view.addSubview(codeFrame) - //transformedMetaDataObject returns layer coordinates/height/width from visual properties + // transformedMetaDataObject returns layer coordinates/height/width from visual properties guard let metaDataCoordinates = videoPreviewLayer?.transformedMetadataObject(for: metaDataObject) else { return } - //Those coordinates are assigned to our codeFrame + // Those coordinates are assigned to our codeFrame codeFrame.frame = metaDataCoordinates.bounds guard let ringId = stringCodeValue.components(separatedBy: "http://").last else { diff --git a/Ring/Ring/QRCode/ScanViewModel.swift b/Ring/Ring/QRCode/ScanViewModel.swift index 6e07188502b4ba09455eef725845e418961cf769..daf963caa759bd6c9559229426cfd7026c53ef88 100644 --- a/Ring/Ring/QRCode/ScanViewModel.swift +++ b/Ring/Ring/QRCode/ScanViewModel.swift @@ -40,7 +40,7 @@ class ScanViewModel: ViewModel, Stateable { guard let currentAccount = self.injectionBag.accountService.currentAccount else { return } - //Create new converation + // Create new converation let conversation = ConversationModel(withParticipantUri: JamiURI.init(schema: URIType.ring, infoHach: recipientRingId), accountId: currentAccount.id) diff --git a/Ring/Ring/Services/AccountsService.swift b/Ring/Ring/Services/AccountsService.swift index c05e3309f40dc217a1a6845dc868c92ee0ac4bf4..6c1da822850cf8606787a09ee246134745a5ece4 100644 --- a/Ring/Ring/Services/AccountsService.swift +++ b/Ring/Ring/Services/AccountsService.swift @@ -142,14 +142,14 @@ class AccountsService: AccountAdapterDelegate { if currentAccount != newValue { currentWillChange.onNext(currentAccount) } - //Get the current account from account list if already exists + // Get the current account from account list if already exists let currentAccount = self.accountList.filter({ account in return account == newValue }).first guard let newAccount = newValue else { return } - //If current account already exists in the list, move it to the first index + // If current account already exists in the list, move it to the first index if let currentAccount = currentAccount, let index = self.accountList.firstIndex(of: currentAccount) { if index != 0 { @@ -169,13 +169,13 @@ class AccountsService: AccountAdapterDelegate { self.responseStream.disposed(by: disposeBag) - //~ Create a shared stream based on the responseStream one. + // ~ Create a shared stream based on the responseStream one. self.sharedResponseStream = responseStream.share() self.accountAdapter = accountAdapter self.dbManager = dbManager - //~ Registering to the accountAdatpter with self as delegate in order to receive delegation - //~ callbacks. + // ~ Registering to the accountAdatpter with self as delegate in order to receive delegation + // ~ callbacks. AccountAdapter.delegate = self } @@ -215,7 +215,7 @@ class AccountsService: AccountAdapterDelegate { if try !dbManager.createDatabaseForAccount(accountId: account.id) { return false } - //if tables already exist an exeption will be thrown + // if tables already exist an exeption will be thrown } catch { } } } @@ -316,7 +316,7 @@ class AccountsService: AccountAdapterDelegate { /// - password: the required password for the new account /// - Returns: an observable of an AccountModel: the created one func addRingAccount(username: String?, password: String, enable: Bool) -> Observable<AccountModel> { - //~ Single asking the daemon to add a new account with the associated metadata + // ~ Single asking the daemon to add a new account with the associated metadata var newAccountId = "" let createAccountSingle: Single<AccountModel> = Single.create(subscribe: { (single) -> Disposable in do { @@ -335,13 +335,13 @@ class AccountsService: AccountAdapterDelegate { let account = try self.buildAccountFromDaemon(accountId: accountId) single(.success(account)) } catch { - single(.error(error)) + single(.failure(error)) } return Disposables.create { } }) - //~ Filter the daemon signals to isolate the "account created" one. + // ~ Filter the daemon signals to isolate the "account created" one. let filteredDaemonSignals = self.sharedResponseStream .filter({ (serviceEvent) -> Bool in if serviceEvent.getEventInput(ServiceEventInput.accountId) != newAccountId { return false } @@ -356,7 +356,7 @@ class AccountsService: AccountAdapterDelegate { return isRegistrationStateChanged && (isRegistered || notRegistered) }) - //~ Make sure that we have the correct account added in the daemon, and return it. + // ~ Make sure that we have the correct account added in the daemon, and return it. return Observable .combineLatest(createAccountSingle.asObservable(), filteredDaemonSignals.asObservable()) { (accountModel, serviceEvent) -> AccountModel in guard accountModel.id == serviceEvent.getEventInput(ServiceEventInput.accountId) else { @@ -409,7 +409,7 @@ class AccountsService: AccountAdapterDelegate { func linkToRingAccount(withPin pin: String, password: String, enable: Bool) -> Observable<AccountModel> { var newAccountId = "" - //~ Single asking the daemon to add a new account with the associated metadata + // ~ Single asking the daemon to add a new account with the associated metadata let createAccountSingle: Single<AccountModel> = Single.create(subscribe: { (single) -> Disposable in do { var ringDetails = try self.getRingInitialAccountDetails() @@ -423,12 +423,12 @@ class AccountsService: AccountAdapterDelegate { let account = try self.buildAccountFromDaemon(accountId: accountId) single(.success(account)) } catch { - single(.error(error)) + single(.failure(error)) } return Disposables.create { } }) - //~ Filter the daemon signals to isolate the "account created" one. + // ~ Filter the daemon signals to isolate the "account created" one. let filteredDaemonSignals = self.sharedResponseStream.filter { (serviceEvent) -> Bool in if serviceEvent.getEventInput(ServiceEventInput.accountId) != newAccountId { return false } if serviceEvent.getEventInput(ServiceEventInput.registrationState) == ErrorGeneric { @@ -440,7 +440,7 @@ class AccountsService: AccountAdapterDelegate { let isRegistered = serviceEvent.getEventInput(ServiceEventInput.registrationState) == Registered return isRegistrationStateChanged && isRegistered } - //~ Make sure that we have the correct account added in the daemon, and return it. + // ~ Make sure that we have the correct account added in the daemon, and return it. return Observable .combineLatest(createAccountSingle.asObservable(), filteredDaemonSignals.asObservable()) { (accountModel, serviceEvent) -> AccountModel in guard accountModel.id == serviceEvent.getEventInput(ServiceEventInput.accountId) else { diff --git a/Ring/Ring/Services/CallsProviderDelegate.swift b/Ring/Ring/Services/CallsProviderDelegate.swift index c653d679f9846cda454c4c503d8d1779654eb8cf..b6b13d3dc93483c1c7dc5c2e264a6025dd204683 100644 --- a/Ring/Ring/Services/CallsProviderDelegate.swift +++ b/Ring/Ring/Services/CallsProviderDelegate.swift @@ -100,7 +100,7 @@ extension CallsProviderDelegate { let type = account.type == AccountType.ring ? URIType.ring : URIType.sip let uri = JamiURI.init(schema: type, infoHach: call.participantUri, account: account) guard var handle = uri.hash else { return nil } - //for sip contact if account and contact have different host name add contact host name + // for sip contact if account and contact have different host name add contact host name if account.type == AccountType.sip { let accountHostname = account.details? .get(withConfigKeyModel: ConfigKeyModel(withKey: ConfigKey.accountHostname)) ?? "" diff --git a/Ring/Ring/Services/CallsService.swift b/Ring/Ring/Services/CallsService.swift index 7cd69585c68d3c3fada5cdf417ea5ed0f3e1377a..983c5c0918dc9a0f89b15938a66838ef8ea119a0 100644 --- a/Ring/Ring/Services/CallsService.swift +++ b/Ring/Ring/Services/CallsService.swift @@ -325,7 +325,7 @@ class CallsService: CallsAdapterDelegate { userName: String, isAudioOnly: Bool = false) -> Single<CallModel> { - //Create and emit the call + // Create and emit the call var callDetails = [String: String]() callDetails[CallDetailKey.callTypeKey.rawValue] = String(describing: CallType.outgoing) callDetails[CallDetailKey.displayNameKey.rawValue] = userName @@ -350,7 +350,7 @@ class CallsService: CallsAdapterDelegate { self.calls.accept(values) single(.success(call)) } else { - single(.error(CallServiceError.placeCallFailed)) + single(.failure(CallServiceError.placeCallFailed)) } return Disposables.create { } }) @@ -434,10 +434,10 @@ class CallsService: CallsAdapterDelegate { func didChangeCallState(withCallId callId: String, state: String, stateCode: NSInteger) { if let callDictionary = self.callsAdapter.callDetails(withCallId: callId) { - //Add or update new call + // Add or update new call var call = self.calls.value[callId] call?.state = CallState(rawValue: state) ?? CallState.unknown - //Remove from the cache if the call is over and save message to history + // Remove from the cache if the call is over and save message to history if call?.state == .over || call?.state == .failure { guard let finichedCall = call else { return } var time = 0 @@ -480,7 +480,7 @@ class CallsService: CallsAdapterDelegate { call?.update(withDictionary: callDictionary) } guard let newCall = call else { return } - //send vCard + // send vCard if (newCall.state == .ringing && newCall.callType == .outgoing) || (newCall.state == .current && newCall.callType == .incoming) { self.sendVCard(callID: callId, accountID: newCall.accountId) @@ -501,7 +501,7 @@ class CallsService: CallsAdapterDelegate { } } - //Emit the call to the observers + // Emit the call to the observers self.currentCallsEvents.onNext(newCall) } } @@ -551,7 +551,7 @@ class CallsService: CallsAdapterDelegate { } else { call?.update(withDictionary: callDictionary) } - //Emit the call to the observers + // Emit the call to the observers guard let newCall = call else { return } self.newCall.accept(newCall) } else { @@ -610,8 +610,8 @@ class CallsService: CallsAdapterDelegate { } let callId = pending.key var values = pending.value - //update pending conferences - //replace callID by new Conference ID, and remove calls that was already added to onference + // update pending conferences + // replace callID by new Conference ID, and remove calls that was already added to onference values.subtract(conferenceCalls) self.pendingConferences[callId] = nil if !values.isEmpty { diff --git a/Ring/Ring/Services/ContactsService.swift b/Ring/Ring/Services/ContactsService.swift index 4af5e0b3a1fd6cb5fe67b39ce8c7ae93901b96d5..e8f16a05bac961db81211a77ad7b48134404ff74 100644 --- a/Ring/Ring/Services/ContactsService.swift +++ b/Ring/Ring/Services/ContactsService.swift @@ -110,10 +110,10 @@ class ContactsService { } func loadJamiContacts(withAccount account: String) { - //Load contacts from daemon + // Load contacts from daemon let contactsDictionaries = self.contactsAdapter.contacts(withAccountId: account) - //Serialize them + // Serialize them if let contacts = contactsDictionaries?.map({ contactDict in return ContactModel(withDictionary: contactDict) }) { @@ -131,10 +131,10 @@ class ContactsService { func loadContactRequests(withAccount accountId: String) { self.contactRequests.accept([]) - //Load trust requests from daemon + // Load trust requests from daemon let trustRequestsDictionaries = self.contactsAdapter.trustRequests(withAccountId: accountId) - //Create contact requests from daemon trust requests + // Create contact requests from daemon trust requests if let contactRequests = trustRequestsDictionaries?.map({ dictionary in return ContactRequestModel(withDictionary: dictionary, accountId: accountId) }) { @@ -196,7 +196,7 @@ class ContactsService { let success = self.contactsAdapter.discardTrustRequest(fromContact: jamiId, withAccountId: accountId) - //Update the Contact request list + // Update the Contact request list self.removeContactRequest(withRingId: jamiId) if success { @@ -319,7 +319,7 @@ extension ContactsService: ContactsAdapterDelegate { if validContact != nil { return } - //Update trust request list + // Update trust request list if self.contactRequest(withRingId: senderAccount) == nil { let contactRequest = ContactRequestModel(withRingId: senderAccount, vCard: vCard, @@ -345,7 +345,7 @@ extension ContactsService: ContactsAdapterDelegate { } func contactAdded(contact uri: String, withAccountId accountId: String, confirmed: Bool) { - //Update trust request list + // Update trust request list if let hash = JamiURI.init(schema: URIType.ring, infoHach: uri).hash { self.removeContactRequest(withRingId: hash) } @@ -357,12 +357,12 @@ extension ContactsService: ContactsAdapterDelegate { } self.contactStatus.onNext(contact) } - //sync contacts with daemon contacts + // sync contacts with daemon contacts else { let contactsDictionaries = self.contactsAdapter.contacts(withAccountId: accountId) - //Serialize them + // Serialize them if let contacts = contactsDictionaries?.map({ contactDict in return ContactModel(withDictionary: contactDict) }) { @@ -395,10 +395,10 @@ extension ContactsService: ContactsAdapterDelegate { if let vCard = contactRequest.vCard { single(.success(vCard)) } else { - single(.error(ContactServiceError.loadVCardFailed)) + single(.failure(ContactServiceError.loadVCardFailed)) } } else { - single(.error(ContactServiceError.loadVCardFailed)) + single(.failure(ContactServiceError.loadVCardFailed)) } return Disposables.create { } }) @@ -406,7 +406,7 @@ extension ContactsService: ContactsAdapterDelegate { func getProfileForUri(uri: String, accountId: String) -> Observable<Profile> { return self.dbManager.profileObservable(for: uri, createIfNotExists: false, accountId: accountId) - .subscribeOn(ConcurrentDispatchQueueScheduler(qos: .background)) + .subscribe(on: ConcurrentDispatchQueueScheduler(qos: .background)) } func getProfile(uri: String, accountId: String) -> Profile? { diff --git a/Ring/Ring/Services/ConversationsManager.swift b/Ring/Ring/Services/ConversationsManager.swift index dfcf2e962890033151f40e43ba2dc1f9ab86a3ac..7b5c74f237977df9aa397c291c942560b92891e0 100644 --- a/Ring/Ring/Services/ConversationsManager.swift +++ b/Ring/Ring/Services/ConversationsManager.swift @@ -121,7 +121,7 @@ class ConversationsManager: MessagesAdapterDelegate { peerUri: peerUri, accountId: accountId, shouldRefreshConversations: shouldRefresh) - .subscribeOn(ConcurrentDispatchQueueScheduler(qos: .background)) + .subscribe(on: ConcurrentDispatchQueueScheduler(qos: .background)) .subscribe() .disposed(by: self.disposeBag) }) @@ -377,7 +377,7 @@ class ConversationsManager: MessagesAdapterDelegate { return lookupNameResponse.address != nil && lookupNameResponse.address == hash }) - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak self] lookupNameResponse in if let name = lookupNameResponse.name, !name.isEmpty { data [NotificationUserInfoKeys.name.rawValue] = name diff --git a/Ring/Ring/Services/ConversationsService.swift b/Ring/Ring/Services/ConversationsService.swift index b80d9cbbaeade8cbe204d9a32bc81ecb928111cc..492b70ba8e3cdab17ec1630fa8c5fae7782f316c 100644 --- a/Ring/Ring/Services/ConversationsService.swift +++ b/Ring/Ring/Services/ConversationsService.swift @@ -77,7 +77,7 @@ class ConversationsService { shouldUpdateMessagesStatus = false } dbManager.getConversationsObservable(for: accountId) - .subscribeOn(ConcurrentDispatchQueueScheduler(qos: .background)) + .subscribe(on: ConcurrentDispatchQueueScheduler(qos: .background)) .subscribe(onNext: { [weak self] conversationsModels in self?.conversations.accept(conversationsModels) if shouldUpdateMessagesStatus { @@ -106,7 +106,7 @@ class ConversationsService { self.dbManager.updateMessageStatus(daemonID: message.daemonId, withStatus: updatedMessageStatus, accountId: accountId) - .subscribeOn(ConcurrentDispatchQueueScheduler(qos: .background)) + .subscribe(on: ConcurrentDispatchQueueScheduler(qos: .background)) .subscribe(onCompleted: { [] in print("Message status updated - load") }) @@ -187,7 +187,7 @@ class ConversationsService { message: message, incoming: message.incoming, interactionType: interactionType, duration: 0) - .subscribeOn(ConcurrentDispatchQueueScheduler(qos: .background)) + .subscribe(on: ConcurrentDispatchQueueScheduler(qos: .background)) .subscribe(onNext: { [weak self] _ in guard let self = self else { return } // append new message so it can be found if a status update is received before the DB finishes reload @@ -201,7 +201,7 @@ class ConversationsService { self.messagesSemaphore.signal() if shouldRefreshConversations { self.dbManager.getConversationsObservable(for: toAccountId) - .subscribeOn(ConcurrentDispatchQueueScheduler(qos: .background)) + .subscribe(on: ConcurrentDispatchQueueScheduler(qos: .background)) .subscribe(onNext: { [weak self] conversationsModels in self?.conversations.accept(conversationsModels) }) @@ -253,12 +253,12 @@ class ConversationsService { message.isGenerated = true self.dbManager.saveMessage(for: accountId, with: contactUri, message: message, incoming: false, interactionType: interactionType, duration: Int(duration)) - .subscribeOn(ConcurrentDispatchQueueScheduler(qos: .background)) + .subscribe(on: ConcurrentDispatchQueueScheduler(qos: .background)) .subscribe(onNext: { [weak self] _ in guard let self = self else { return } if shouldUpdateConversation { self.dbManager.getConversationsObservable(for: accountId) - .subscribeOn(ConcurrentDispatchQueueScheduler(qos: .background)) + .subscribe(on: ConcurrentDispatchQueueScheduler(qos: .background)) .subscribe(onNext: { conversationsModels in self.conversations.accept(conversationsModels) }) @@ -303,12 +303,12 @@ class ConversationsService { self.dbManager.saveMessage(for: accountId, with: contactUri, message: message, incoming: isIncoming, interactionType: interactionType, duration: 0) - .subscribeOn(ConcurrentDispatchQueueScheduler(qos: .background)) + .subscribe(on: ConcurrentDispatchQueueScheduler(qos: .background)) .subscribe(onNext: { [weak self] message in guard let self = self else { return } self.dataTransferMessageMap[transferId] = message self.dbManager.getConversationsObservable(for: accountId) - .subscribeOn(ConcurrentDispatchQueueScheduler(qos: .background)) + .subscribe(on: ConcurrentDispatchQueueScheduler(qos: .background)) .subscribe(onNext: { conversationsModels in if updateConversation { self.conversations.accept(conversationsModels) @@ -347,7 +347,7 @@ class ConversationsService { .setMessagesAsRead(messagesIDs: [messageID], withStatus: .displayed, accountId: accountId) - .subscribeOn(ConcurrentDispatchQueueScheduler(qos: .background)) + .subscribe(on: ConcurrentDispatchQueueScheduler(qos: .background)) .subscribe() .disposed(by: self.disposeBag) } @@ -357,7 +357,7 @@ class ConversationsService { return Completable.create(subscribe: { [weak self] completable in guard let self = self else { return Disposables.create { } } - //Filter out read, outgoing, and transfer messages + // Filter out read, outgoing, and transfer messages let unreadMessages = conversation.messages.filter({ messages in return messages.status != .displayed && messages.incoming && !messages.isTransfer }) @@ -375,11 +375,11 @@ class ConversationsService { .setMessagesAsRead(messagesIDs: messagesIds, withStatus: .displayed, accountId: accountId) - .subscribeOn(ConcurrentDispatchQueueScheduler(qos: .background)) + .subscribe(on: ConcurrentDispatchQueueScheduler(qos: .background)) .subscribe(onCompleted: { [weak self] in guard let self = self else { return } self.dbManager.getConversationsObservable(for: accountId) - .subscribeOn(ConcurrentDispatchQueueScheduler(qos: .background)) + .subscribe(on: ConcurrentDispatchQueueScheduler(qos: .background)) .subscribe(onNext: { [weak self] conversationsModels in self?.conversations.accept(conversationsModels) }) @@ -398,7 +398,7 @@ class ConversationsService { guard let self = self else { return Disposables.create { } } self.dbManager .deleteMessage(messagesId: messagesId, accountId: accountId) - .subscribeOn(ConcurrentDispatchQueueScheduler(qos: .background)) + .subscribe(on: ConcurrentDispatchQueueScheduler(qos: .background)) .subscribe(onCompleted: { completable(.completed) }, onError: { error in completable(.error(error)) }) .disposed(by: self.disposeBag) return Disposables.create { } @@ -411,13 +411,13 @@ class ConversationsService { func clearHistory(conversation: ConversationModel, keepConversation: Bool) { self.dbManager.clearHistoryFor(accountId: conversation.accountId, and: conversation.participantUri, keepConversation: keepConversation) - .subscribeOn(ConcurrentDispatchQueueScheduler(qos: .background)) + .subscribe(on: ConcurrentDispatchQueueScheduler(qos: .background)) .subscribe(onCompleted: { [weak self] in guard let self = self else { return } self.removeSavedFiles(accountId: conversation.accountId, conversationId: conversation.conversationId) self.dbManager .getConversationsObservable(for: conversation.accountId) - .subscribeOn(ConcurrentDispatchQueueScheduler(qos: .background)) + .subscribe(on: ConcurrentDispatchQueueScheduler(qos: .background)) .subscribe(onNext: { [weak self] conversationsModels in self?.conversations.accept(conversationsModels) }) @@ -449,13 +449,13 @@ class ConversationsService { fromAccount account: AccountModel, to uri: String) { self.messagesSemaphore.wait() - //Get conversations for this sender + // Get conversations for this sender let conversation = self.conversations.value.filter({ conversation in return conversation.participantUri == uri && conversation.accountId == account.id }).first - //Find message + // Find message if let messages: [MessageModel] = conversation?.messages.filter({ (message) -> Bool in return !message.daemonId.isEmpty && message.daemonId == String(messageId) && ((status.rawValue > message.status.rawValue && status != .failure) || @@ -476,7 +476,7 @@ class ConversationsService { .updateMessageStatus(daemonID: message.daemonId, withStatus: status, accountId: account.id) - .subscribeOn(ConcurrentDispatchQueueScheduler(qos: .background)) + .subscribe(on: ConcurrentDispatchQueueScheduler(qos: .background)) .subscribe(onCompleted: { [weak self] in guard let self = self else { return } self.messagesSemaphore.signal() @@ -511,7 +511,7 @@ class ConversationsService { .updateTransferStatus(daemonID: String(transferId), withStatus: transferStatus, accountId: accountId) - .subscribeOn(ConcurrentDispatchQueueScheduler(qos: .background)) + .subscribe(on: ConcurrentDispatchQueueScheduler(qos: .background)) .subscribe(onCompleted: { [weak self] in guard let self = self else { return } self.messagesSemaphore.signal() @@ -610,11 +610,11 @@ extension ConversationsService { return Completable.create(subscribe: { [weak self] completable in guard let self = self else { return Disposables.create { } } self.dbManager.deleteLocationUpdates(incoming: incoming, peerUri: peerUri, accountId: accountId) - .subscribeOn(ConcurrentDispatchQueueScheduler(qos: .background)) + .subscribe(on: ConcurrentDispatchQueueScheduler(qos: .background)) .subscribe(onCompleted: { if shouldRefreshConversations { self.dbManager.getConversationsObservable(for: accountId) - .subscribeOn(ConcurrentDispatchQueueScheduler(qos: .background)) + .subscribe(on: ConcurrentDispatchQueueScheduler(qos: .background)) .subscribe(onNext: { [weak self] conversationsModels in self?.conversations.accept(conversationsModels) }) diff --git a/Ring/Ring/Services/DataTransferService.swift b/Ring/Ring/Services/DataTransferService.swift index 5673d80b4c57ed1a9d3c3b494272e5ce6f08fe5d..79cfa6a8bbecf035632fa32324b955bfe9245db6 100644 --- a/Ring/Ring/Services/DataTransferService.swift +++ b/Ring/Ring/Services/DataTransferService.swift @@ -83,7 +83,7 @@ public final class DataTransferService: DataTransferAdapterDelegate { private let log = SwiftyBeaver.self - //contain image if transfering file is image type, othewise contain nil + // contain image if transfering file is image type, othewise contain nil typealias ImageTuple = (isImage: Bool, data: UIImage?) private var transferedImages = [String: ImageTuple]() @@ -129,7 +129,7 @@ public final class DataTransferService: DataTransferAdapterDelegate { let fileSizeWithUnit = ByteCountFormatter.string(fromByteCount: info.totalSize, countStyle: .file) let name = pathUrl.lastPathComponent + "\n" + fileSizeWithUnit fileName = name - //update db + // update db self.dbManager.updateFileName(interactionID: interactionID, name: name, accountId: accountID) .subscribe(onCompleted: { [weak self] in self?.log.debug("file name updated") diff --git a/Ring/Ring/Services/LocationSharingService.swift b/Ring/Ring/Services/LocationSharingService.swift index 43374af872179785ee93a9817f452c595a5ee1c7..da6a5faa4840f43373cee896b7528b04b1044814 100644 --- a/Ring/Ring/Services/LocationSharingService.swift +++ b/Ring/Ring/Services/LocationSharingService.swift @@ -30,13 +30,13 @@ enum SerializableLocationTypes: String { // swiftlint:enable redundant_string_enum_value struct SerializableLocation: Codable { - var type: String? //position (optional) and stop - var lat: Double? //position - var long: Double? //position - var alt: Double? //position - var time: Int64 //position and stop - var bearing: Float? //position (optional) - var speed: Float? //position (optional) + var type: String? // position (optional) and stop + var lat: Double? // position + var long: Double? // position + var alt: Double? // position + var time: Int64 // position and stop + var bearing: Float? // position (optional) + var speed: Float? // position (optional) } private class LocationSharingInstanceDictionary<T: LocationSharingInstance> { diff --git a/Ring/Ring/Services/NameService.swift b/Ring/Ring/Services/NameService.swift index 0e0ceb3c76096a7f99b7aaf2ea37c0e22d5cc124..c8f359666a48fadfbbf4e759bca7e20b0eacf337 100644 --- a/Ring/Ring/Services/NameService.swift +++ b/Ring/Ring/Services/NameService.swift @@ -74,7 +74,7 @@ class NameService { /// Make a username lookup request to the daemon func lookupName(withAccount account: String, nameserver: String, name: String) { - //Cancel previous lookups... + // Cancel previous lookups... delayedLookupNameCall?.cancel() if name.isEmpty { @@ -82,7 +82,7 @@ class NameService { } else { usernameValidationStatus.onNext(.lookingUp) - //Fire a delayed lookup... + // Fire a delayed lookup... delayedLookupNameCall = DispatchWorkItem { self.nameRegistrationAdapter.lookupName(withAccount: account, nameserver: nameserver, name: name) } diff --git a/Ring/Ring/Services/ProfilesService.swift b/Ring/Ring/Services/ProfilesService.swift index 359157de4352fd6e48209d1163bfcd5b937e0987..220e58cf9002287644f450be415147dcc6f985a3 100644 --- a/Ring/Ring/Services/ProfilesService.swift +++ b/Ring/Ring/Services/ProfilesService.swift @@ -39,7 +39,7 @@ enum ProfileNotificationsKeys: String { } struct Base64VCard { - var data: [Int: String] //The key is the number of vCard part + var data: [Int: String] // The key is the number of vCard part var partsReceived: Int } @@ -118,7 +118,7 @@ class ProfilesService: ProfilesAdapterDelegate { if let vCardKey = message.keys.filter({ $0.hasPrefix(self.ringVCardMIMEType) }).first { - //Parse the key to get the number of parts and the current part number + // Parse the key to get the number of parts and the current part number let components = vCardKey.components(separatedBy: ",") guard let partComponent = components.filter({ $0.hasPrefix("part=") }).first else { @@ -158,7 +158,7 @@ class ProfilesService: ProfilesAdapterDelegate { } } - //Build the vCard when all data are appended + // Build the vCard when all data are appended if of == numberOfReceivedChunk { self.buildVCardFromChunks(cardID: id, ringID: ringId, accountId: accountId) } @@ -172,7 +172,7 @@ class ProfilesService: ProfilesAdapterDelegate { let vCardChunks = vcard.data - //Append data from sorted part numbers + // Append data from sorted part numbers var vCardData = Data() for currentPartNumber in vCardChunks.keys.sorted() { if let currentData = vCardChunks[currentPartNumber]?.data(using: String.Encoding.utf8) { @@ -185,7 +185,7 @@ class ProfilesService: ProfilesAdapterDelegate { vCardData = dataUtf16 } - //Create the vCard, save and db and emit a new event + // Create the vCard, save and db and emit a new event if let vCard = CNContactVCardSerialization.parseToVCard(data: vCardData) { let name = VCardUtils.getName(from: vCard) var stringImage: String? diff --git a/Ring/Ring/Services/VideoService.swift b/Ring/Ring/Services/VideoService.swift index a633d91d620ee70adc1ca7eb7a95663da387fbf0..1bdaa7f1e6fae6b04bd2c710dd7fa828fc66b4df 100644 --- a/Ring/Ring/Services/VideoService.swift +++ b/Ring/Ring/Services/VideoService.swift @@ -49,7 +49,7 @@ enum VideoCodecs: String { case unknown } -protocol FrameExtractorDelegate: class { +protocol FrameExtractorDelegate: AnyObject { func captured(imageBuffer: CVImageBuffer?, image: UIImage) func updateDevicePosition(position: AVCaptureDevice.Position) } diff --git a/Ring/Ring/UI/ProgressView.swift b/Ring/Ring/UI/ProgressView.swift index 310e5dd1c51b18ac132747ba6fde2ebd4a00564c..24fdc40f8fe3ac013f338e818d5287bafa316700 100644 --- a/Ring/Ring/UI/ProgressView.swift +++ b/Ring/Ring/UI/ProgressView.swift @@ -165,7 +165,7 @@ class ProgressView: UIView { self.addSubview(statusLabel) disposeBug = DisposeBag() self.statusLabelValue - .observeOn(MainScheduler.instance) + .observe(on: MainScheduler.instance) .subscribe(onNext: { [weak statusLabel] (text) in statusLabel?.text = text }) diff --git a/Ring/RingTests/AccountModelHelperTests.swift b/Ring/RingTests/AccountModelHelperTests.swift index d2009bf1d5c6859a5a405331f8e97910bf88462a..399cb5c3969def818da9fb4210af81a13b645618 100644 --- a/Ring/RingTests/AccountModelHelperTests.swift +++ b/Ring/RingTests/AccountModelHelperTests.swift @@ -32,7 +32,7 @@ class AccountModelHelperTests: XCTestCase { override func setUp() { super.setUp() - //~ Dummy account + // ~ Dummy account account = AccountModel(withAccountId: "identifier") }