Skip to content

Commit

Permalink
Improve zmodem state transitions
Browse files Browse the repository at this point in the history
Fixes #46, I think
  • Loading branch information
sorenisanerd committed Sep 2, 2022
1 parent 26c419f commit d0982d6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bindata/static/js/gotty.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bindata/static/js/gotty.js.map

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion js/src/MyModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
13 changes: 11 additions & 2 deletions js/src/zmodem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ interface ReceiveFileModalState {
}

export class ReceiveFileModal extends Component<ReceiveFileModalProps, ReceiveFileModalState> {
skipped: boolean;

constructor(props) {
super(props)
this.setState({ state: "notstarted" })
Expand Down Expand Up @@ -136,7 +138,6 @@ export class ReceiveFileModal extends Component<ReceiveFileModalProps, ReceiveFi
}

finish() {
console.log('finished');
if (this.props.onFinish) this.props.onFinish();
}

Expand All @@ -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" })
}
Expand All @@ -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()}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d0982d6

Please sign in to comment.