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() { componentDidMount() {
Modal.getOrCreateInstance(this.ref.current!).show(); 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() { componentWillUnmount() {

View File

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