Skip to content

Commit 6af39a4

Browse files
committed
Extract getCompanionWindowLocale selector.
1 parent efc99f3 commit 6af39a4

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/state/selectors/companionWindows.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@ export const getCompanionWindow = createSelector(
2929
(companionWindows, companionWindowId) => companionWindowId && companionWindows[companionWindowId],
3030
);
3131

32+
/**
33+
* Returns the companion window locale.
34+
* @param {object} state
35+
* @param {object} props
36+
* @param {string} props.companionWindowId
37+
* @returns {string|undefined}
38+
*/
39+
export const getCompanionWindowLocale = createSelector(
40+
[getCompanionWindow],
41+
companionWindow => companionWindow && companionWindow.locale,
42+
);
43+
3244
/**
3345
* Return position of thumbnail navigation in a certain window.
3446
* @param {object} state

src/state/selectors/manifests.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { createCachedSelector } from 're-reselect';
33
import { PropertyValue, Utils, Resource } from 'manifesto.js';
44
import getThumbnail from '../../lib/ThumbnailFactory';
55
import asArray from '../../lib/asArray';
6-
import { getCompanionWindow } from './companionWindows';
6+
import { getCompanionWindowLocale } from './companionWindows';
77
import { getManifest } from './getters';
88
import { getConfig } from './config';
99

@@ -22,11 +22,11 @@ function createManifestoInstance(json, locale) {
2222
/** */
2323
export const getLocale = createSelector(
2424
[
25-
getCompanionWindow,
25+
getCompanionWindowLocale,
2626
getConfig,
2727
],
28-
(companionWindow = {}, config = {}) => (
29-
companionWindow.locale || config.language
28+
(companionWindowLocale, config = {}) => (
29+
companionWindowLocale || config.language
3030
),
3131
);
3232

0 commit comments

Comments
 (0)