From 81af504c17d7c87babfc14479bb0e30e57aa832f Mon Sep 17 00:00:00 2001 From: Kyle Redelinghuys Date: Thu, 18 Aug 2016 21:29:11 +0100 Subject: [PATCH] A lot of goodness. No more hard crashes. --- AddContactView.js | 1 + MainAccountView.js | 23 ++++++++++++++++++++++- TransactionView.js | 4 ++-- ios/BVNK.xcodeproj/project.pbxproj | 12 ++++++------ ios/BVNK/Info.plist | 2 +- libs/RealmDB.js | 12 ++++++------ 6 files changed, 38 insertions(+), 16 deletions(-) diff --git a/AddContactView.js b/AddContactView.js index 9771e25..7d82500 100644 --- a/AddContactView.js +++ b/AddContactView.js @@ -116,6 +116,7 @@ var AddContactView = React.createClass({ diff --git a/MainAccountView.js b/MainAccountView.js index f1d4a82..e7630b5 100644 --- a/MainAccountView.js +++ b/MainAccountView.js @@ -67,12 +67,33 @@ var MainAccountView = React.createClass({ // Update Main Account let userUpdate = db.objects('Account'); var userAccountUpdate = userUpdate.filtered('AccountNumber == $0', userAccountDetails.AccountNumber); + console.log("User from response:"); + console.log(userAccountDetails); + console.log("UserAccountNumber from response:"); + console.log(userAccountDetails.AccountNumber); + console.log("User from DB:"); + console.log(userAccountUpdate); //var userAccountUpdate = userUpdate.slice(0,1).first; if (userAccountUpdate.length == 0) { // @FIXME There are cases where the user stored in the accounts table and the user sent to log in // are two different users. Find the cause and fix. For now we throw an error and send the user out alert("Account stored in database is not the same as login!"); - actions.login({ type: "reset" }); + // Delete all other accounts for now + let accounts = db.objects('Account'); + db.delete(accounts); + let contacts = db.objects('Contacts'); + db.delete(contacts); + let transactions = db.objects('Transactions'); + db.delete(transactions); + let auth = db.objects('AccountAuth'); + db.delete(auth); + let authToken = db.objects('AccountToken'); + db.delete(authToken); + let accountMeta = db.objects('AccountMeta'); + db.delete(accountMeta); + let deviceToken = db.objects('DeviceToken'); + db.delete(deviceToken); + Actions.login({ type: "reset" }); return; } diff --git a/TransactionView.js b/TransactionView.js index 3645ae1..d9bd641 100644 --- a/TransactionView.js +++ b/TransactionView.js @@ -111,8 +111,8 @@ var TransactionView = React.createClass({ render: function() { - //let marker = { latitude: this.props.data.Lat, longitude: this.props.data.Lon }; - let marker = { latitude: 37.7749, longitude: -122.4194 }; + let marker = { latitude: this.props.data.Lat, longitude: this.props.data.Lon }; + //let marker = { latitude: 37.7749, longitude: -122.4194 }; console.log(marker); return ( diff --git a/ios/BVNK.xcodeproj/project.pbxproj b/ios/BVNK.xcodeproj/project.pbxproj index f09a3e2..91fba8f 100644 --- a/ios/BVNK.xcodeproj/project.pbxproj +++ b/ios/BVNK.xcodeproj/project.pbxproj @@ -787,8 +787,8 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; CODE_SIGN_ENTITLEMENTS = BVNK/BVNK.entitlements; - CODE_SIGN_IDENTITY = "iPhone Developer"; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CODE_SIGN_IDENTITY = "iPhone Developer: Kyle Redelinghuys (M484F68P27)"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: Kyle Redelinghuys (M484F68P27)"; DEAD_CODE_STRIPPING = NO; HEADER_SEARCH_PATHS = ( "$(inherited)", @@ -807,7 +807,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = "co.bvnk.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = BVNK; - PROVISIONING_PROFILE = ""; + PROVISIONING_PROFILE = "ea9b07e0-aca6-4e70-a7b7-fa7b292f0d6e"; TARGETED_DEVICE_FAMILY = 1; VALIDATE_PRODUCT = NO; }; @@ -819,8 +819,8 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; CODE_SIGN_ENTITLEMENTS = BVNK/BVNK.entitlements; - CODE_SIGN_IDENTITY = "iPhone Developer"; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CODE_SIGN_IDENTITY = "iPhone Developer: Kyle Redelinghuys (M484F68P27)"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: Kyle Redelinghuys (M484F68P27)"; DEAD_CODE_STRIPPING = NO; HEADER_SEARCH_PATHS = ( "$(inherited)", @@ -840,7 +840,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = "co.bvnk.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = BVNK; - PROVISIONING_PROFILE = ""; + PROVISIONING_PROFILE = "ea9b07e0-aca6-4e70-a7b7-fa7b292f0d6e"; TARGETED_DEVICE_FAMILY = 1; VALIDATE_PRODUCT = YES; }; diff --git a/ios/BVNK/Info.plist b/ios/BVNK/Info.plist index 4884fde..6d77f9b 100644 --- a/ios/BVNK/Info.plist +++ b/ios/BVNK/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 4 + 5 LSApplicationCategoryType LSRequiresIPhoneOS diff --git a/libs/RealmDB.js b/libs/RealmDB.js index 7f335d8..819ce5f 100644 --- a/libs/RealmDB.js +++ b/libs/RealmDB.js @@ -11,9 +11,9 @@ const Realm = require('realm'); const AccountSchema = { name: 'Account', properties: { - AccountNumber: { type: 'string' , indexed: true }, - BankNumber: 'string', - AccountHolderName: 'string', + AccountNumber: { type: 'string' , indexed: true, optional: true, default: '' }, + BankNumber: { type: 'string', optional: true, default: '' }, + AccountHolderName: { type: 'string', optional: true, default: '' }, AccountBalance: { type: 'float', optional: true, default: 0 }, // Decimal Overdraft: { type: 'float', optional: true, default: 0 }, AvailableBalance: { type: 'float', optional: true, default: 0 }, @@ -23,7 +23,7 @@ const AccountSchema = { const AccountAuthSchema = { name: 'AccountAuth', properties: { - AccountNumber: { type: 'string', indexed: true }, + AccountNumber: { type: 'string', indexed: true, optional: true, default: '' }, Password: { type: 'string', optional: true, default: '' }, Timestamp: { type: 'int', optional: true, default: '' }, } @@ -82,13 +82,13 @@ const TransactionsSchema = { const ContactsSchema = { name: 'Contacts', properties: { - ContactName: { type: 'string', indexed: true }, + ContactName: { type: 'string', indexed: true, optional: true, default: '' }, ContactAccountNumber: { type: 'string', optional: true, default: '' }, ContactBankNumber: { type: 'string', optional: true, default: '' }, ContactEmailAddress: { type: 'string', optional: true, default: '' }, } }; -let realm = new Realm({ schema: [ AccountSchema, AccountMetaSchema, AccountAuthSchema, AccountTokenSchema, DeviceTokenSchema, TransactionsSchema, ContactsSchema ], schemaVersion: 18 }); +let realm = new Realm({ schema: [ AccountSchema, AccountMetaSchema, AccountAuthSchema, AccountTokenSchema, DeviceTokenSchema, TransactionsSchema, ContactsSchema ], schemaVersion: 20 }); module.exports = realm;