Skip to content

Commit

Permalink
Merge pull request #988 from Dygmalab/fixVersionDataModal
Browse files Browse the repository at this point in the history
fix: now versions are properly showed when updating, only the relevan…
  • Loading branch information
alexpargon authored Jan 30, 2025
2 parents 99f7486 + 4d7b7da commit eed3c67
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Bazecor",
"productName": "Bazecor",
"version": "1.6.2",
"version": "1.6.3",
"description": "Bazecor desktop app",
"private": true,
"repository": {
Expand Down
3 changes: 1 addition & 2 deletions src/renderer/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ function App() {
const [fwUpdate, setFwUpdate] = useState(false);
const [loading, setLoading] = useState(false);
const [notifyNewVersion, setNotifyNewVersion] = useState(false);
const [oldSettings] = useState(store.get("settings"));

const saveButtonRef = useRef(null);
const discardChangesButtonRef = useRef(null);
Expand All @@ -78,7 +79,6 @@ function App() {
const navigate = useNavigate();
const varFlashing = React.useRef(false);
const device: any = React.useRef();
const oldSettings = store.get("settings");

const updateStorageSchema = async () => {
// Update stored settings schema
Expand Down Expand Up @@ -521,7 +521,6 @@ function App() {
<VersionUpdateDialog
open={notifyNewVersion}
oldVersion={oldSettings.version}
newVersion={version}
handleUpdate={handleUpdateVersion}
onCancel={() => setNotifyNewVersion(false)}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import React, { useEffect, useState } from "react";
import { Octokit } from "@octokit/core";
// import log from "electron-log/renderer";
import log from "electron-log/renderer";
import SemVer from "semver";
import parse, { domToReact } from "html-react-parser";

Expand All @@ -26,12 +26,12 @@ import { i18n } from "@Renderer/i18n";
import Heading from "@Renderer/components/atoms/Heading";
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "@Renderer/components/atoms/Accordion";
import LogoLoader from "@Renderer/components/atoms/loader/LogoLoader";
import { version } from "../../../../../package.json";

interface VersionUpdateProps {
open: boolean;
onCancel: () => void;
oldVersion: string;
newVersion: string;
handleUpdate: () => void;
}

Expand Down Expand Up @@ -94,7 +94,7 @@ const options = {
};

export function VersionUpdateDialog(props: VersionUpdateProps) {
const { open, onCancel, newVersion, oldVersion, handleUpdate } = props;
const { open, onCancel, oldVersion, handleUpdate } = props;
const [data, setData] = useState<Releases[]>(undefined);

useEffect(() => {
Expand All @@ -111,17 +111,19 @@ export function VersionUpdateDialog(props: VersionUpdateProps) {
format: "full",
},
});
// log.info("Testing", GHdata);
log.info("Testing", GHdata);
GHdata.data.forEach(release => {
// eslint-disable-next-line @typescript-eslint/naming-convention
const { prerelease, name, published_at, body_html, tag_name } = release;
const newRelease = { name, version: tag_name, date: published_at, content: body_html };
if (!prerelease) releases.push(newRelease);
});
// log.info("Data from Dialog: ", releases, newVersion, oldVersion);
const versionToCheck = oldVersion || newVersion;
const parsedData = releases.filter(r => SemVer.compare(r.version, versionToCheck) >= 0);
// log.info("Data from Dialog: ", parsedData);
log.info("Data from Dialog: ", releases, version, oldVersion);
const parsedData = releases.filter(r =>
oldVersion
? SemVer.compare(r.version, oldVersion) > 0 && SemVer.compare(r.version, version) <= 0
: SemVer.compare(r.version, version) === 0,
);
setData(parsedData);
}
fetchData();
Expand Down
1 change: 0 additions & 1 deletion src/renderer/modules/Settings/GeneralSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ const GeneralSettings = ({
<VersionUpdateDialog
open={versionDialog}
oldVersion={version}
newVersion={version}
handleUpdate={() => {}}
onCancel={() => setVersionDialog(false)}
/>
Expand Down

0 comments on commit eed3c67

Please sign in to comment.