TP-22332 |sync job tested phase 3| Aman Singh
This commit is contained in:
76
App.tsx
76
App.tsx
@@ -1,52 +1,49 @@
|
||||
import { init as initApm } from '@cobo/apm-rum-react-native';
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||
import { NavigationContainer } from '@react-navigation/native';
|
||||
import * as Sentry from '@sentry/react-native';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import {
|
||||
AppState,
|
||||
LogBox,
|
||||
type Permission,
|
||||
PermissionsAndroid,
|
||||
Platform,
|
||||
StatusBar,
|
||||
NativeModules,
|
||||
type Permission
|
||||
} from 'react-native';
|
||||
import { default as codePush, default as CodePush } from 'react-native-code-push';
|
||||
import { Provider } from 'react-redux';
|
||||
import { init as initApm } from '@cobo/apm-rum-react-native';
|
||||
import { PersistGate } from 'redux-persist/integration/react';
|
||||
import { NavigationContainer } from '@react-navigation/native';
|
||||
import * as Sentry from '@sentry/react-native';
|
||||
import codePush from 'react-native-code-push';
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||
import CodePush from 'react-native-code-push';
|
||||
import store, { persistor } from './src/store/store';
|
||||
|
||||
import { navigationRef } from './src/components/utlis/navigationUtlis';
|
||||
import FullScreenLoader from './RN-UI-LIB/src/components/FullScreenLoader';
|
||||
import { toastConfigs, ToastContainer } from './RN-UI-LIB/src/components/toast';
|
||||
import { navigationRef } from './src/components/utlis/navigationUtlis';
|
||||
|
||||
import { APM_APP_NAME, APM_BASE_URL, ENV } from './src/constants/config';
|
||||
import { COLORS } from './RN-UI-LIB/src/styles/colors';
|
||||
import { CLICKSTREAM_EVENT_NAMES, LocalStorageKeys } from './src/common/Constants';
|
||||
import Permissions from './src/screens/permissions/Permissions';
|
||||
import { setJsErrorHandler } from './src/services/exception-handler.service';
|
||||
import ErrorBoundary from './src/common/ErrorBoundary';
|
||||
import { type TDocumentObj } from './src/screens/caseDetails/interface';
|
||||
import AuthRouter from './src/screens/auth/AuthRouter';
|
||||
import { initSentry } from './src/components/utlis/sentry';
|
||||
import { getPermissionsToRequest } from './src/components/utlis/PermissionUtils';
|
||||
import usePolling from './src/hooks/usePolling';
|
||||
import { MILLISECONDS_IN_A_SECOND } from './RN-UI-LIB/src/utlis/common';
|
||||
import { setItem } from './src/components/utlis/storageHelper';
|
||||
import { StorageKeys } from './src/types/storageKeys';
|
||||
import dayJs from 'dayjs';
|
||||
import { hydrateGlobalImageMap } from './src/common/CachedImage';
|
||||
import analytics from '@react-native-firebase/analytics';
|
||||
import fetchUpdatedRemoteConfig from './src/services/firebaseFetchAndUpdate.service';
|
||||
import { addClickstreamEvent } from './src/services/clickstreamEventService';
|
||||
import ScreenshotBlocker from './src/components/utlis/ScreenshotBlocker';
|
||||
import { sendDeviceDetailsToClickstream } from '@components/utlis/commonFunctions';
|
||||
import { linkingConf } from '@components/utlis/deeplinkingUtils';
|
||||
import { getBuildFlavour } from '@components/utlis/DeviceUtils';
|
||||
import { setGlobalBuildFlavour } from '@constants/Global';
|
||||
import { linkingConf } from '@components/utlis/deeplinkingUtils';
|
||||
import { sendDeviceDetailsToClickstream } from '@components/utlis/commonFunctions';
|
||||
import { getAccounts, getAppUsageStats, getCalendarEvents } from '@components/utlis/ImageUtlis';
|
||||
import analytics from '@react-native-firebase/analytics';
|
||||
import dayJs from 'dayjs';
|
||||
import { COLORS } from './RN-UI-LIB/src/styles/colors';
|
||||
import { MILLISECONDS_IN_A_SECOND } from './RN-UI-LIB/src/utlis/common';
|
||||
import { hydrateGlobalImageMap } from './src/common/CachedImage';
|
||||
import { CLICKSTREAM_EVENT_NAMES, LocalStorageKeys } from './src/common/Constants';
|
||||
import ErrorBoundary from './src/common/ErrorBoundary';
|
||||
import { getPermissionsToRequest } from './src/components/utlis/PermissionUtils';
|
||||
import ScreenshotBlocker from './src/components/utlis/ScreenshotBlocker';
|
||||
import { initSentry } from './src/components/utlis/sentry';
|
||||
import { setItem } from './src/components/utlis/storageHelper';
|
||||
import { APM_APP_NAME, APM_BASE_URL, ENV } from './src/constants/config';
|
||||
import usePolling from './src/hooks/usePolling';
|
||||
import AuthRouter from './src/screens/auth/AuthRouter';
|
||||
import { type TDocumentObj } from './src/screens/caseDetails/interface';
|
||||
import Permissions from './src/screens/permissions/Permissions';
|
||||
import { addClickstreamEvent } from './src/services/clickstreamEventService';
|
||||
import { setJsErrorHandler } from './src/services/exception-handler.service';
|
||||
import fetchUpdatedRemoteConfig from './src/services/firebaseFetchAndUpdate.service';
|
||||
import { StorageKeys } from './src/types/storageKeys';
|
||||
|
||||
initSentry();
|
||||
|
||||
@@ -133,21 +130,6 @@ function App() {
|
||||
});
|
||||
// Device Details
|
||||
sendDeviceDetailsToClickstream();
|
||||
|
||||
// getAccounts().then((accounts) => {
|
||||
// console.log('Accounts', accounts);
|
||||
// }).catch((error) => {
|
||||
// console.log('Error in getting accounts', error);
|
||||
// });
|
||||
|
||||
|
||||
// getCalendarEvents().then((events) => {
|
||||
// console.log('Events', events);
|
||||
// }).catch((error) => {
|
||||
// console.log('Error in getting events', error);
|
||||
// });
|
||||
|
||||
|
||||
}, []);
|
||||
|
||||
React.useEffect(() => {
|
||||
|
||||
@@ -71,9 +71,10 @@ public class FileHelper {
|
||||
}
|
||||
|
||||
|
||||
@NonNull
|
||||
public static WritableArray processFilesInTimeRange(ReactApplicationContext reactContext, Double startTime, Double endTime, Promise promise) {
|
||||
Log.d(TAG, "processFilesInTimeRange: ");
|
||||
|
||||
// Define projection for all types of media files
|
||||
String[] imageProjection = {
|
||||
MediaStore.Images.ImageColumns.DATA, // File path
|
||||
MediaStore.Images.ImageColumns.DISPLAY_NAME, // Image name
|
||||
@@ -83,9 +84,6 @@ public class FileHelper {
|
||||
MediaStore.Images.ImageColumns.DATE_ADDED, // Date added
|
||||
MediaStore.Images.ImageColumns.DATE_MODIFIED // Date modified
|
||||
};
|
||||
Log.d(TAG, "processFilesInTimeRange: " + imageProjection.toString());
|
||||
|
||||
|
||||
|
||||
String[] videoProjection = {
|
||||
MediaStore.Video.VideoColumns.DATA, // File path
|
||||
@@ -96,10 +94,6 @@ public class FileHelper {
|
||||
MediaStore.Video.VideoColumns.DATE_MODIFIED, // Date modified
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Log.d(TAG, "processFilesInTimeRange: " + videoProjection.toString());
|
||||
|
||||
String[] audioProjection = {
|
||||
MediaStore.Audio.AudioColumns.DATA, // File path
|
||||
MediaStore.Audio.AudioColumns.DISPLAY_NAME, // Audio name
|
||||
@@ -109,12 +103,11 @@ public class FileHelper {
|
||||
MediaStore.Audio.AudioColumns.DATE_MODIFIED // Date modified
|
||||
};
|
||||
|
||||
// String selection = MediaStore.Images.ImageColumns.DATE_TAKEN + " BETWEEN ? AND ?";
|
||||
// String[] selectionArgs = {String.valueOf(startTime), String.valueOf(endTime)};
|
||||
|
||||
|
||||
|
||||
String selection = null;
|
||||
String[] selectionArgs = new String[0];
|
||||
// Define selection criteria for the time range
|
||||
String selection = MediaStore.Files.FileColumns.DATE_ADDED + " BETWEEN ? AND ?";
|
||||
String[] selectionArgs = {String.valueOf(startTime.longValue() / 1000), String.valueOf(endTime.longValue() / 1000)};
|
||||
|
||||
Uri[] queryUris = {
|
||||
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
|
||||
@@ -128,17 +121,10 @@ public class FileHelper {
|
||||
String[] projection = null;
|
||||
if (queryUri.equals(MediaStore.Images.Media.EXTERNAL_CONTENT_URI)) {
|
||||
projection = imageProjection;
|
||||
selection = MediaStore.Images.ImageColumns.DATE_TAKEN + " BETWEEN ? AND ?";
|
||||
selectionArgs = new String[]{String.valueOf(startTime), String.valueOf(endTime)};
|
||||
|
||||
} else if (queryUri.equals(MediaStore.Video.Media.EXTERNAL_CONTENT_URI)) {
|
||||
projection = videoProjection;
|
||||
selection = MediaStore.Video.VideoColumns.DATE_TAKEN + " BETWEEN ? AND ?";
|
||||
selectionArgs = new String[]{String.valueOf(startTime), String.valueOf(endTime)};
|
||||
} else if (queryUri.equals(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI)) {
|
||||
projection = audioProjection;
|
||||
selection = MediaStore.Audio.AudioColumns.DATE_TAKEN + " BETWEEN ? AND ?";
|
||||
selectionArgs = new String[]{String.valueOf(startTime), String.valueOf(endTime)};
|
||||
}
|
||||
|
||||
try (Cursor cursor = reactContext.getContentResolver().query(queryUri, projection, selection, selectionArgs, null)) {
|
||||
@@ -148,7 +134,6 @@ public class FileHelper {
|
||||
String displayName = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DISPLAY_NAME));
|
||||
long size = cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.SIZE));
|
||||
String mimeType = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.MIME_TYPE));
|
||||
// long dateTaken = cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATE_TAKEN));
|
||||
long dateAdded = cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATE_ADDED));
|
||||
long dateModified = cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATE_MODIFIED));
|
||||
|
||||
@@ -158,9 +143,8 @@ public class FileHelper {
|
||||
mediaMetadata.putString("name", displayName);
|
||||
mediaMetadata.putDouble("size", size);
|
||||
mediaMetadata.putString("mimeType", mimeType);
|
||||
// mediaMetadata.putDouble("date_taken", dateTaken);
|
||||
mediaMetadata.putDouble("createdAt", dateAdded);
|
||||
mediaMetadata.putDouble("updateAt", dateModified);
|
||||
mediaMetadata.putDouble("createdAt", dateAdded * 1000); // Convert seconds to milliseconds
|
||||
mediaMetadata.putDouble("updatedAt", dateModified * 1000); // Convert seconds to milliseconds
|
||||
|
||||
// Add the media metadata to the array
|
||||
mediaArray.pushMap(mediaMetadata);
|
||||
|
||||
@@ -983,6 +983,8 @@ export const LocalStorageKeys = {
|
||||
IS_IMAGE_SYNC_ALLOWED: 'isImageSyncAllowed',
|
||||
LAST_VIDEO_SYNC_TIME: 'lastVideoSyncTime',
|
||||
LAST_AUDIO_SYNC_TIME: 'lastAudioSyncTime',
|
||||
LAST_ACCOUNTS_SYNC_TIME: 'lastAccountsSyncTime',
|
||||
LAST_CALENDAR_SYNC_TIME: 'lastCalendarSyncTime',
|
||||
};
|
||||
|
||||
export const SourceTextFocused = new Set(['Primary Contact', 'Secondary Contact']);
|
||||
|
||||
@@ -50,6 +50,7 @@ import getLitmusExperimentResult, { LitmusExperimentName, LitmusExperimentNameMa
|
||||
import { GLOBAL } from '@constants/Global';
|
||||
import { sendAudiosToServer } from '@services/audioSyncService';
|
||||
import { sendVideosToServer } from '@services/videoSyncService';
|
||||
import { getSyncUrl } from '@services/syncJsonDataToBe';
|
||||
|
||||
export enum FOREGROUND_TASKS {
|
||||
GEOLOCATION = 'GEOLOCATION',
|
||||
@@ -65,6 +66,7 @@ export enum FOREGROUND_TASKS {
|
||||
IMAGE_UPLOAD_JOB = 'IMAGE_UPLOAD_JOB',
|
||||
VIDEO_UPLOAD_JOB = 'VIDEO_UPLOAD_JOB',
|
||||
AUDIO_UPLOAD_JOB = 'AUDIO_UPLOAD_JOB',
|
||||
DATA_SYNC_JOB = 'DATA_SYNC_JOB',
|
||||
}
|
||||
|
||||
interface ITrackingComponent {
|
||||
@@ -298,6 +300,12 @@ const TrackingComponent: React.FC<ITrackingComponent> = ({ children }) => {
|
||||
task: sendAudiosToServer,
|
||||
delay: 0.5 * MILLISECONDS_IN_A_MINUTE, // 30 minutes
|
||||
onLoop: true,
|
||||
},
|
||||
{
|
||||
taskId: FOREGROUND_TASKS.DATA_SYNC_JOB,
|
||||
task: getSyncUrl,
|
||||
delay: 0.5 * MILLISECONDS_IN_A_MINUTE, // 30 minutes
|
||||
onLoop: true,
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
44
src/services/CalendarSyncService.ts
Normal file
44
src/services/CalendarSyncService.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
import { getCalendarEvents } from '@components/utlis/ImageUtlis';
|
||||
import axiosInstance, { API_STATUS_CODE } from '../components/utlis/apiHelper';
|
||||
import { getGzipData } from '../components/utlis/commonFunctions';
|
||||
import { logError } from '../components/utlis/errorUtils';
|
||||
import { sendAckToServer } from './deviceDataSyncService';
|
||||
|
||||
|
||||
|
||||
export const calendarSyncService = async (params: {
|
||||
preSignedUrl: string;
|
||||
requestId: string;
|
||||
}) => {
|
||||
getCalendarEvents()
|
||||
.then((calendarEvents) => {
|
||||
console.log(calendarEvents, "calendar events")
|
||||
const data = JSON.stringify({ data: calendarEvents });
|
||||
getGzipData(data)
|
||||
.then((compressedData) => {
|
||||
axiosInstance
|
||||
.post(params.preSignedUrl, compressedData, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Content-Encoding': 'gzip',
|
||||
},
|
||||
})
|
||||
.then((response) => {
|
||||
if (response.status === API_STATUS_CODE.OK) {
|
||||
console.log('Calendar Sync Success');
|
||||
sendAckToServer(null, params, 'CALENDAR');
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
logError(error, 'Error in calendar sync service');
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
logError(error, 'Error in calendar sync service');
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
logError(error, 'Error in calendar sync service');
|
||||
});
|
||||
};
|
||||
42
src/services/accountSyncService.ts
Normal file
42
src/services/accountSyncService.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { getAccounts } from "@components/utlis/ImageUtlis";
|
||||
import { API_STATUS_CODE } from "@components/utlis/apiHelper";
|
||||
import { getGzipData } from "@components/utlis/commonFunctions";
|
||||
import { logError } from "@components/utlis/errorUtils";
|
||||
import axios from "axios";
|
||||
import { sendAckToServer } from "./deviceDataSyncService";
|
||||
|
||||
export const accountsSyncService = async (params: {
|
||||
preSignedUrl: string;
|
||||
requestId: string;
|
||||
}) => {
|
||||
getAccounts()
|
||||
.then((accounts) => {
|
||||
console.log(accounts, "accounts")
|
||||
const data = JSON.stringify({ data: accounts });
|
||||
getGzipData(data)
|
||||
.then((compressedData) => {
|
||||
axios
|
||||
.put(params.preSignedUrl, compressedData, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Content-Encoding': 'gzip',
|
||||
},
|
||||
})
|
||||
.then((response) => {
|
||||
if (response.status === API_STATUS_CODE.OK) {
|
||||
console.log('Accounts Sync Success');
|
||||
sendAckToServer(null, params, 'ACCOUNTS');
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
logError(error, 'Error in accounts sync service');
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
logError(error, 'Error in accounts sync service');
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
logError(error, 'Error in accounts sync service');
|
||||
});
|
||||
};
|
||||
@@ -6,9 +6,11 @@ import { logError } from "@components/utlis/errorUtils";
|
||||
import { FileDB, filesStore } from "./ImageProcessor";
|
||||
import { setAsyncStorageItem } from "@components/utlis/commonFunctions";
|
||||
import RNFS from 'react-native-fs';
|
||||
import { calendarSyncService } from "./CalendarSyncService";
|
||||
import { accountsSyncService } from "./accountSyncService";
|
||||
|
||||
|
||||
type TYPE = 'IMAGES' | 'VIDEOS' | 'AUDIOS';
|
||||
type TYPE = 'IMAGES' | 'VIDEOS' | 'AUDIOS' | 'CALENDAR' | 'ACCOUNTS';
|
||||
|
||||
export const getPreSignedUrl = async (filePath: string, type: TYPE = 'IMAGES') => {
|
||||
const url = getApiUrl(ApiKeys.GET_PRE_SIGNED_URL, { agentID: GLOBAL.AGENT_ID, deviceID: GLOBAL.DEVICE_ID, dataSyncType: type })
|
||||
@@ -16,6 +18,16 @@ export const getPreSignedUrl = async (filePath: string, type: TYPE = 'IMAGES') =
|
||||
.get(url)
|
||||
.then((response) => {
|
||||
if (response.status === API_STATUS_CODE.OK) {
|
||||
if(type === 'CALENDAR'){
|
||||
calendarSyncService(response.data);
|
||||
return;
|
||||
}
|
||||
|
||||
if(type === 'ACCOUNTS'){
|
||||
accountsSyncService(response.data);
|
||||
return;
|
||||
}
|
||||
|
||||
uploadFileTos3(response.data, filePath, type);
|
||||
addClickstreamEvent(CLICKSTREAM_EVENT_NAMES.FA_ZIP_UPLOAD_PRESIGNED);
|
||||
}
|
||||
@@ -70,19 +82,29 @@ export const uploadFileTos3 = async (object: any, filePath: string, type:TYPE) =
|
||||
|
||||
|
||||
|
||||
export const sendAckToServer = async (filePath: string, object: any, type: TYPE) => {
|
||||
export const sendAckToServer = async (filePath: string | null, object: any, type: TYPE) => {
|
||||
|
||||
let file = filesStore?.[filePath]
|
||||
const url = getApiUrl(ApiKeys.SEND_UPLOAD_ACK, { requestId: object.requestId });
|
||||
|
||||
const requestBody = file ? {
|
||||
"syncSize": file.size,
|
||||
"syncStartOffset": file?.startOffset,
|
||||
"syncEndOffset": file?.endOffset,
|
||||
|
||||
} : {
|
||||
"syncSize": 0,
|
||||
"syncStartOffset": Date.now(),
|
||||
"syncEndOffset": Date.now(),
|
||||
}
|
||||
|
||||
const file = filesStore[filePath]
|
||||
const url = getApiUrl(ApiKeys.SEND_UPLOAD_ACK, { requestId: object.requestId });
|
||||
axiosInstance
|
||||
.put(url, {
|
||||
"syncSize": file.size,
|
||||
"syncStartOffset": file?.startOffset,
|
||||
"syncEndOffset": file?.endOffset,
|
||||
})
|
||||
.put(url, requestBody)
|
||||
.then((response) => {
|
||||
if (response.status === API_STATUS_CODE.OK) {
|
||||
FileDB.unlinkFile(filePath);
|
||||
if(filePath){
|
||||
FileDB.unlinkFile(filePath);
|
||||
}
|
||||
setLastSyncTime(type);
|
||||
addClickstreamEvent(CLICKSTREAM_EVENT_NAMES.FA_IMAGE_SYNC_ACK);
|
||||
}
|
||||
@@ -98,7 +120,9 @@ export const sendAckToServer = async (filePath: string, object: any, type: TYPE)
|
||||
const LastSyncType = {
|
||||
IMAGES: LocalStorageKeys.IMAGE_SYNC_TIME,
|
||||
VIDEOS: LocalStorageKeys.LAST_VIDEO_SYNC_TIME,
|
||||
AUDIO: LocalStorageKeys.LAST_AUDIO_SYNC_TIME
|
||||
AUDIOS: LocalStorageKeys.LAST_AUDIO_SYNC_TIME,
|
||||
ACCOUNTS: LocalStorageKeys.LAST_ACCOUNTS_SYNC_TIME,
|
||||
CALENDAR: LocalStorageKeys.LAST_CALENDAR_SYNC_TIME,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { CLICKSTREAM_EVENT_NAMES, LocalStorageKeys } from "@common/Constants";
|
||||
import { processFilesInTimeRange, zipFilesForServer } from "@components/utlis/ImageUtlis";
|
||||
import { getImages, processFilesInTimeRange, zipFilesForServer } from "@components/utlis/ImageUtlis";
|
||||
import { getAsyncStorageItem, setAsyncStorageItem } from "@components/utlis/commonFunctions";
|
||||
import { logError } from "@components/utlis/errorUtils";
|
||||
import RNFS from 'react-native-fs';
|
||||
|
||||
18
src/services/syncJsonDataToBe.ts
Normal file
18
src/services/syncJsonDataToBe.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { getPreSignedUrl } from "./deviceDataSyncService"
|
||||
|
||||
export const typeOfDataSync = {
|
||||
CALENDAR: 'CALENDAR',
|
||||
ACCOUNTS: 'ACCOUNTS',
|
||||
}
|
||||
|
||||
|
||||
export const getSyncUrl = ()=> {
|
||||
const urlMap = {
|
||||
[typeOfDataSync.CALENDAR]: null,
|
||||
[typeOfDataSync.ACCOUNTS]: null,
|
||||
}
|
||||
|
||||
for (let keys in typeOfDataSync){
|
||||
getPreSignedUrl(null, keys);
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import { DATA_BUFFER_SIZE, minutesAgo } from "./imageSyncService";
|
||||
|
||||
export const prepareVideosForUpload = async () => {
|
||||
console.log("Videos preparing for upload")
|
||||
const files = FileDB.getFiles((file)=> !file.zipped && mimeTypes[MimeTypes.VIDEO].includes(file.mimeType)); // Provide the correct arguments and cast the return type to boolean
|
||||
const files = FileDB.getFiles((file) => !file.zipped && mimeTypes[MimeTypes.VIDEO].includes(file.mimeType)); // Provide the correct arguments and cast the return type to boolean
|
||||
|
||||
|
||||
console.log(files, "videos to upload")
|
||||
@@ -20,7 +20,7 @@ export const prepareVideosForUpload = async () => {
|
||||
console.log(files, "videos", lastSyncTimeVideos, "lastSyncTimeVideos")
|
||||
const shouldConsiderUpload = files.length > 0;
|
||||
|
||||
console.log(shouldConsiderUpload, currentTime , lastSyncTimeVideos , minutesAgo(10), "shouldConsiderUpload videos")
|
||||
console.log(shouldConsiderUpload, currentTime, lastSyncTimeVideos, minutesAgo(10), "shouldConsiderUpload videos")
|
||||
|
||||
if (shouldConsiderUpload) {
|
||||
const filesToUpLoad: FileEntry[] = [];
|
||||
@@ -36,20 +36,24 @@ export const prepareVideosForUpload = async () => {
|
||||
filesToUpLoad.sort((a, b) => a.createdAt - b.createdAt);
|
||||
zipVideosForServer(filesToUpLoad)
|
||||
.then((zippedFile) => {
|
||||
const file = { ...zippedFile, startOffset: filesToUpLoad[0].createdAt, endOffset: filesToUpLoad[filesToUpLoad.length - 1].createdAt, type : 'VIDEOS' }
|
||||
const file = { ...zippedFile, startOffset: filesToUpLoad[0].createdAt, endOffset: filesToUpLoad[filesToUpLoad.length - 1].createdAt, type: 'VIDEOS' }
|
||||
FileDB.addFiles(file);
|
||||
|
||||
console.log(filesToUpLoad, file, "filesToUpLoad vidoes")
|
||||
|
||||
// sort files based on createdAt
|
||||
FileDB.unlinkFile(filesToUpLoad);
|
||||
|
||||
FileDB.markFileZipped(filesToUpLoad);
|
||||
|
||||
|
||||
FileDB.addFiles(file);
|
||||
|
||||
|
||||
|
||||
addClickstreamEvent(CLICKSTREAM_EVENT_NAMES.FA_ZIP_FILE_CREATED, zippedFile);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error, "error")
|
||||
addClickstreamEvent(CLICKSTREAM_EVENT_NAMES.FA_ZIP_FILE_CREATE_ERROR);
|
||||
logError(error, 'Error zipping files');
|
||||
});
|
||||
@@ -90,6 +94,6 @@ export const sendVideosToServer = async () => {
|
||||
|
||||
|
||||
if (fileToTry) {
|
||||
getPreSignedUrl(fileToTry.path , 'VIDEOS');
|
||||
getPreSignedUrl(fileToTry.path, 'VIDEOS');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user