Skip to content

Commit

Permalink
Rename method and attributes to make their usage clearer
Browse files Browse the repository at this point in the history
  • Loading branch information
anttimaki committed Dec 20, 2024
1 parent 9b6e8a8 commit 2e99b41
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default class App extends mixins(UtilityMixin) {
// Load settings using the default game before the actual game is selected.
const settings: ManagerSettings = await this.$store.dispatch('resetActiveGame');
this.hookThunderstoreModListRefresh();
this.hookBackgroundUpdateThunderstoreModList();
await this.checkCdnConnection();
InstallationRuleApplicator.apply();
Expand Down
16 changes: 9 additions & 7 deletions src/components/mixins/UtilityMixin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import { PackageListIndex } from '../../store/modules/TsModsModule';
@Component
export default class UtilityMixin extends Vue {
readonly REFRESH_INTERVAL = 5 * 60 * 1000;
private tsRefreshFailed = false;
private tsBackgroundRefreshFailed = false;
hookThunderstoreModListRefresh() {
setInterval(this.tryRefreshThunderstoreModList, this.REFRESH_INTERVAL);
hookBackgroundUpdateThunderstoreModList() {
setInterval(this.backgroundRefreshThunderstoreModList, this.REFRESH_INTERVAL);
}
// Wrapper to allow TSMM to inject telemetry gathering.
Expand Down Expand Up @@ -42,12 +42,14 @@ export default class UtilityMixin extends Vue {
}
/**
* Periodically refresh the Thunderstore mod list in the background.
*
* Thunderstore's Sentry gets regular errors about this failing with
* HTTP status code 0. The assumption is that it's caused by users
* closing the window while update is in progress. Ignore the first
* failure to see how this affects the number of reported errors.
*/
private async tryRefreshThunderstoreModList() {
private async backgroundRefreshThunderstoreModList() {
// Don't do background update on index route since the game
// isn't really chosen yet, nor in the splash screen since it
// proactively updates the package list.
Expand All @@ -65,18 +67,18 @@ export default class UtilityMixin extends Vue {
this.$store.commit("tsMods/startBackgroundUpdate");
await this.refreshThunderstoreModList();
} catch (e) {
if (this.tsRefreshFailed) {
if (this.tsBackgroundRefreshFailed) {
console.error("Two consecutive background refresh attempts failed");
throw e;
}
this.tsRefreshFailed = true;
this.tsBackgroundRefreshFailed = true;
return;
} finally {
this.$store.commit("tsMods/finishBackgroundUpdate");
}
this.tsRefreshFailed = false;
this.tsBackgroundRefreshFailed = false;
}
/**
Expand Down

0 comments on commit 2e99b41

Please sign in to comment.