Skip to content

Commit

Permalink
feat: get latest Nintendont version dynamically
Browse files Browse the repository at this point in the history
  • Loading branch information
NikhilNarayana committed Sep 1, 2021
1 parent 256494f commit 42ddf28
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/common/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ export const ipc_checkForUpdate = makeEndpoint.main("checkForUpdate", <EmptyPayl

export const ipc_installUpdate = makeEndpoint.main("installUpdate", <EmptyPayload>_, <SuccessPayload>_);

export const ipc_getLatestGitHubReleaseVersion = makeEndpoint.main(
"getLatestGitHubReleaseVersion",
<{ owner: string; repo: string }>_,
<{ version: string }>_,
);

// Events

export const ipc_launcherUpdateFoundEvent = makeEndpoint.renderer("launcherupdate_found", <{ version: string }>_);
Expand Down
9 changes: 9 additions & 0 deletions src/main/listeners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
ipc_copyLogsToClipboard,
ipc_deleteDesktopAppPath,
ipc_fetchNewsFeed,
ipc_getLatestGitHubReleaseVersion,
ipc_installUpdate,
ipc_launcherUpdateDownloadingEvent,
ipc_launcherUpdateFoundEvent,
Expand All @@ -27,6 +28,7 @@ import osName from "os-name";
import path from "path";

import { fileExists } from "./fileExists";
import { getLatestRelease } from "./github";
import { fetchNewsFeedData } from "./newsFeed";
import { readLastLines } from "./util";
import { verifyIso } from "./verifyIso";
Expand Down Expand Up @@ -138,4 +140,11 @@ export function setupListeners() {
autoUpdater.checkForUpdatesAndNotify().catch(log.warn);
return { success: true };
});

ipc_getLatestGitHubReleaseVersion.main!.handle(async ({ owner, repo }) => {
const release = await getLatestRelease(owner, repo);
const tag: string = release.tag_name;
const version = tag.slice(1);
return { version };
});
}
4 changes: 3 additions & 1 deletion src/renderer/containers/Console/SavedConnectionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface SavedConnectionItemProps {
nickname?: string;
currentFilename: string | null;
nintendontVersion: string | null;
latestVersion: string;
connection: StoredConnection;
onOpenMenu: (index: number, element: HTMLElement) => void;
}
Expand All @@ -44,6 +45,7 @@ export const SavedConnectionItem: React.FC<SavedConnectionItemProps> = ({
isAvailable,
currentFilename,
nintendontVersion,
latestVersion,
}) => {
const { addToast } = useToasts();
const onConnect = () => connectToConsole(connection);
Expand All @@ -58,7 +60,7 @@ export const SavedConnectionItem: React.FC<SavedConnectionItemProps> = ({
const statusName = status === ConnectionStatus.DISCONNECTED && isAvailable ? "Available" : renderStatusName(status);
const isConnected = status !== ConnectionStatus.DISCONNECTED;
const title = nickname ? `${connection.ipAddress} (${nickname})` : connection.ipAddress;
const nintendontIsOutdated = nintendontVersion !== null && lt(nintendontVersion, "1.9.1");
const nintendontIsOutdated = nintendontVersion !== null && lt(nintendontVersion, latestVersion);
return (
<Outer>
<CardHeader
Expand Down
7 changes: 7 additions & 0 deletions src/renderer/containers/Console/SavedConnectionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import DeleteIcon from "@material-ui/icons/Delete";
import HelpOutlineIcon from "@material-ui/icons/HelpOutline";
import { StoredConnection } from "@settings/types";
import { ConnectionStatus } from "@slippi/slippi-js";
import { ipc_getLatestGitHubReleaseVersion } from "common/ipc";
import React from "react";

import { IconMenu } from "@/components/IconMenu";
Expand Down Expand Up @@ -54,6 +55,11 @@ export const SavedConnectionsList: React.FC<SavedConnectionsListProps> = ({ avai
handleClose();
};

const { value: versionData } = ipc_getLatestGitHubReleaseVersion.renderer!.useValue(
{ owner: "project-slippi", repo: "Nintendont" },
{ version: "1.8.0" },
);

return (
<Outer>
{savedConnections.length === 0 ? (
Expand All @@ -73,6 +79,7 @@ export const SavedConnectionsList: React.FC<SavedConnectionsListProps> = ({ avai
isAvailable={Boolean(consoleInfo)}
currentFilename={consoleStatus?.filename ?? null}
nintendontVersion={consoleStatus?.nintendontVersion ?? null}
latestVersion={versionData.version}
nickname={consoleStatus?.nickname ?? consoleInfo?.name}
connection={conn}
index={index}
Expand Down

0 comments on commit 42ddf28

Please sign in to comment.