1.3.7-2 - Test Build - Added progress for fetching file size.
This commit is contained in:
@@ -6,7 +6,6 @@ import i18n from "i18next";
|
||||
import moment from "moment";
|
||||
import React, { useEffect } from "react";
|
||||
import { Button } from "react-native-paper";
|
||||
import { SafeAreaView } from "react-native-safe-area-context";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { logImEXEvent } from "../../firebase/firebase.analytics";
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { ActivityIndicator, Image, StyleSheet, View } from "react-native";
|
||||
import { Title, Subheading } from "react-native-paper";
|
||||
import { Title, Subheading, Divider } from "react-native-paper";
|
||||
import Logo from "../../assets/logo192.png";
|
||||
import SignOutButton from "../sign-out-button/sign-out-button.component";
|
||||
|
||||
export default function ScreenSplash({ noAccess }) {
|
||||
const { t } = useTranslation();
|
||||
@@ -18,6 +19,8 @@ export default function ScreenSplash({ noAccess }) {
|
||||
<Subheading style={{ textAlign: "center" }}>
|
||||
{t("app.nomobileaccess")}
|
||||
</Subheading>
|
||||
<Divider />
|
||||
<SignOutButton />
|
||||
</View>
|
||||
) : (
|
||||
<ActivityIndicator color="dodgerblue" size="large" />
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { useApolloClient } from "@apollo/client";
|
||||
import * as FileSystem from "expo-file-system";
|
||||
import * as MediaLibrary from "expo-media-library";
|
||||
import _ from "lodash";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import {
|
||||
@@ -9,12 +8,11 @@ import {
|
||||
Alert,
|
||||
Modal,
|
||||
Platform,
|
||||
ScrollView,
|
||||
StyleSheet,
|
||||
Text,
|
||||
View,
|
||||
} from "react-native";
|
||||
import { ProgressBar } from "react-native-paper";
|
||||
import { Divider, ProgressBar } from "react-native-paper";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { logImEXEvent } from "../../firebase/firebase.analytics";
|
||||
@@ -29,7 +27,6 @@ import {
|
||||
} from "../../redux/user/user.selectors";
|
||||
import { formatBytes, handleUpload } from "../../util/document-upload.utility";
|
||||
import Toast from "react-native-toast-message";
|
||||
import { validateArgCount } from "@firebase/util";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
currentUser: selectCurrentUser,
|
||||
@@ -122,6 +119,14 @@ export function UploadProgress({
|
||||
}
|
||||
|
||||
const onDone = async (selectedFiles) => {
|
||||
setProgress((progress) => {
|
||||
return {
|
||||
...progress,
|
||||
uploadInProgress: true,
|
||||
statusText: "Preparing upload...",
|
||||
};
|
||||
});
|
||||
|
||||
//Validate to make sure the totals for the file sizes do not exceed the total on the job.
|
||||
const data = [];
|
||||
const totalOfUploads = await selectedFiles.reduce(async (acc, val) => {
|
||||
@@ -151,7 +156,7 @@ export function UploadProgress({
|
||||
...progress,
|
||||
speed: 0,
|
||||
action: null,
|
||||
|
||||
statusText: null,
|
||||
uploadInProgress: false,
|
||||
}));
|
||||
Alert.alert(
|
||||
@@ -162,21 +167,17 @@ export function UploadProgress({
|
||||
}
|
||||
}
|
||||
//We made it this far. We have enough space, so let's start uploading.
|
||||
|
||||
setProgress((progress) => {
|
||||
return {
|
||||
...progress,
|
||||
uploadInProgress: true,
|
||||
|
||||
totalToUpload: totalOfUploads,
|
||||
totalUploaded: 0,
|
||||
totalFilesCompleted: 0,
|
||||
startTime: new Date(),
|
||||
totalFiles: data.length,
|
||||
currentFile: null,
|
||||
files: {}, //uri is the key, value is progress
|
||||
};
|
||||
});
|
||||
setProgress((progress) => ({
|
||||
...progress,
|
||||
totalToUpload: totalOfUploads,
|
||||
totalUploaded: 0,
|
||||
totalFilesCompleted: 0,
|
||||
startTime: new Date(),
|
||||
totalFiles: data.length,
|
||||
currentFile: null,
|
||||
statusText: null,
|
||||
files: {}, //uri is the key, value is progress
|
||||
}));
|
||||
|
||||
for (var i = 0; i < data.length + 4; i = i + 4) {
|
||||
//Reset the files.
|
||||
@@ -264,7 +265,16 @@ export function UploadProgress({
|
||||
text: "Yes",
|
||||
onPress: () => {
|
||||
setUploads(null);
|
||||
setProgress(null);
|
||||
setProgress({
|
||||
uploadInProgress: false,
|
||||
totalToUpload: 0,
|
||||
totalUploaded: 0,
|
||||
totalFilesCompleted: 0,
|
||||
startTime: null,
|
||||
totalFiles: 0,
|
||||
currentFile: null,
|
||||
files: {},
|
||||
});
|
||||
},
|
||||
},
|
||||
{ text: "No" },
|
||||
@@ -308,10 +318,20 @@ export function UploadProgress({
|
||||
</View>
|
||||
))}
|
||||
<View style={styles.centeredView}>
|
||||
<Text>{`${progress.totalFilesCompleted} of ${progress.totalFiles} uploaded.`}</Text>
|
||||
<Text>{`${formatBytes(progress.totalUploaded)} of ${formatBytes(
|
||||
progress.totalToUpload
|
||||
)} uploaded.`}</Text>
|
||||
{progress.statusText ? (
|
||||
<>
|
||||
<ActivityIndicator style={{ marginLeft: 12 }} />
|
||||
<Text style={{ marginLeft: 4 }}>{progress.statusText}</Text>
|
||||
<Divider />
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Text>{`${progress.totalFilesCompleted} of ${progress.totalFiles} uploaded.`}</Text>
|
||||
<Text>{`${formatBytes(progress.totalUploaded)} of ${formatBytes(
|
||||
progress.totalToUpload
|
||||
)} uploaded.`}</Text>
|
||||
</>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
Reference in New Issue
Block a user