Fix bug with error when decoding

This commit is contained in:
Fabian Stamm 2020-07-10 18:54:32 +02:00
parent db5a363bff
commit 3c80ac3125
2 changed files with 718 additions and 651 deletions

View File

@ -4,69 +4,76 @@ import Refresh from "feather-icons/dist/icons/refresh-cw.svg";
import "./footer.scss"; import "./footer.scss";
import Notifications from "../notifications"; import Notifications from "../notifications";
export class Footer extends Component<{}, { synced: boolean, syncing: boolean }> { export class Footer extends Component<
constructor(props) { {},
super(props); { synced: boolean; syncing: boolean }
this.state = { synced: false, syncing: false }; > {
this.onSyncedChange = this.onSyncedChange.bind(this); constructor(props) {
this.onSyncChange = this.onSyncChange.bind(this); super(props);
} this.state = { synced: false, syncing: false };
this.onSyncedChange = this.onSyncedChange.bind(this);
this.onSyncChange = this.onSyncChange.bind(this);
}
async componentWillMount() { async componentWillMount() {
Notes.syncedObservable.subscribe(this.onSyncedChange); Notes.syncedObservable.subscribe(this.onSyncedChange);
Notes.syncObservable.subscribe(this.onSyncChange); Notes.syncObservable.subscribe(this.onSyncChange);
this.setState({ synced: await Notes.isSynced() }) this.setState({ synced: await Notes.isSynced() });
} }
componentWillUnmount() { componentWillUnmount() {
Notes.syncedObservable.unsubscribe(this.onSyncedChange); Notes.syncedObservable.unsubscribe(this.onSyncedChange);
Notes.syncObservable.unsubscribe(this.onSyncChange); Notes.syncObservable.unsubscribe(this.onSyncChange);
} }
onSyncChange(state: boolean) { onSyncChange(state: boolean) {
console.log("sync", state); console.log("sync", state);
this.setState({ syncing: state }) this.setState({ syncing: state });
} }
onSyncedChange(state: boolean) { onSyncedChange(state: boolean) {
console.log("synced", state); console.log("synced", state);
this.setState({ synced: state }) this.setState({ synced: state });
} }
onSyncClick() { onSyncClick() {
Notes.sync().then(() => { Notes.sync().then(() => {
Notifications.sendInfo("Finished Synchronisation"); Notifications.sendInfo("Finished Synchronisation");
}) });
} }
render() { render() {
let extrac = undefined; let extrac = undefined;
let color; let color;
let text; let text;
if (this.state.syncing) { if (this.state.syncing) {
color = "orange"; color = "orange";
text = "syncing"; text = "syncing";
extrac = "reloading" extrac = "reloading";
} else { } else {
if (this.state.synced) { if (this.state.synced) {
color = "green"; color = "green";
text = "synced"; text = "synced";
} else { } else {
color = "red"; color = "red";
text = "not synced"; text = "not synced";
} }
} }
return <footer class="elv-8"> return (
<footer class="elv-8">
<span> <span>
<span class={extrac} ><a onClick={() => this.onSyncClick()} ><Refresh style="height: 1em; width: 1em;"></Refresh></a></span> <span class={extrac}>
<span style={"margin-left: 8px; color:" + color}>{text}</span> <a onClick={() => this.onSyncClick()}>
<Refresh style="height: 1em; width: 1em;"></Refresh>
</a>
</span>
<span style={"margin-left: 8px; color:" + color}>{text}</span>
</span> </span>
<span> <span>
Welcome <b>{Notes.name}</b> Welcome <b>{Notes.name}</b>
</span> </span>
<span style="color: lightgrey;"> <span style="color: lightgrey;">v1.5</span>
v1.4 </footer>
</span> );
</footer> }
} }
}

File diff suppressed because it is too large Load Diff