fix swiftlint warnings
Change-Id: I0fb13c5d263f4f7a994ef411684c9fb01cd972f7
diff --git a/Ring/Ring/Calls/CallViewModel.swift b/Ring/Ring/Calls/CallViewModel.swift
index 3e237c7..805c937 100644
--- a/Ring/Ring/Calls/CallViewModel.swift
+++ b/Ring/Ring/Calls/CallViewModel.swift
@@ -31,6 +31,8 @@
case videoWithSpiner
case video
}
+
+// swiftlint:disable type_body_length
class CallViewModel: Stateable, ViewModel {
// stateable
@@ -95,7 +97,7 @@
}
self.callService.currentConferenceEvent
.asObservable()
- .filter({ [weak self] conference-> Bool in
+ .filter({ [weak self] conference -> Bool in
guard let self = self else { return false }
return conference.calls.contains(self.call?.callId ?? "") ||
conference.conferenceID == self.rendererId
diff --git a/Ring/Ring/Constants/Generated/Images.swift b/Ring/Ring/Constants/Generated/Images.swift
index abadce9..ef796c4 100644
--- a/Ring/Ring/Constants/Generated/Images.swift
+++ b/Ring/Ring/Constants/Generated/Images.swift
@@ -52,7 +52,6 @@
internal static let editSwarmImage = ImageAsset(name: "editSwarmImage")
internal static let enableSpeakerphone = ImageAsset(name: "enable_speakerphone")
internal static let fallbackAvatar = ImageAsset(name: "fallback_avatar")
- internal static let group = ImageAsset(name: "group")
internal static let icBack = ImageAsset(name: "ic_back")
internal static let icContactPicture = ImageAsset(name: "ic_contact_picture")
internal static let icConversationRemove = ImageAsset(name: "ic_conversation_remove")
diff --git a/Ring/Ring/Contact/ContactViewModel.swift b/Ring/Ring/Contact/ContactViewModel.swift
index c81436f..2fd5f32 100644
--- a/Ring/Ring/Contact/ContactViewModel.swift
+++ b/Ring/Ring/Contact/ContactViewModel.swift
@@ -108,7 +108,7 @@
}
let schema: URIType = account.type == .sip ? .sip : .ring
guard let contactURI = JamiURI(schema: schema, infoHach: jamiId).uriString else { return }
- var initialProfile = Profile(jamiId, "", "", schema.getString())
+ var initialProfile = Profile(uri: jamiId, alias: "", photo: "", type: schema.getString())
if let profile = self.contactService.getProfile(uri: contactURI, accountId: conversation.accountId) {
initialProfile = profile
}
diff --git a/Ring/Ring/Database/DBHelpers/InteractionDataHelper.swift b/Ring/Ring/Database/DBHelpers/InteractionDataHelper.swift
index 1dce07d..7e86edd 100644
--- a/Ring/Ring/Database/DBHelpers/InteractionDataHelper.swift
+++ b/Ring/Ring/Database/DBHelpers/InteractionDataHelper.swift
@@ -21,18 +21,18 @@
import SQLite
-typealias Interaction = (
- id: Int64,
- author: String?,
- conversation: Int64,
- timestamp: Int64,
- duration: Int64,
- body: String,
- type: String,
- status: String,
- daemonID: String,
- incoming: Bool
-)
+struct Interaction {
+ var id: Int64
+ var author: String?
+ var conversation: Int64
+ var timestamp: Int64
+ var duration: Int64
+ var body: String
+ var type: String
+ var status: String
+ var daemonID: String
+ var incoming: Bool
+}
final class InteractionDataHelper {
diff --git a/Ring/Ring/Database/DBHelpers/ProfileDataHelper.swift b/Ring/Ring/Database/DBHelpers/ProfileDataHelper.swift
index 6707221..415e4ba 100644
--- a/Ring/Ring/Database/DBHelpers/ProfileDataHelper.swift
+++ b/Ring/Ring/Database/DBHelpers/ProfileDataHelper.swift
@@ -21,12 +21,12 @@
import SQLite
import SwiftyBeaver
-typealias Profile = (
- uri: String,
- alias: String?,
- photo: String?,
- type: String
-)
+struct Profile {
+ var uri: String
+ var alias: String?
+ var photo: String?
+ var type: String
+}
final class ProfileDataHelper {
let contactsProfileTable = Table("profiles")
@@ -58,7 +58,7 @@
guard let row = try dataBase.pluck(accountProfileTable) else { return nil }
// account profile saved in db does not have uri and type,
// return default values that need to be updated by function caller
- return Profile("", row[alias], row[photo], ProfileType.ring.rawValue)
+ return Profile(uri: "", alias: row[alias], photo: row[photo], type: ProfileType.ring.rawValue)
} catch {
return nil
}
diff --git a/Ring/Ring/Database/DBManager.swift b/Ring/Ring/Database/DBManager.swift
index d2423d7..6c1c38c 100644
--- a/Ring/Ring/Database/DBManager.swift
+++ b/Ring/Ring/Database/DBManager.swift
@@ -273,7 +273,7 @@
}
guard let path = self.dbConnections.accountProfilePath(accountId: accountId) else { return false }
let type = accountURI.contains("ring:") ? URIType.ring : URIType.sip
- let profile = Profile(accountURI, accountProfile.alias, accountProfile.photo, type.getString())
+ let profile = Profile(uri: accountURI, alias: accountProfile.alias, photo: accountProfile.photo, type: type.getString())
try self.saveProfile(profile: profile, path: path)
if !self.dbConnections.isAccountProfileExists(accountId: accountId) {
return false
@@ -587,7 +587,7 @@
}
guard let path = self.dbConnections.contactProfilePath(accountId: accountId, profileURI: profileUri, createifNotExists: true) else { return false }
- let profile = Profile(profileUri, alias, image, type.rawValue)
+ let profile = Profile(uri: profileUri, alias: alias, photo: image, type: type.rawValue)
do {
try self.saveProfile(profile: profile, path: path)
@@ -603,7 +603,7 @@
self.dbConnections.createAccountfolder(for: accountId)
}
guard let path = self.dbConnections.accountProfilePath(accountId: accountId) else { return false }
- let profile = Profile(accountURI, alias, photo, type.rawValue)
+ let profile = Profile(uri: accountURI, alias: alias, photo: photo, type: type.rawValue)
do {
try self.saveProfile(profile: profile, path: path)
return self.dbConnections.isAccountProfileExists(accountId: accountId)
@@ -712,11 +712,11 @@
status = InteractionStatus(status: message.transferStatus).rawValue
}
let timeInterval = message.receivedDate.timeIntervalSince1970
- let interaction = Interaction(defaultID, author,
- conversationID, Int64(timeInterval), Int64(duration),
- message.content, interactionType.rawValue,
- status, message.daemonId,
- message.incoming)
+ let interaction = Interaction(id: defaultID, author: author,
+ conversation: conversationID, timestamp: Int64(timeInterval), duration: Int64(duration),
+ body: message.content, type: interactionType.rawValue,
+ status: status, daemonID: message.daemonId,
+ incoming: message.incoming)
if let result = self.interactionHepler.insert(item: interaction, dataBase: dataBase) {
return String(result)
}
@@ -738,7 +738,7 @@
profileURI: profileUri) || !createIfNotExists {
return getProfileFromPath(path: profilePath)
}
- let profile = Profile(profileUri, alias, photo, type.rawValue)
+ let profile = Profile(uri: profileUri, alias: alias, photo: photo, type: type.rawValue)
try self.saveProfile(profile: profile, path: profilePath)
return getProfileFromPath(path: profilePath)
}
@@ -754,7 +754,7 @@
guard let data = data else { return "" }
return data.base64EncodedString()
}(vCard.imageData)
- let profile = Profile(profileURI, vCard.familyName, imageString, type.rawValue)
+ let profile = Profile(uri: profileURI, alias: vCard.familyName, photo: imageString, type: type.rawValue)
return profile
}
diff --git a/Ring/Ring/Features/ContactRequests/ContactRequestsViewController.swift b/Ring/Ring/Features/ContactRequests/ContactRequestsViewController.swift
index 463d232..b5ed122 100644
--- a/Ring/Ring/Features/ContactRequests/ContactRequestsViewController.swift
+++ b/Ring/Ring/Features/ContactRequests/ContactRequestsViewController.swift
@@ -130,7 +130,7 @@
func acceptButtonTapped(withItem item: RequestItem) {
viewModel.accept(withItem: item)
- .subscribe(onError: { [weak self] error in
+ .subscribe(onError: { [weak self] _ in
self?.log.error("Accept trust request failed")
}, onCompleted: { [weak self] in
self?.log.info("Accept trust request done")
@@ -140,7 +140,7 @@
func discardButtonTapped(withItem item: RequestItem) {
viewModel.discard(withItem: item)
- .subscribe(onError: { [weak self] error in
+ .subscribe(onError: { [weak self] _ in
self?.log.error("Discard trust request failed")
}, onCompleted: { [weak self] in
self?.log.info("Discard trust request done")
@@ -150,7 +150,7 @@
func banButtonTapped(withItem item: RequestItem) {
viewModel.ban(withItem: item)
- .subscribe(onError: { [weak self] error in
+ .subscribe(onError: { [weak self] _ in
self?.log.error("Ban trust request failed")
}, onCompleted: { [weak self] in
self?.log.info("Ban trust request done")
diff --git a/Ring/Ring/Features/Conversations/Conversation/InvitationViewModel.swift b/Ring/Ring/Features/Conversations/Conversation/InvitationViewModel.swift
index 02240c8..d652d91 100644
--- a/Ring/Ring/Features/Conversations/Conversation/InvitationViewModel.swift
+++ b/Ring/Ring/Features/Conversations/Conversation/InvitationViewModel.swift
@@ -240,7 +240,7 @@
alias: self.alias)
.subscribe(onCompleted: { [weak self] in
self?.log.info("contact request sent")
- }, onError: { [weak self] (error) in
+ }, onError: { [weak self] (_) in
self?.log.error("error sending contact request")
})
.disposed(by: self.disposeBag)
diff --git a/Ring/Ring/Features/Conversations/views/JamiSearchView/JamiSearchViewModel.swift b/Ring/Ring/Features/Conversations/views/JamiSearchView/JamiSearchViewModel.swift
index 952989c..d63bc91 100644
--- a/Ring/Ring/Features/Conversations/views/JamiSearchView/JamiSearchViewModel.swift
+++ b/Ring/Ring/Features/Conversations/views/JamiSearchView/JamiSearchViewModel.swift
@@ -33,7 +33,10 @@
class JamiSearchViewModel {
- typealias UserSearchModel = (username: String, firstName: String, lastName: String, organization: String, jamiId: String, profilePicture: Data?)
+ struct UserSearchModel {
+ var username, firstName, lastName, organization, jamiId: String
+ var profilePicture: Data?
+ }
let log = SwiftyBeaver.self
diff --git a/Ring/Ring/Features/Me/LinkNewDeviceViewModel.swift b/Ring/Ring/Features/Me/LinkNewDeviceViewModel.swift
index 38d729d..54186ae 100644
--- a/Ring/Ring/Features/Me/LinkNewDeviceViewModel.swift
+++ b/Ring/Ring/Features/Me/LinkNewDeviceViewModel.swift
@@ -139,7 +139,7 @@
} else {
self.generatingState.accept(GeneratingPinState.error(error: PinError.defaultError))
}
- }, onError: { error in
+ }, onError: { _ in
self.generatingState.accept(GeneratingPinState.error(error: PinError.passwordError))
})
.disposed(by: self.disposeBag)
diff --git a/Ring/Ring/Services/NameService.swift b/Ring/Ring/Services/NameService.swift
index ef8838a..b7f914a 100644
--- a/Ring/Ring/Services/NameService.swift
+++ b/Ring/Ring/Services/NameService.swift
@@ -106,7 +106,7 @@
self.nameRegistrationAdapter.registerName(withAccount: account, password: password, name: name)
}
- func registerNameObservable(withAccount account: String, password: String, name: String)-> Observable<Bool> {
+ func registerNameObservable(withAccount account: String, password: String, name: String) -> Observable<Bool> {
let registerName: Single<Bool> =
Single.create(subscribe: { (single) -> Disposable in
let dispatchQueue = DispatchQueue(label: "nameRegistration", qos: .background)
diff --git a/Ring/Ring/Services/ProfilesService.swift b/Ring/Ring/Services/ProfilesService.swift
index 35431cc..b06ff52 100644
--- a/Ring/Ring/Services/ProfilesService.swift
+++ b/Ring/Ring/Services/ProfilesService.swift
@@ -257,7 +257,7 @@
.subscribe(onNext: { profile in
profileObservable.onNext(profile)
}, onError: { (_) in
- profileObservable.onNext(Profile("", nil, nil, ""))
+ profileObservable.onNext(Profile(uri: "", alias: nil, photo: nil, type: ""))
})
.disposed(by: self.disposeBag)
}
diff --git a/Ring/jamiNotificationExtension/EventData.swift b/Ring/jamiNotificationExtension/EventData.swift
index d89725c..2e32ed8 100644
--- a/Ring/jamiNotificationExtension/EventData.swift
+++ b/Ring/jamiNotificationExtension/EventData.swift
@@ -1,17 +1,17 @@
/*
-Copyright (C) 2022 Savoir-faire Linux Inc. *
-Author: Alireza Toghiani Khorasgani alireza.toghiani@savoirfairelinux.com *
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3 of the License, or
-(at your option) any later version. *
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details. *
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
+ Copyright (C) 2022 Savoir-faire Linux Inc. *
+ Author: Alireza Toghiani Khorasgani alireza.toghiani@savoirfairelinux.com *
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version. *
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details. *
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
import Foundation
diff --git a/Ring/jamiNotificationExtension/NotificationService.swift b/Ring/jamiNotificationExtension/NotificationService.swift
index 5033f21..ea9a3a5 100644
--- a/Ring/jamiNotificationExtension/NotificationService.swift
+++ b/Ring/jamiNotificationExtension/NotificationService.swift
@@ -136,49 +136,7 @@
info["displayName"] = name
self.presentCall(info: info)
}
- switch result {
- case .call(let peerId, let hasVideo):
- handleCall(peerId, "\(hasVideo)")
- return
- case .gitMessage:
- /// check if account already acive
- guard !self.accountIsActive else { break }
- self.accountIsActive = true
- self.adapterService.startAccountsWithListener(accountId: self.accountId) { [weak self] event, eventData in
- guard let self = self else {
- return
- }
- switch event {
- case .message:
- self.numberOfMessages += 1
- self.configureMessageNotification(from: eventData.jamiId, body: eventData.content, accountId: self.accountId, conversationId: eventData.conversationId, groupTitle: "")
- case .fileTransferDone:
- if let url = URL(string: eventData.content) {
- self.configureFileNotification(from: eventData.jamiId, url: url, accountId: self.accountId, conversationId: eventData.conversationId)
- } else {
- self.numberOfFiles -= 1
- self.verifyTasksStatus()
- }
- case .syncCompleted:
- self.syncCompleted = true
- self.verifyTasksStatus()
- case .fileTransferInProgress:
- self.numberOfFiles += 1
- case .call:
- handleCall(eventData.jamiId, eventData.content)
- case .invitation:
- self.syncCompleted = true
- self.numberOfMessages += 1
- self.configureMessageNotification(from: eventData.jamiId,
- body: eventData.content,
- accountId: self.accountId,
- conversationId: eventData.conversationId,
- groupTitle: eventData.groupTitle)
- }
- }
- case .unknown:
- break
- }
+ self.handleResult(result: result, handleCall: handleCall)
} catch {
print("serialization failed , \(error)")
}
@@ -193,6 +151,48 @@
finish()
}
+ private func handleResult(result: AdapterService.PeerConnectionRequestType, handleCall: @escaping (String, String) -> Void) {
+ switch result {
+ case .call(let peerId, let hasVideo):
+ handleCall(peerId, "\(hasVideo)")
+ return
+ case .gitMessage:
+ /// check if account already acive
+ guard !self.accountIsActive else { break }
+ self.accountIsActive = true
+ self.adapterService.startAccountsWithListener(accountId: self.accountId) { [weak self] event, eventData in
+ guard let self = self else {
+ return
+ }
+ switch event {
+ case .message:
+ self.numberOfMessages += 1
+ self.configureMessageNotification(from: eventData.jamiId, body: eventData.content, accountId: self.accountId, conversationId: eventData.conversationId, groupTitle: "")
+ case .fileTransferDone:
+ if let url = URL(string: eventData.content) {
+ self.configureFileNotification(from: eventData.jamiId, url: url, accountId: self.accountId, conversationId: eventData.conversationId)
+ } else {
+ self.numberOfFiles -= 1
+ self.verifyTasksStatus()
+ }
+ case .syncCompleted:
+ self.syncCompleted = true
+ self.verifyTasksStatus()
+ case .fileTransferInProgress:
+ self.numberOfFiles += 1
+ case .call:
+ handleCall(eventData.jamiId, eventData.content)
+ case .invitation:
+ self.syncCompleted = true
+ self.numberOfMessages += 1
+ self.configureMessageNotification(from: eventData.jamiId, body: eventData.content, accountId: self.accountId, conversationId: eventData.conversationId, groupTitle: eventData.groupTitle)
+ }
+ }
+ case .unknown:
+ break
+ }
+ }
+
private func verifyTasksStatus() {
guard !self.tasksCompleted else { return } /// we already left taskGroup
/// waiting for lookup