Skip to content

Commit 3d73b23

Browse files
committed
FIX: issue expansion names not being translated correctly in settings
1 parent 6cb3170 commit 3d73b23

File tree

3 files changed

+39
-13
lines changed

3 files changed

+39
-13
lines changed

src/Redux/Store/Settings/Expansions/Expansions/content/selectors.ts

+15-6
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11
import { ExpansionContentStateSlice } from './types'
22
import { createSelector } from 'reselect'
3+
import * as Languages from '../../Languages'
34

45
import { selectors as LanguageSelectors } from '../../Languages'
6+
import { ContentStruct } from '../../helpers'
7+
import { Expansion } from 'aer-types'
58

69
const getContent = (state: ExpansionContentStateSlice) =>
710
state.Settings.Expansions.Expansions.content
811

912
const getId = (_: unknown, props: { expansionId: string }) => props.expansionId
1013

14+
export const getContentWithLanguageFallback = (
15+
languages: Languages.State,
16+
content: ContentStruct<Expansion>,
17+
id: string
18+
) => {
19+
// Just get the corresponding expansion id from the english version
20+
const language = languages[content.ENG[id].id]
21+
22+
return content[language][id] || content.ENG[id]
23+
}
24+
1125
const getExpansionById = createSelector(
1226
[LanguageSelectors.getLanguagesByExpansion, getContent, getId],
13-
(languages, content, id) => {
14-
// Just get the corresponding expansion id from the english version
15-
const language = languages[content.ENG[id].id]
16-
17-
return content[language][id] || content.ENG[id]
18-
}
27+
getContentWithLanguageFallback
1928
)
2029

2130
export const selectors = {

src/Redux/Store/Settings/Expansions/Expansions/index.ts

+23-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { combineReducers, reduceReducers, Cmd, loop } from 'redux-loop'
22
import { createSelector } from 'reselect'
33
import { set as setToDb } from 'idb-keyval'
4+
import { selectors as LanguageSelectors } from '../Languages'
45

56
import * as Content from './content'
67
import * as Selected from './selected'
78
import * as Ids from './ids'
89
import { createAction, ActionsUnion } from '@martin_hotell/rex-tils'
910
import { EXPANSIONS_DB_KEY } from './constants'
11+
import { getContentWithLanguageFallback } from './content/selectors'
1012

1113
///////////
1214
// STATE //
@@ -154,16 +156,31 @@ const getPromoIds = createSelector(
154156
)
155157

156158
const getStandaloneExpansions = createSelector(
157-
[Content.selectors.getContent, getStandaloneExpansionIds],
158-
(content, ids) => ids.map(id => content.ENG[id])
159+
[
160+
Content.selectors.getContent,
161+
getStandaloneExpansionIds,
162+
LanguageSelectors.getLanguagesByExpansion,
163+
],
164+
(content, ids, languages) =>
165+
ids.map(id => getContentWithLanguageFallback(languages, content, id))
159166
)
160167
const getMiniExpansions = createSelector(
161-
[Content.selectors.getContent, getMiniExpansionIds],
162-
(content, ids) => ids.map(id => content.ENG[id])
168+
[
169+
Content.selectors.getContent,
170+
getMiniExpansionIds,
171+
LanguageSelectors.getLanguagesByExpansion,
172+
],
173+
(content, ids, languages) =>
174+
ids.map(id => getContentWithLanguageFallback(languages, content, id))
163175
)
164176
const getPromos = createSelector(
165-
[Content.selectors.getContent, getPromoIds],
166-
(content, ids) => ids.map(id => content.ENG[id])
177+
[
178+
Content.selectors.getContent,
179+
getPromoIds,
180+
LanguageSelectors.getLanguagesByExpansion,
181+
],
182+
(content, ids, languages) =>
183+
ids.map(id => getContentWithLanguageFallback(languages, content, id))
167184
)
168185

169186
export const selectors = {

src/Redux/Store/Settings/Expansions/helpers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type Entity =
1919
| UpgradedBasicNemesisCard
2020
| ICard
2121

22-
type ContentStruct<T> = {
22+
export type ContentStruct<T> = {
2323
[key in LanguageKey]: {
2424
[id: string]: T
2525
}

0 commit comments

Comments
 (0)