Skip to content

Commit

Permalink
Prevent manual and automatic mod list updates running simultaneously
Browse files Browse the repository at this point in the history
Users can trigger updating the online mod list from the settings view.
Use the status text to show if an update is already in progress and
prevent user actions from triggering another one, since they would just
compete for the same bandwidth and slow down the manager.
  • Loading branch information
anttimaki committed Apr 26, 2024
1 parent 75a5bbc commit 13a9873
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/components/settings-components/SettingsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ import UtilityMixin from '../mixins/UtilityMixin.vue';
private search: string = '';
private managerVersionNumber: VersionNumber = ManagerInformation.VERSION;
private searchableSettings: SettingsRow[] = [];
private downloadingThunderstoreModList: boolean = false;
get activeGame(): Game {
return this.$store.state.activeGame;
Expand Down Expand Up @@ -299,7 +298,7 @@ import UtilityMixin from '../mixins/UtilityMixin.vue';
'Refresh online mod list',
'Check for any new mod releases.',
async () => {
if (this.downloadingThunderstoreModList) {
if (this.$store.state.tsMods.isBackgroundUpdateInProgress) {
return "Checking for new releases";
}
if (this.$store.state.tsMods.connectionError.length > 0) {
Expand All @@ -312,17 +311,19 @@ import UtilityMixin from '../mixins/UtilityMixin.vue';
},
'fa-exchange-alt',
async () => {
if (!this.downloadingThunderstoreModList) {
this.downloadingThunderstoreModList = true;
this.$store.commit("tsMods/setConnectionError", "");
if (this.$store.state.tsMods.isBackgroundUpdateInProgress) {
return;
}
try {
await this.refreshThunderstoreModList();
} catch (e) {
this.$store.commit("tsMods/setConnectionError", e);
} finally {
this.downloadingThunderstoreModList = false;
}
this.$store.commit("tsMods/startBackgroundUpdate");
this.$store.commit("tsMods/setConnectionError", "");
try {
await this.refreshThunderstoreModList();
} catch (e) {
this.$store.commit("tsMods/setConnectionError", e);
} finally {
this.$store.commit("tsMods/finishBackgroundUpdate");
}
}
),
Expand Down

0 comments on commit 13a9873

Please sign in to comment.