Skip to content
This repository has been archived by the owner on Apr 5, 2022. It is now read-only.

Commit

Permalink
Merge pull request #91 from BlueBubblesApp/maxwell/dev
Browse files Browse the repository at this point in the history
Fixed bug with update
  • Loading branch information
maxwellfortney authored Nov 22, 2020
2 parents 28fd07a + 9dfe1ea commit a167a83
Showing 1 changed file with 11 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { ipcRenderer } from "electron";
import * as React from "react";
import "./Updates.css";

const semver = require("semver");

interface UpdatesProps {
title: string;
}
Expand Down Expand Up @@ -37,61 +39,33 @@ class Updates extends React.Component<UpdatesProps, State> {

console.log(data);
if (data) {
this.setState({ checkingForUpdates: false, hasUpdates: true, updateData: data });
if (semver.gt(data.updateInfo.version, window.require("electron").remote.app.getVersion())) {
this.setState({ checkingForUpdates: false, hasUpdates: true, updateData: data });
} else {
this.setState({ checkingForUpdates: false, hasUpdates: false, updateData: data });
}
}
// this.setState({hasUpdates: data.hasUpdates, checkingForUpdates: false})
});

ipcRenderer.on("update-download-progress", (_, progressObj) => {
console.log(progressObj);
this.setState({ progressObj, isDownloadingUpdate: true });
});

ipcRenderer.on("update-err", (_, err) => {
console.log(err);

this.setState({ hasUpdates: false, isDownloadingUpdate: false, checkingForUpdates: false });
});

ipcRenderer.on("update-available", (_, info) => {
console.log(info);
this.setState({ hasUpdates: true, isDownloadingUpdate: false, checkingForUpdates: false });
});

ipcRenderer.on("update-not-available", (_, info) => {
this.setState({ hasUpdates: false, isDownloadingUpdate: false, checkingForUpdates: false });
});

ipcRenderer.on("update-downloaded", (_, info) => {
console.log(info);
this.setState({ isDownloadingUpdate: false, downloadFinished: true });
});

// autoUpdater.on("checking-for-update", () => {
// this.setState({checkingForUpdates: true, hasUpdates: true})
// });

// autoUpdater.on("error", err => {
// this.setState({checkingForUpdates: false, hasUpdates: false, hasError: true})
// });

// autoUpdater.on("update-available", info => {
// this.setState({checkingForUpdates: false, hasUpdates: true})
// console.info(info);
// });

// autoUpdater.on("update-not-available", info => {
// this.setState({checkingForUpdates: false, hasUpdates: false})
// console.info(info);
// });

// autoUpdater.on("update-downloaded", info => {
// console.info(info);
// });

// autoUpdater.on('download-progress', (progressObj) => {
// // let log_message = `Download speed: ${ progressObj.bytesPerSecond}`;
// // log_message = log_message + ' - Downloaded ' + progressObj.percent + '%';
// // log_message = log_message + ' (' + progressObj.transferred + "/" + progressObj.total + ')';
// // sendStatusToWindow(log_message);
// console.log(progressObj)
// })
}

async downloadUpdate() {
Expand All @@ -103,9 +77,6 @@ class Updates extends React.Component<UpdatesProps, State> {
}

render() {
console.log("PROG");
console.log(this.state.progressObj);

return (
<div className="ServerSettingTitle">
<h2>{this.props.title}</h2>
Expand Down

0 comments on commit a167a83

Please sign in to comment.