Skip to content

Commit

Permalink
Fix various incompatibilities.
Browse files Browse the repository at this point in the history
  • Loading branch information
HalfVoxel committed Mar 19, 2022
1 parent dcc8f8b commit d1ee708
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
4 changes: 1 addition & 3 deletions src/all.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import './style.scss';
import { JSON, JsonObject, JsonProperty } from "ta-json";
import { render, Component } from 'inferno';
import { PreviewSign } from './view_preview';
import { Sign, PaperSize } from './data';
Expand Down Expand Up @@ -36,8 +35,7 @@ interface SignWithID {
sign: Sign;
id: number;
}
export class App extends Component {
state : { signs: SignWithID[], visible_signs: SignWithID[]};
export class App extends Component<{}, { signs: SignWithID[], visible_signs: SignWithID[]}>{

constructor(props: any) {
super(props);
Expand Down
6 changes: 3 additions & 3 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import './style.scss';
import { JSON, JsonObject, JsonProperty } from "ta-json";
import { JSON } from "ta-json";
import { render, Component } from 'inferno';
import { PreviewSign } from './view_preview';
import { Sign } from './data';
Expand Down Expand Up @@ -34,7 +34,7 @@ function SignItem({ item, onOpen }: any) {
)
}

class SignSelector extends Component {
class SignSelector extends Component<any, {signs: Sign[] }> {
constructor(props: any) {
super(props);
this.state = { signs: [] }
Expand Down Expand Up @@ -94,7 +94,7 @@ class SignSelectorSmall extends SignSelector {
// How often to save (at most). In milliseconds
const SavingInterval = 2000;

export class App extends Component {
export class App extends Component<any, { sign: Sign | null, id: number | null }> {
saving: boolean;
debouncedSave = debounce(() => this.save(), SavingInterval);

Expand Down
15 changes: 10 additions & 5 deletions src/view_preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ accessMessage[Access.CourseRequired] = "You must complete a course to use this m
accessMessage[Access.UsableByEveryone] = "All members may use this machine";
accessMessage[Access.UsableByEveryoneCareful] = "You may use this machine if you know how to operate it and can do so safely";

class CourseQRCode extends Component {
class CourseQRCode extends Component<{ sign: Sign }, { qrData: string }> {
state: any;
lastQRUrl: string = null;

Expand Down Expand Up @@ -136,7 +136,9 @@ class CourseQRCode extends Component {
}
}

QRCode.toDataURL(url, opts).then(data => {
QRCode.toDataURL(url, opts, (e, data) => {
// Hack: required when called from constructor
this.state.qrData = data;
this.setState({ qrData: data });
});
}
Expand Down Expand Up @@ -191,8 +193,7 @@ const SignOutOfOrder = ({sign}: {sign: Sign}) => {
);
}

class PreviewSignFooter extends Component {
state: any;
class PreviewSignFooter extends Component<{ sign: Sign, id: number }, { qrData: string }> {
lastQRUrl: string = null;

constructor(props: any) {
Expand Down Expand Up @@ -220,13 +221,17 @@ class PreviewSignFooter extends Component {
}
}

QRCode.toDataURL(url, opts).then(data => {
console.log("URL ", url);
QRCode.toDataURL(url, opts, (e, data) => {
// Hack: required when called from constructor
this.state.qrData = data;
this.setState({ qrData: data });
});
}
}

render() {
console.log("Q", this.state.qrData);
return (
<Fragment>
<div class="sign-footer">
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"target": "es5",
"jsx": "preserve",
"allowJs": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"types": [
"inferno"
Expand Down

0 comments on commit d1ee708

Please sign in to comment.