diff --git a/src/components/settings-components/SettingsView.vue b/src/components/settings-components/SettingsView.vue index d793d501..afa8829f 100644 --- a/src/components/settings-components/SettingsView.vue +++ b/src/components/settings-components/SettingsView.vue @@ -295,8 +295,8 @@ import UtilityMixin from '../mixins/UtilityMixin.vue'; if (this.downloadingThunderstoreModList) { return "Checking for new releases"; } - if (this.$store.state.apiConnectionError.length > 0) { - return "Error getting new mods: " + this.$store.state.apiConnectionError; + if (this.$store.state.tsMods.connectionError.length > 0) { + return "Error getting new mods: " + this.$store.state.tsMods.connectionError; } if (this.$store.state.tsMods.modsLastUpdated !== undefined) { return "Cache date: " + moment(this.$store.state.tsMods.modsLastUpdated).format("MMMM Do YYYY, h:mm:ss a"); @@ -307,13 +307,12 @@ import UtilityMixin from '../mixins/UtilityMixin.vue'; async () => { if (!this.downloadingThunderstoreModList) { this.downloadingThunderstoreModList = true; - await this.$store.dispatch("updateApiConnectionError", ""); + this.$store.commit("tsMods/setConnectionError", ""); try { await this.refreshThunderstoreModList(); } catch (e) { - const err = e instanceof Error ? e.message : "Unknown error"; - await this.$store.dispatch("updateApiConnectionError", err); + this.$store.commit("tsMods/setConnectionError", e); } finally { this.downloadingThunderstoreModList = false; } diff --git a/src/components/views/InstalledModView.vue b/src/components/views/InstalledModView.vue index 29131de5..cc7b78c6 100644 --- a/src/components/views/InstalledModView.vue +++ b/src/components/views/InstalledModView.vue @@ -24,7 +24,7 @@ You have {{ numberOfModsWithUpdates }} available mod update{{ numberOfModsWithUpdates > 1 ? "s" : ""}}. Would you like to update all? - + @@ -50,7 +50,7 @@ import LocalModListProvider from "../../providers/components/loaders/LocalModLis export default class InstalledModView extends Vue { get dismissedUpdateAll() { - return this.$store.state.dismissedUpdateAll; + return this.$store.state.profile.dismissedUpdateAll; } get localModList(): ManifestV2[] { diff --git a/src/store/index.ts b/src/store/index.ts index f46eefff..e9b3b66e 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -16,8 +16,6 @@ Vue.use(Vuex); export interface State { activeGame: Game; - apiConnectionError: string; - dismissedUpdateAll: boolean; isMigrationChecked: boolean; _settings: ManagerSettings | null; } @@ -32,20 +30,12 @@ type Context = ActionContext; export const store = { state: { activeGame: GameManager.defaultGame, - dismissedUpdateAll: false, isMigrationChecked: false, - apiConnectionError: "", // Access through getters to ensure the settings are loaded. _settings: null, }, actions: { - dismissUpdateAll({commit}: Context) { - commit('dismissUpdateAll'); - }, - updateApiConnectionError({commit}: Context, err: string) { - commit('setApiConnectionError', err); - }, async checkMigrations({commit, state}: Context) { if (state.isMigrationChecked) { return; @@ -78,15 +68,9 @@ export const store = { setActiveGame(state: State, game: Game) { state.activeGame = game; }, - dismissUpdateAll(state: State) { - state.dismissedUpdateAll = true; - }, setMigrationChecked(state: State) { state.isMigrationChecked = true; }, - setApiConnectionError(state: State, err: string) { - state.apiConnectionError = err; - }, setSettings(state: State, settings: ManagerSettings) { state._settings = settings; } diff --git a/src/store/modules/ProfileModule.ts b/src/store/modules/ProfileModule.ts index ec1d1333..60ce884f 100644 --- a/src/store/modules/ProfileModule.ts +++ b/src/store/modules/ProfileModule.ts @@ -24,6 +24,7 @@ interface State { direction?: SortDirection; disabledPosition?: SortLocalDisabledMods; searchQuery: string; + dismissedUpdateAll: boolean; } /** @@ -41,6 +42,7 @@ export default { direction: undefined, disabledPosition: undefined, searchQuery: '', + dismissedUpdateAll: false, }), getters: >{ @@ -112,6 +114,10 @@ export default { }, mutations: { + dismissUpdateAll(state: State) { + state.dismissedUpdateAll = true; + }, + // Use updateActiveProfile action to ensure the persistent // settings are updated. setActiveProfile(state: State, profileName: string) { diff --git a/src/store/modules/TsModsModule.ts b/src/store/modules/TsModsModule.ts index 307a4b71..7efb728f 100644 --- a/src/store/modules/TsModsModule.ts +++ b/src/store/modules/TsModsModule.ts @@ -15,6 +15,7 @@ interface CachedMod { interface State { cache: Map; + connectionError: string; deprecated: Map; exclusions?: string[]; mods: ThunderstoreMod[]; @@ -32,6 +33,8 @@ export const TsModsModule = { state: (): State => ({ cache: new Map(), + /*** Error shown on UI after manual mod list refresh fails */ + connectionError: '', deprecated: new Map(), /*** Packages available through API that should be ignored by the manager */ exclusions: [], @@ -113,6 +116,14 @@ export const TsModsModule = { clearModCache(state) { state.cache.clear(); }, + setConnectionError(state, error: string|unknown) { + if (typeof error === 'string') { + state.connectionError = error; + } else { + const msg = error instanceof Error ? error.message : "Unknown error"; + state.connectionError = msg; + } + }, setMods(state, payload: ThunderstoreMod[]) { state.mods = payload; },