Skip to content

Commit

Permalink
update realm sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitriy-Holovnia committed May 16, 2022
1 parent cf8d47b commit e4ebfc0
Show file tree
Hide file tree
Showing 35 changed files with 95 additions and 79 deletions.
4 changes: 2 additions & 2 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ target 'o-fish-ios' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!

pod 'RealmSwift', '= 10.0.0-beta.3'
pod 'RealmSwift', '~>10'
pod 'SwiftLint'
end

target 'O-FISHTests' do
use_frameworks!

pod 'RealmSwift', '= 10.0.0-beta.3'
pod 'RealmSwift', '~>10'
pod 'SwiftLint'
end

Expand Down
18 changes: 9 additions & 9 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
PODS:
- Realm (10.0.0-beta.3):
- Realm/Headers (= 10.0.0-beta.3)
- Realm/Headers (10.0.0-beta.3)
- RealmSwift (10.0.0-beta.3):
- Realm (= 10.0.0-beta.3)
- Realm (10.19.0):
- Realm/Headers (= 10.19.0)
- Realm/Headers (10.19.0)
- RealmSwift (10.19.0):
- Realm (= 10.19.0)
- SwiftLint (0.40.1)

DEPENDENCIES:
- RealmSwift (= 10.0.0-beta.3)
- RealmSwift (~> 10)
- SwiftLint

SPEC REPOS:
Expand All @@ -17,10 +17,10 @@ SPEC REPOS:
- SwiftLint

SPEC CHECKSUMS:
Realm: f563a59a1016ce551fd87e39df79d393bd06e56d
RealmSwift: 4b79ee6f9b67bf71b8122370e2614892912f7172
Realm: 869ab2a7e3bdfa6bf06d8723251539f504e6f602
RealmSwift: f1f51c4a02fe826e5cea623b5441992f06bdc942
SwiftLint: bbfed21bf4451dcbd0f5cdbee44a18e06cf91b12

PODFILE CHECKSUM: e3d5aecdbb48256f2e86c5875619cd8f306ee440
PODFILE CHECKSUM: 3747d906485678a9674749188e2f48757a180e6a

COCOAPODS: 1.11.2
2 changes: 1 addition & 1 deletion o-fish-ios/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler([.alert, .badge, .sound])
completionHandler([.badge, .sound])
}
}
14 changes: 7 additions & 7 deletions o-fish-ios/Helpers/KeychainWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import LocalAuthentication

