Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: leverage slippi backend's getLatestDolphin query #271

Merged
merged 4 commits into from
Jan 31, 2022

Conversation

NikhilNarayana
Copy link
Member

Swaps our current implementation of querying github in favor of the getLatestDolphin query on our backend.

The refactor of downloadDolphin.ts does reorder a bit of the code so the diff is a bit greater there.

const appVersion = __VERSION__;

const client = new ApolloClient({
link: httpLink,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to provide a link here instead of just providing the uri directly? Does it not work if we don't provide it an instance to cross-fetch?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, we get this explicit error from ApolloClient

Invariant Violation:
  "fetch" has not been found globally and no fetcher has been configured. To fix this, install a fetch package (like https://www.npmjs.com/package/cross-fetch), instantiate the fetcher, and pass it into your HttpLink constructor. For example:

  import fetch from 'cross-fetch';
  import { ApolloClient, HttpLink } from '@apollo/client';
  const client = new ApolloClient({
    link: new HttpLink({ uri: '/graphql', fetch })
  });

Comment on lines +24 to +25
await assertDolphinInstallation(DolphinLaunchType.NETPLAY, logDownloadInfo);
await assertDolphinInstallation(DolphinLaunchType.PLAYBACK, logDownloadInfo);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we could use Promise.all so we could potentially avoid a waterfall. However, since we're sending the log to logDownloadInfo we might not be able to do that, since it would intersperse the log messages. Something we could keep in mind for the future though.

src/dolphin/downloadDolphin.ts Outdated Show resolved Hide resolved
@@ -27,106 +39,63 @@ export async function assertDolphinInstallation(
await findDolphinExecutable(type);
log(`Found existing ${type} Dolphin executable.`);
log(`Checking if we need to update ${type} Dolphin`);
const data = await getLatestReleaseData(type);
const latestVersion = data.tag_name;
const data = await fetchLatestDolphin(type);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const data = await fetchLatestDolphin(type);
const dolphinDownloadInfo = await fetchLatestDolphin(type);

Can we use a better variable name than data here?

}

async function downloadLatestDolphin(
type: DolphinLaunchType,
releaseInfo: DolphinVersionResponse,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
releaseInfo: DolphinVersionResponse,
downloadUrl: string,

Can we pass the URL in directly here?

Comment on lines +93 to +94
await download(win, downloadUrl, {
filename: filename,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a comment, but I think it would be good if we could eventually not depend on the existence of a browser window to download a file since electron-dl seems to require a Browser window. I feel like there are a few cases where the app is running without a window (e.g. MacOS) or in the task bar/system tray (perhaps in the future).

Copy link
Member

@vinceau vinceau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@NikhilNarayana NikhilNarayana merged commit 08ef93f into main Jan 31, 2022
@vinceau vinceau deleted the feat/dolphin-download-endpoint branch February 27, 2022 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants