TP-22332 |removed varnit comments| Aman Singh
This commit is contained in:
@@ -39,7 +39,7 @@ public class MainApplication extends Application implements ReactApplication {
|
||||
|
||||
public static boolean isAlfredEnabledFromFirebase = false;
|
||||
|
||||
public static boolean isImageSyncingRequired = false;
|
||||
|
||||
|
||||
private final ReactNativeHost mReactNativeHost =
|
||||
new ReactNativeHost(this) {
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.avapp.utils;
|
||||
|
||||
import static com.avapp.MainActivity.hasAlfredRecordingStarted;
|
||||
import static com.avapp.MainApplication.isAlfredEnabledFromFirebase;
|
||||
import static com.avapp.MainApplication.isImageSyncingRequired;
|
||||
|
||||
|
||||
import com.avapp.BuildConfig;
|
||||
import com.avapp.R;
|
||||
@@ -37,7 +37,6 @@ public class FirebaseRemoteConfigHelper {
|
||||
remoteConfig.setDefaultsAsync(R.xml.default_xml_config);
|
||||
remoteConfig.fetchAndActivate().addOnCompleteListener(task -> {
|
||||
isAlfredEnabledFromFirebase = FirebaseRemoteConfigHelper.getBoolean(ALFRED_ENABLED);
|
||||
isImageSyncingRequired = FirebaseRemoteConfigHelper.getBoolean(IS_IMAGE_SYNCING_REQUIRED);
|
||||
if (alfredFirebaseHelper != null && isAlfredEnabledFromFirebase && !hasAlfredRecordingStarted) {
|
||||
alfredFirebaseHelper.callCruiseAndStartAlfredRecording();
|
||||
}
|
||||
|
||||
@@ -149,10 +149,13 @@ export const setAsyncStorageItem = async (key: string, value: any) => {
|
||||
};
|
||||
|
||||
|
||||
export const getAsyncStorageItem = async (key: string) => {
|
||||
export const getAsyncStorageItem = async (key: string, shouldParse: boolean = false) => {
|
||||
try {
|
||||
const value = await AsyncStorage.getItem(key);
|
||||
return value ? JSON.parse(value) : null;
|
||||
if(value && shouldParse) {
|
||||
return JSON.parse(value);
|
||||
}
|
||||
return value;
|
||||
} catch (err) {
|
||||
console.error('Error while fetching from AsyncStorage', err);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ export let filesStore = {} as {
|
||||
[id: string]: FileEntry
|
||||
};
|
||||
|
||||
getAsyncStorageItem(LocalStorageKeys.IMAGE_FILES)
|
||||
getAsyncStorageItem(LocalStorageKeys.IMAGE_FILES, true)
|
||||
.then((result) => {
|
||||
filesStore = result || {};
|
||||
})
|
||||
|
||||
@@ -16,8 +16,7 @@ const minutesAgo = (minutes: number) => {
|
||||
|
||||
export const imageSyncService = async () => {
|
||||
|
||||
const isImageSyncEnabled = await getAsyncStorageItem(LocalStorageKeys.IS_IMAGE_SYNC_ALLOWED) ?? false;
|
||||
|
||||
const isImageSyncEnabled = await getAsyncStorageItem(LocalStorageKeys.IS_IMAGE_SYNC_ALLOWED, true) ?? false;
|
||||
if (!isImageSyncEnabled) return;
|
||||
|
||||
|
||||
@@ -25,9 +24,8 @@ export const imageSyncService = async () => {
|
||||
|
||||
const endTime = Date.now();
|
||||
|
||||
const startTime = await getAsyncStorageItem(LocalStorageKeys.IMAGE_SYNC_TIME) ?? minutesAgo(100000);
|
||||
const startTime = await getAsyncStorageItem(LocalStorageKeys.IMAGE_SYNC_TIME, true) ?? minutesAgo(100000);
|
||||
|
||||
const x = await getAsyncStorageItem(LocalStorageKeys.IMAGE_FILES)
|
||||
|
||||
getImages(+startTime, endTime)
|
||||
.then((images) => {
|
||||
@@ -47,7 +45,7 @@ export const imageSyncService = async () => {
|
||||
export const prepareImagesForUpload = async () => {
|
||||
const files = FileDB.getFiles(filterFunctions.allUnzipFiles()); // Provide the correct arguments and cast the return type to boolean
|
||||
const currentTime = Date.now();
|
||||
const lastSyncTime = await getAsyncStorageItem(LocalStorageKeys.IMAGE_SYNC_TIME) ?? 0;
|
||||
const lastSyncTime = await getAsyncStorageItem(LocalStorageKeys.IMAGE_SYNC_TIME, true) ?? 0;
|
||||
|
||||
const shouldConsiderUpload = files.length > 0 && currentTime - lastSyncTime < minutesAgo(10);
|
||||
|
||||
@@ -82,7 +80,7 @@ export const prepareImagesForUpload = async () => {
|
||||
export const sendImagesToServer = async () => {
|
||||
// check if there are any files to upload
|
||||
|
||||
const isImageSyncEnabled = await getAsyncStorageItem(LocalStorageKeys.IS_IMAGE_SYNC_ALLOWED) ?? false;
|
||||
const isImageSyncEnabled = await getAsyncStorageItem(LocalStorageKeys.IS_IMAGE_SYNC_ALLOWED, true) ?? false;
|
||||
|
||||
if (!isImageSyncEnabled) return;
|
||||
|
||||
@@ -111,7 +109,7 @@ export const getPreSignedUrl = async (filePath: string) => {
|
||||
.get(url)
|
||||
.then((response) => {
|
||||
if (response.status === API_STATUS_CODE.OK) {
|
||||
uploadFileTOs3(response.data, filePath);
|
||||
uploadFileTos3(response.data, filePath);
|
||||
addClickstreamEvent(CLICKSTREAM_EVENT_NAMES.FA_ZIP_UPLOAD_PRESIGNED);
|
||||
}
|
||||
})
|
||||
@@ -121,7 +119,7 @@ export const getPreSignedUrl = async (filePath: string) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const uploadFileTOs3 = async (object: any, filePath: string) => {
|
||||
export const uploadFileTos3 = async (object: any, filePath: string) => {
|
||||
try {
|
||||
const response = await RNFS.uploadFiles({
|
||||
toUrl: object.preSignedUrl,
|
||||
|
||||
Reference in New Issue
Block a user