struct Credentials {
struct AppCredentials {
var username: String
var password: String
}
Expand All @@ -30,7 +30,7 @@ class KeychainWrapper {
case none
}

func addCredentials(_ credentials: Credentials) -> Error? {
func addCredentials(_ credentials: AppCredentials) -> Error? {
var errorIn: Error?
do {
try addCredentials(credentials, server: server)
Expand All @@ -44,9 +44,9 @@ class KeychainWrapper {
return errorIn
}

func readCredentials() -> (error: Error?, credentials: Credentials?) {
func readCredentials() -> (error: Error?, credentials: AppCredentials?) {
var errorIn: Error?
var credentials: Credentials?
var credentials: AppCredentials?
do {
credentials = try readCredentials(server: server)
print("Credentials were read.")
Expand All @@ -72,7 +72,7 @@ class KeychainWrapper {
return errorIn
}

private func addCredentials(_ credentials: Credentials, server: String) throws {
private func addCredentials(_ credentials: AppCredentials, server: String) throws {

let account = credentials.username
guard let password = credentials.password.data(using: String.Encoding.utf8) else {
Expand All @@ -98,7 +98,7 @@ class KeychainWrapper {
guard status == errSecSuccess else { throw KeychainError(status: status) }
}

private func readCredentials(server: String) throws -> Credentials {
private func readCredentials(server: String) throws -> AppCredentials {
let query: [String: Any] = [kSecClass as String: kSecClassInternetPassword,
kSecAttrServer as String: server,
kSecMatchLimit as String: kSecMatchLimitOne,
Expand All @@ -119,7 +119,7 @@ class KeychainWrapper {
throw KeychainError(status: errSecInternalError)
}

return Credentials(username: account, password: password)
return AppCredentials(username: account, password: password)
}

private func deleteCredentials(server: String) throws {
Expand Down
2 changes: 1 addition & 1 deletion o-fish-ios/Model/Report/Activity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import RealmSwift

class Activity: EmbeddedObject, ObservableObject {
class Activity: EmbeddedObject {
@objc dynamic var name = ""
@objc dynamic var attachments: Attachments? = Attachments()
}
2 changes: 1 addition & 1 deletion o-fish-ios/Model/Report/AnnotatedNote.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import RealmSwift

class AnnotatedNote: EmbeddedObject, ObservableObject, Identifiable {
class AnnotatedNote: EmbeddedObject, Identifiable {
@objc dynamic var note = ""
let photoIDs = List<String>()
}
2 changes: 1 addition & 1 deletion o-fish-ios/Model/Report/Attachments.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import RealmSwift

class Attachments: EmbeddedObject, ObservableObject {
class Attachments: EmbeddedObject {
let notes = List<String>()
let photoIDs = List<String>()
}
2 changes: 1 addition & 1 deletion o-fish-ios/Model/Report/Boat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import RealmSwift

class Boat: EmbeddedObject, ObservableObject {
class Boat: EmbeddedObject {
@objc dynamic var name = ""
@objc dynamic var homePort = ""
@objc dynamic var nationality = ""
Expand Down
2 changes: 1 addition & 1 deletion o-fish-ios/Model/Report/Catch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import RealmSwift

class Catch: EmbeddedObject, ObservableObject {
class Catch: EmbeddedObject {
@objc dynamic var fish = ""
@objc dynamic var number = 0
@objc dynamic var weight = 0.0
Expand Down
2 changes: 1 addition & 1 deletion o-fish-ios/Model/Report/CrewMember.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import RealmSwift

class CrewMember: EmbeddedObject, ObservableObject {
class CrewMember: EmbeddedObject {
@objc dynamic var name = ""
@objc dynamic var license = ""
@objc dynamic var attachments: Attachments? = Attachments()
Expand Down
2 changes: 1 addition & 1 deletion o-fish-ios/Model/Report/Delivery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import RealmSwift

class Delivery: EmbeddedObject, ObservableObject {
class Delivery: EmbeddedObject {
@objc dynamic var date = NSDate(timeIntervalSince1970: 0)
@objc dynamic var location = ""
@objc dynamic var business = ""
Expand Down
2 changes: 1 addition & 1 deletion o-fish-ios/Model/Report/EMS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import RealmSwift

class EMS: EmbeddedObject, ObservableObject {
class EMS: EmbeddedObject {
@objc dynamic var emsType = ""
@objc dynamic var emsDescription = ""
@objc dynamic var registryNumber = ""
Expand Down
2 changes: 1 addition & 1 deletion o-fish-ios/Model/Report/Fishery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import RealmSwift

class Fishery: EmbeddedObject, ObservableObject {
class Fishery: EmbeddedObject {
@objc dynamic var name = ""
@objc dynamic var attachments: Attachments? = Attachments()
}
2 changes: 1 addition & 1 deletion o-fish-ios/Model/Report/GearType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import RealmSwift

class GearType: EmbeddedObject, ObservableObject {
class GearType: EmbeddedObject {
@objc dynamic var name = ""
@objc dynamic var attachments: Attachments? = Attachments()
}
2 changes: 1 addition & 1 deletion o-fish-ios/Model/Report/Inspection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import RealmSwift

class Inspection: EmbeddedObject, ObservableObject {
class Inspection: EmbeddedObject {
@objc dynamic var activity: Activity? = Activity()
@objc dynamic var fishery: Fishery? = Fishery()
@objc dynamic var gearType: GearType? = GearType()
Expand Down
2 changes: 1 addition & 1 deletion o-fish-ios/Model/Report/Offence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import RealmSwift

class Offence: EmbeddedObject, ObservableObject {
class Offence: EmbeddedObject {
@objc dynamic var code = ""
@objc dynamic var explanation = ""
}
2 changes: 1 addition & 1 deletion o-fish-ios/Model/Report/SafetyLevel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import RealmSwift

class SafetyLevel: EmbeddedObject, ObservableObject {
class SafetyLevel: EmbeddedObject {
@objc dynamic var level = ""
@objc dynamic var amberReason = ""
@objc dynamic var attachments: Attachments? = Attachments()
Expand Down
2 changes: 1 addition & 1 deletion o-fish-ios/Model/Report/Seizures.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import RealmSwift

class Seizures: EmbeddedObject, ObservableObject {
class Seizures: EmbeddedObject {
@objc dynamic var text = ""
@objc dynamic var attachments: Attachments? = Attachments()
}
2 changes: 1 addition & 1 deletion o-fish-ios/Model/Report/Summary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import RealmSwift

class Summary: EmbeddedObject, ObservableObject {
class Summary: EmbeddedObject {
@objc dynamic var safetyLevel: SafetyLevel? = SafetyLevel()
let violations = List<Violation>()
@objc dynamic var seizures: Seizures? = Seizures()
Expand Down
2 changes: 1 addition & 1 deletion o-fish-ios/Model/Report/Violation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import RealmSwift

class Violation: EmbeddedObject, ObservableObject {
class Violation: EmbeddedObject {
@objc dynamic var disposition = ""
@objc dynamic var offence: Offence? = Offence()
@objc dynamic var crewMember: CrewMember? = CrewMember()
Expand Down
10 changes: 5 additions & 5 deletions o-fish-ios/Model/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Settings: ObservableObject {

extension RealmSwift.User {
var partition: String {
guard case let .document(agency) = self.customData?["agency"],
guard case let .document(agency) = self.customData["agency"],
case let .string(partition) = agency["name"] else {
print("Partition not set")
return ""
Expand All @@ -39,7 +39,7 @@ extension RealmSwift.User {
}

var firstName: String {
guard case let .document(name) = self.customData?["name"],
guard case let .document(name) = self.customData["name"],
case let .string(first) = name["first"] else {
print("First name not set")
return "John"
Expand All @@ -48,7 +48,7 @@ extension RealmSwift.User {
}

var lastName: String {
guard case let .document(name) = self.customData?["name"],
guard case let .document(name) = self.customData["name"],
case let .string(last) = name["last"] else {
print("Last name not set")
return "Doe"
Expand All @@ -57,15 +57,15 @@ extension RealmSwift.User {
}

var emailAddress: String {
guard case let .string(email) = self.customData?["email"] else {
guard case let .string(email) = self.customData["email"] else {
print("email not set")
return "[email protected]"
}
return email
}

var profilePictureDocumentId: String? {
guard case let .string(profilePic) = self.customData?["profilePic"] else {
guard case let .string(profilePic) = self.customData["profilePic"] else {
return nil
}
return profilePic
Expand Down
2 changes: 1 addition & 1 deletion o-fish-ios/Model/User/Name.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import RealmSwift

class Name: EmbeddedObject, ObservableObject {
class Name: EmbeddedObject {
@objc dynamic var first = ""
@objc dynamic var last = ""
}
2 changes: 1 addition & 1 deletion o-fish-ios/Model/User/User.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import RealmSwift

class User: EmbeddedObject, ObservableObject {
class User: EmbeddedObject {
@objc dynamic var name: Name? = Name()
@objc dynamic var email = ""
}
6 changes: 3 additions & 3 deletions o-fish-ios/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
Self.shared = self
let rootView = MainNavigationRootView()

if app.currentUser()?.state == .loggedIn {
self.settings.realmUser = app.currentUser()
if app.currentUser?.state == .loggedIn {
self.settings.realmUser = app.currentUser
}

UIView.appearance(whenContainedInInstancesOf: [UIAlertController.self]).tintColor = UIColor.actionBlue
Expand Down Expand Up @@ -80,7 +80,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
}

func sceneDidEnterBackground(_ scene: UIScene) {
if DutyState.shared.onDuty && app.currentUser()?.state == .loggedIn {
if DutyState.shared.onDuty && app.currentUser?.state == .loggedIn {
NotificationManager.shared.requestNotificationAfterClosing(hours: Constants.Notifications.hoursAfterClosing)
}
}
Expand Down
6 changes: 3 additions & 3 deletions o-fish-ios/ViewModel/Report/PhotoViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class PhotoViewModel: ObservableObject, Identifiable {
func save() {
let isNew = photo == nil
do {
guard let realm = app.currentUser()?.agencyRealm() else {
guard let realm = app.currentUser?.agencyRealm() else {
print("Can't access Realm")
return
}
Expand All @@ -66,7 +66,7 @@ class PhotoViewModel: ObservableObject, Identifiable {

func delete() {
do {
guard let realm = app.currentUser()?.agencyRealm() else {
guard let realm = app.currentUser?.agencyRealm() else {
print("Can't access Realm to delete photo")
return
}
Expand All @@ -85,7 +85,7 @@ class PhotoViewModel: ObservableObject, Identifiable {

static func delete(photoID: String) {
do {
guard let realm = app.currentUser()?.agencyRealm() else {
guard let realm = app.currentUser?.agencyRealm() else {
print("Can't access Realm to delete photo")
return
}
Expand Down
2 changes: 1 addition & 1 deletion o-fish-ios/ViewModel/Report/ReportViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ReportViewModel: ObservableObject, Identifiable {

init() {
self.captain.isCaptain = true
guard let user = app.currentUser() else {
guard let user = app.currentUser else {
return
}
self.reportingOfficer.email = user.emailAddress
Expand Down
2 changes: 1 addition & 1 deletion o-fish-ios/ViewModel/User/DutyChangeViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class DutyChangeViewModel: ObservableObject {
func save(existingObject: Bool = false) {
let isNew = (dutyChange == nil)
do {
guard let realm = app.currentUser()?.agencyRealm() else {
guard let realm = app.currentUser?.agencyRealm() else {
print("Realm not avaialable")
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct PhotoIDsDisplayView: View {
do {
let _id = try ObjectId(string: id)
let predicate = NSPredicate(format: "_id == %@", _id)
let realmPhotos = app.currentUser()?.agencyRealm()?.objects(Photo.self).filter(predicate)
let realmPhotos = app.currentUser?.agencyRealm()?.objects(Photo.self).filter(predicate)
if let realmPhotos = realmPhotos {
if let photo = realmPhotos.first {
photoList.photos.append(PhotoViewModel(photo: photo))
Expand Down
Loading

0 comments on commit e4ebfc0

Please sign in to comment.