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

Improve Splash screen download indicators #1176

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/components/mixins/SplashMixin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default class SplashMixin extends Vue {
};

ThunderstorePackages.EXCLUSIONS = await ConnectionProvider.instance.getExclusions(showProgress);
this.getRequestItem('ExclusionsList').setProgress(100);
}

// Get the list of Thunderstore mods from API.
Expand All @@ -62,6 +63,8 @@ export default class SplashMixin extends Vue {
this.isOffline = true;
this.heroTitle = 'Failed to get mods from Thunderstore';
this.loadingText = 'You may be offline or Thunderstore is unavailabe. Checking cache.';
} finally {
this.getRequestItem('ThunderstoreDownload').setProgress(100);
}

if (response) {
Expand Down
3 changes: 3 additions & 0 deletions src/pages/Splash.vue
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ export default class Splash extends mixins(SplashMixin) {
}

retryConnection() {
this.getRequestItem('UpdateCheck').setProgress(0);
this.getRequestItem('ExclusionsList').setProgress(0);
this.getRequestItem('ThunderstoreDownload').setProgress(0);
this.isOffline = false;
this.checkForUpdates();
}
Expand Down
13 changes: 4 additions & 9 deletions src/utils/HttpUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ export const getAxiosWithTimeouts = (responseTimeout = 5000, totalTimeout = 1000
};

interface LongRunningRequestOptions {
/**
* Custom function to be called when progress is made. Doesn't work
* properly currently, since the progress percentage can't be
* calculated because the total length of the content isn't known.
*/
/** Custom function to be called when progress is made. */
downloadProgressed?: DownloadProgressed;
/**
* Time (in ms) the request has to trigger the first download
Expand Down Expand Up @@ -84,10 +80,9 @@ export const makeLongRunningGetRequest = async (
rollingTimeout = setTimeout(abort, transmissionTimeout);

if (typeof downloadProgressed === "function") {
// TODO: Progress percentage can't be calculated since the
// content length is unknown. Looks like this hasn't worked
// in a while.
downloadProgressed(0);
// Backend might not provided total content length.
const percent = progress.total ? (progress.loaded / progress.total) * 100 : 0;
downloadProgressed(percent);
}
}

Expand Down