Improve zmodem state transitions

Fixes #46, I think
This commit is contained in:
Søren L. Hansen 2022-09-01 17:16:17 -07:00
parent 26c419f564
commit d0982d6538
4 changed files with 17 additions and 5 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -18,7 +18,10 @@ export class MyModal extends Component<ModalProps, {}> {
componentDidMount() {
Modal.getOrCreateInstance(this.ref.current!).show();
this.ref.current?.addEventListener('hide.bs.modal', () => { this.props.dismissHandler && this.props.dismissHandler(); });
this.ref.current?.addEventListener('hide.bs.modal', () => {
this.props.dismissHandler && this.props.dismissHandler();
});
}
componentWillUnmount() {

View File

@ -106,6 +106,8 @@ interface ReceiveFileModalState {
}
export class ReceiveFileModal extends Component<ReceiveFileModalProps, ReceiveFileModalState> {
skipped: boolean;
constructor(props) {
super(props)
this.setState({ state: "notstarted" })
@ -136,7 +138,6 @@ export class ReceiveFileModal extends Component<ReceiveFileModalProps, ReceiveFi
}
finish() {
console.log('finished');
if (this.props.onFinish) this.props.onFinish();
}
@ -147,6 +148,11 @@ export class ReceiveFileModal extends Component<ReceiveFileModalProps, ReceiveFi
}
skip() {
if (this.skipped) {
return
}
this.skipped = true;
this.props.xfer.skip()
this.setState({ state: "skipped" })
}
@ -172,6 +178,7 @@ export class ReceiveFileModal extends Component<ReceiveFileModalProps, ReceiveFi
render() {
if (this.state.state != "done")
return <MyModal title="Incoming file"
dismissHandler={() => this.skip()}
buttons={this.buttons()}>
Accept <code>{this.props.xfer.get_details().name}</code> ({this.props.xfer.get_details().size.toLocaleString(undefined, { maximumFractionDigits: 0 })} bytes)?
{this.progress()}
@ -223,7 +230,9 @@ export class SendFileModal extends Component<SendFileModalProps, SendFileModalSt
render() {
if (this.state.state != "done")
return <MyModal title="Send file(s)"
buttons={this.buttons()}>
buttons={this.buttons()}
dismissHandler={() => this.props.session.close()}
>
<div class="mb-3">
<label for="formFileMultiple" class="form-label">
Remote requested file transfer