Passed
Push — master ( b85d84...ad752e )
by Christian
15:16 queued 12s
created

index.js ➔ initState   A

Complexity

Conditions 3

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 12
rs 10
c 0
b 0
f 0
cc 3
1
import extensionStore from './extensions.store';
2
3
export default function initState(Shopware) {
4
    Shopware.State.registerModule('shopwareExtensions', extensionStore);
5
6
    let languageId = Shopware.State.get('session').languageId;
7
    Shopware.State._store.subscribe(({ type }, state) => {
8
        if (type === 'setAdminLocale' && state.session.languageId !== '' && languageId !== state.session.languageId) {
9
            Shopware.State.dispatch('shopwareExtensions/updateInstalledExtensions');
10
            Shopware.State.dispatch('shopwareExtensions/updateLicensedExtensions');
11
            languageId = state.session.languageId;
12
        }
13
    });
14
}
15