finish sending files for data transfer
This commit is contained in:
@@ -56,10 +56,17 @@ export default class FileTransferModel {
|
||||
};
|
||||
|
||||
// sending
|
||||
sendFiles = (...directoryPaths: string[][]): void => {
|
||||
sendFiles = (
|
||||
directoryPaths: BuiltinIterator<string[]>,
|
||||
callback: (path: string) => void
|
||||
): void => {
|
||||
for (const directoryPath of directoryPaths) {
|
||||
this.storageModel.recurse(directoryPath, (filePath: string[]) => {
|
||||
this.sendFile(filePath);
|
||||
const pathString: string = StorageModel.pathComponentsToString(
|
||||
...filePath
|
||||
);
|
||||
callback(pathString);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -3,5 +3,5 @@ import * as React from "bloatless-react";
|
||||
export const StringToTextSpan: React.StateItemConverter<string> = (
|
||||
string: string
|
||||
) => {
|
||||
return <span>{string}</span>
|
||||
return <span class="ellipsis">{string}</span>
|
||||
};
|
||||
|
||||
@@ -6,6 +6,7 @@ import FileTransferViewModel, {
|
||||
} from "../../ViewModel/Global/fileTransferViewModel";
|
||||
|
||||
import StorageModel from "../../Model/Global/storageModel";
|
||||
import { StringToTextSpan } from "../Components/textSpan";
|
||||
import { translations } from "../translations";
|
||||
|
||||
export function DataTransferModalWrapper(
|
||||
@@ -16,6 +17,7 @@ export function DataTransferModalWrapper(
|
||||
{DirectionSelectionModal(fileTransferViewModel)}
|
||||
{FileSelectionModal(fileTransferViewModel)}
|
||||
{TransferDataDisplayModal(fileTransferViewModel)}
|
||||
{TransferDisplayModal(fileTransferViewModel)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -176,6 +178,12 @@ function TransferDataDisplayModal(
|
||||
<main>
|
||||
<h2>{translations.dataTransferModal.transferDataHeadline}</h2>
|
||||
|
||||
<span class="secondary">
|
||||
{translations.dataTransferModal.dataEntryDescription}
|
||||
</span>
|
||||
|
||||
<hr></hr>
|
||||
|
||||
<div class="flex-column gap content-margin-bottom">
|
||||
<div class="tile">
|
||||
<span class="icon">forum</span>
|
||||
@@ -206,8 +214,11 @@ function TransferDataDisplayModal(
|
||||
>
|
||||
{translations.general.backButton}
|
||||
</button>
|
||||
<button class="primary flex">
|
||||
{translations.general.continueButton}
|
||||
<button
|
||||
class="primary flex"
|
||||
on:click={fileTransferViewModel.initiateTransfer}
|
||||
>
|
||||
{translations.dataTransferModal.sendButton}
|
||||
<span class="icon">arrow_forward</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -215,3 +226,44 @@ function TransferDataDisplayModal(
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function TransferDisplayModal(fileTransferViewModel: FileTransferViewModel) {
|
||||
const isPresented = React.createProxyState(
|
||||
[fileTransferViewModel.presentedModal],
|
||||
() =>
|
||||
fileTransferViewModel.presentedModal.value ==
|
||||
FileTransferModal.TransferDisplay
|
||||
);
|
||||
|
||||
return (
|
||||
<div class="modal" toggle:open={isPresented}>
|
||||
<div>
|
||||
<main>
|
||||
<h2>{translations.dataTransferModal.transferDataHeadline}</h2>
|
||||
|
||||
<p>{translations.dataTransferModal.sendingFiles}</p>
|
||||
|
||||
<p
|
||||
class="secondary"
|
||||
subscribe:innerText={fileTransferViewModel.filesSentText}
|
||||
></p>
|
||||
|
||||
<div
|
||||
class="tile flex-column align-start"
|
||||
children:append={[
|
||||
fileTransferViewModel.filePathsSent,
|
||||
StringToTextSpan,
|
||||
]}
|
||||
></div>
|
||||
</main>
|
||||
<button
|
||||
on:click={fileTransferViewModel.hideModal}
|
||||
toggle:disabled={fileTransferViewModel.didNotFinishSending}
|
||||
>
|
||||
{translations.general.closeButton}
|
||||
<span class="icon">close</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -82,6 +82,7 @@ const englishTranslations = {
|
||||
dataTransferModal: {
|
||||
transferDataHeadline: "Transfer Data",
|
||||
selectionDescription: "Select the data that you want to transfer.",
|
||||
dataEntryDescription: "Enter this data on the other device.",
|
||||
|
||||
///
|
||||
|
||||
@@ -94,15 +95,20 @@ const englishTranslations = {
|
||||
|
||||
connectionData: "Connection Data",
|
||||
settingsData: "Settings Data",
|
||||
|
||||
///
|
||||
|
||||
|
||||
chatsHeadline: "Chats",
|
||||
|
||||
///
|
||||
|
||||
transferChannelHeadline: "Transfer Chanel",
|
||||
transferKeyHeadline: "Transfer Encryption Key",
|
||||
|
||||
sendButton: "Send",
|
||||
|
||||
///
|
||||
|
||||
sendingFiles: "Sending files...",
|
||||
filesSentCount: (count: number) => `Files sent: ${count}`
|
||||
},
|
||||
|
||||
storage: {
|
||||
|
||||
@@ -27,6 +27,15 @@ export default class FileTransferViewModel {
|
||||
transferChannel: React.State<string> = new React.State("");
|
||||
transferKey: React.State<string> = new React.State("");
|
||||
|
||||
filesSentCount: React.State<number> = new React.State(0);
|
||||
filePathsSent: React.ListState<string> = new React.ListState();
|
||||
didNotFinishSending: React.State<boolean> = new React.State(true);
|
||||
filesSentText: React.State<string> = React.createProxyState(
|
||||
[this.filesSentCount],
|
||||
() =>
|
||||
translations.dataTransferModal.filesSentCount(this.filesSentCount.value)
|
||||
);
|
||||
|
||||
// guards
|
||||
hasNoPathsSelected: React.State<boolean> = React.createProxyState(
|
||||
[this.selectedPaths],
|
||||
@@ -80,6 +89,24 @@ export default class FileTransferViewModel {
|
||||
this.getTransferData();
|
||||
};
|
||||
|
||||
initiateTransfer = (): void => {
|
||||
this.presentedModal.value = FileTransferModal.TransferDisplay;
|
||||
this.didNotFinishSending.value = true;
|
||||
this.filesSentCount.value = 0;
|
||||
this.filePathsSent.clear();
|
||||
|
||||
this.fileTransferModel.sendFiles(
|
||||
this.selectedPaths.value.values(),
|
||||
(path: string) => {
|
||||
console.log(path);
|
||||
this.filePathsSent.add(path);
|
||||
this.filesSentCount.value++;
|
||||
}
|
||||
);
|
||||
|
||||
this.didNotFinishSending.value = false;
|
||||
};
|
||||
|
||||
hideModal = (): void => {
|
||||
this.presentedModal.value = undefined;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user