Skip to content

Commit

Permalink
Rename ambiguous "connectionError"
Browse files Browse the repository at this point in the history
  • Loading branch information
anttimaki committed Dec 20, 2024
1 parent b0419fd commit e6581bf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions src/components/settings-components/SettingsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,8 @@ import CdnProvider from '../../providers/generic/connection/CdnProvider';
if (this.$store.state.tsMods.isThunderstoreModListUpdateInProgress) {
return "Checking for new releases";
}
if (this.$store.state.tsMods.connectionError.length > 0) {
return "Error getting new mods: " + this.$store.state.tsMods.connectionError;
if (this.$store.state.tsMods.thunderstoreModListUpdateError.length > 0) {
return "Error getting new mods: " + this.$store.state.tsMods.thunderstoreModListUpdateError;
}
if (this.$store.state.tsMods.modsLastUpdated !== undefined) {
return "Cache date: " + moment(this.$store.state.tsMods.modsLastUpdated).format("MMMM Do YYYY, h:mm:ss a");
Expand All @@ -317,12 +317,12 @@ import CdnProvider from '../../providers/generic/connection/CdnProvider';
}
this.$store.commit("tsMods/startThunderstoreModListUpdate");
this.$store.commit("tsMods/setConnectionError", "");
this.$store.commit("tsMods/setThunderstoreModListUpdateError", "");
try {
await this.refreshThunderstoreModList();
} catch (e) {
this.$store.commit("tsMods/setConnectionError", e);
this.$store.commit("tsMods/setThunderstoreModListUpdateError", e);
} finally {
this.$store.commit("tsMods/finishThunderstoreModListUpdate");
}
Expand Down
26 changes: 13 additions & 13 deletions src/store/modules/TsModsModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ export interface CachedMod {

interface State {
cache: Map<string, CachedMod>;
connectionError: string;
deprecated: Map<string, boolean>;
exclusions?: string[];
isThunderstoreModListUpdateInProgress: boolean;
mods: ThunderstoreMod[];
modsLastUpdated?: Date;
thunderstoreModListUpdateError: string;
}

type ProgressCallback = (progress: number) => void;
Expand All @@ -49,8 +49,6 @@ export const TsModsModule = {

state: (): State => ({
cache: new Map<string, CachedMod>(),
/*** Error shown on UI after manual mod list refresh fails */
connectionError: '',
deprecated: new Map<string, boolean>(),
/*** Packages available through API that should be ignored by the manager */
exclusions: undefined,
Expand All @@ -59,7 +57,9 @@ export const TsModsModule = {
/*** All mods available through API for the current active game */
mods: [],
/*** When was the mod list last refreshed from the API? */
modsLastUpdated: undefined
modsLastUpdated: undefined,
/*** Error shown on UI after manual mod list refresh fails */
thunderstoreModListUpdateError: ''
}),

getters: <GetterTree<State, RootState>>{
Expand Down Expand Up @@ -119,26 +119,18 @@ export const TsModsModule = {
mutations: <MutationTree<State>>{
reset(state: State) {
state.cache = new Map<string, CachedMod>();
state.connectionError = '';
state.deprecated = new Map<string, boolean>();
state.exclusions = undefined;
state.mods = [];
state.modsLastUpdated = undefined;
state.thunderstoreModListUpdateError = '';
},
clearModCache(state) {
state.cache.clear();
},
finishThunderstoreModListUpdate(state) {
state.isThunderstoreModListUpdateInProgress = false;
},
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;
},
Expand All @@ -148,6 +140,14 @@ export const TsModsModule = {
setExclusions(state, payload: string[]) {
state.exclusions = payload;
},
setThunderstoreModListUpdateError(state, error: string|unknown) {
if (typeof error === 'string') {
state.thunderstoreModListUpdateError = error;
} else {
const msg = error instanceof Error ? error.message : "Unknown error";
state.thunderstoreModListUpdateError = msg;
}
},
startThunderstoreModListUpdate(state) {
state.isThunderstoreModListUpdateInProgress = true;
},
Expand Down

0 comments on commit e6581bf

Please sign in to comment.