Update rn-user-defaults version and checks for both Android and iOS native credentials when there isn't migation for now.
This commit is contained in:
parent
47dc644478
commit
890190d0cc
|
@ -204,6 +204,8 @@ dependencies {
|
|||
addUnimodulesDependencies()
|
||||
implementation project(':reactnativenotifications')
|
||||
implementation project(":reactnativekeyboardinput")
|
||||
implementation project(':rn-user-defaults')
|
||||
|
||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||
implementation "com.facebook.react:react-native:+" // From node_modules
|
||||
implementation "com.google.firebase:firebase-messaging:18.0.0"
|
||||
|
|
|
@ -14,6 +14,7 @@ import com.facebook.react.ReactPackage;
|
|||
import com.facebook.soloader.SoLoader;
|
||||
|
||||
import chat.rocket.reactnative.generated.BasePackageList;
|
||||
import chat.rocket.userdefaults;
|
||||
|
||||
import org.unimodules.adapters.react.ModuleRegistryAdapter;
|
||||
import org.unimodules.adapters.react.ReactModuleRegistryProvider;
|
||||
|
@ -54,6 +55,7 @@ public class MainApplication extends Application implements ReactApplication, IN
|
|||
packages.add(new KeyboardInputPackage(MainApplication.this));
|
||||
packages.add(new RNNotificationsPackage(MainApplication.this));
|
||||
packages.add(new ModuleRegistryAdapter(mModuleRegistryProvider));
|
||||
packages.add(new RNUserDefaultsPackage());
|
||||
return packages;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,4 +7,6 @@ project(':reactnativenotifications').projectDir = new File(rootProject.projectDi
|
|||
include ':reactnativekeyboardinput'
|
||||
project(':reactnativekeyboardinput').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-keyboard-input/lib/android')
|
||||
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
|
||||
include ':rn-user-defaults'
|
||||
project(':rn-user-defaults').projectDir = new File(rootProject.projectDir, '../node_modules/rn-user-defaults/android')
|
||||
include ':app'
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
// This file hosts the contansts with the values used on native apps (User Defaults on iOS and Shared Preferences on Android).
|
||||
import { isIOS } from '../utils/deviceInfo';
|
||||
|
||||
export const SERVERS = isIOS ? 'kServers' : 'ACCOUNTS_KEY';
|
||||
export const TOKEN = isIOS ? 'kAuthToken' : 'authToken';
|
||||
export const USER_ID = isIOS ? 'kUserId' : 'userId';
|
||||
export const SERVER_URL = isIOS ? 'kAuthServerURL' : 'serverUrl';
|
||||
export const SERVER_NAME = isIOS ? 'kServerName' : 'serverName';
|
||||
export const SERVER_ICON = isIOS ? 'kServerIconURL' : 'serverLogoUrl';
|
|
@ -1,6 +0,0 @@
|
|||
export const SHARED_PREFERENCES_ACCOUNTS_KEY = 'ACCOUNTS_KEY';
|
||||
export const ANDROID_TOKEN = 'authToken';
|
||||
export const ANDROID_USER_ID = 'userId';
|
||||
export const ANDROID_SERVER_URL = 'serverUrl';
|
||||
export const ANDROID_SERVER_NAME = 'serverName';
|
||||
export const ANDROID_SERVER_ICON = 'serverLogoUrl';
|
|
@ -1,6 +0,0 @@
|
|||
export const SERVERS = 'kServers';
|
||||
export const TOKEN = 'kAuthToken';
|
||||
export const USER_ID = 'kUserId';
|
||||
export const SERVER_URL = 'kAuthServerURL';
|
||||
export const SERVER_NAME = 'kServerName';
|
||||
export const SERVER_ICON = 'kServerIconURL';
|
|
@ -40,7 +40,7 @@ import sendMessage, { getMessage, sendMessageCall } from './methods/sendMessage'
|
|||
import { sendFileMessage, cancelUpload, isUploadActive } from './methods/sendFileMessage';
|
||||
|
||||
import { getDeviceToken } from '../notifications/push';
|
||||
import { SERVERS, SERVER_URL } from '../constants/userDefaults';
|
||||
import { SERVERS, SERVER_URL } from '../constants/native';
|
||||
|
||||
const TOKEN_KEY = 'reactnativemeteor_usertoken';
|
||||
const SORT_PREFS_KEY = 'RC_SORT_PREFS_KEY';
|
||||
|
|
|
@ -14,16 +14,13 @@ import Navigation from '../lib/Navigation';
|
|||
import database from '../lib/realm';
|
||||
import {
|
||||
SERVERS, SERVER_ICON, SERVER_NAME, SERVER_URL, TOKEN, USER_ID
|
||||
} from '../constants/userDefaults';
|
||||
} from '../constants/native';
|
||||
import { isIOS } from '../utils/deviceInfo';
|
||||
|
||||
const restore = function* restore() {
|
||||
try {
|
||||
let hasMigration;
|
||||
if (isIOS) {
|
||||
yield RNUserDefaults.setName('group.ios.chat.rocket');
|
||||
hasMigration = yield AsyncStorage.getItem('hasMigration');
|
||||
}
|
||||
yield RNUserDefaults.setName(isIOS ? 'group.ios.chat.rocket' : 'chat.rocket.android');
|
||||
const hasMigration = yield AsyncStorage.getItem('hasMigration');
|
||||
|
||||
let { token, server } = yield all({
|
||||
token: RNUserDefaults.get(RocketChat.TOKEN_KEY),
|
||||
|
@ -31,7 +28,7 @@ const restore = function* restore() {
|
|||
});
|
||||
|
||||
// get native credentials
|
||||
if (isIOS && !hasMigration) {
|
||||
if (!hasMigration) {
|
||||
const { serversDB } = database.databases;
|
||||
const servers = yield RNUserDefaults.objectForKey(SERVERS);
|
||||
if (servers) {
|
||||
|
|
|
@ -15,7 +15,7 @@ import RocketChat from '../lib/rocketchat';
|
|||
import database from '../lib/realm';
|
||||
import log from '../utils/log';
|
||||
import I18n from '../i18n';
|
||||
import { SERVERS, TOKEN, SERVER_URL } from '../constants/userDefaults';
|
||||
import { SERVERS, TOKEN, SERVER_URL } from '../constants/native';
|
||||
|
||||
const getServerInfo = function* getServerInfo({ server, raiseError = true }) {
|
||||
try {
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
"remove-markdown": "^0.3.0",
|
||||
"rn-extensions-share": "^2.3.10",
|
||||
"rn-fetch-blob": "^0.10.16",
|
||||
"rn-user-defaults": "^1.3.5",
|
||||
"rn-user-defaults": "^1.4.5",
|
||||
"semver": "6.3.0",
|
||||
"snyk": "1.210.0",
|
||||
"strip-ansi": "5.2.0"
|
||||
|
|
Loading…
Reference in New Issue