Skip to content

Commit 03033af

Browse files
author
Mykolas Maciekus
authored
Merge pull request #493 from mysteriumnetwork/improvements/mobile_provider_flags
New ui features tequila api endpoint
2 parents c014f1c + 37380c5 commit 03033af

File tree

4 files changed

+10
-16
lines changed

4 files changed

+10
-16
lines changed

src/Pages/StateInitializer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const StateInitializer = ({ children }: Props) => {
3333
;(async () => {
3434
const isDefaultPassword = await tequila.loginWithDefaultCredentials()
3535
let isAuthenticated = isDefaultPassword
36-
36+
await complexActions.loadUIFeaturesBeforeAuthentificationAsync()
3737
//check if there is a token cookie saved
3838
if (!isAuthenticated) {
3939
isAuthenticated = await tequila.isUserAuthenticated()

src/api/tequila.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,16 @@ const initClaim = async (redirectUrl: string = urls.currentOrigin(routes.CLAIM))
102102
const loginWithAuthorizationGrant = async ({ authorizationGrantToken }: { authorizationGrantToken: string }) =>
103103
await http.post('/auth/login-mystnodes', { authorization_grant: authorizationGrantToken })
104104

105+
const getUIFeatures = async () => await http.get('/config/ui/features').then((r) => r.data)
106+
105107
export const tequila = {
106108
api: tequilaClient,
107109
http,
108110
loginWithDefaultCredentials,
109111
isUserAuthenticated,
110112
startAllServices,
111113
stopAllServices,
114+
getUIFeatures,
112115
restartRunningServices,
113116
initSSOAuth,
114117
initClaim,

src/commons/config.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@
88
import _ from 'lodash'
99
import { Config } from 'mysterium-vpn-js'
1010
import toasts from './toasts'
11-
import localStorageWrapper from './localStorageWrapper'
12-
import { localStorageKeys } from '../constants/local-storage.keys'
1311

1412
const { toastError } = toasts
15-
const { FEATURES } = localStorageKeys
1613

1714
export const SUPPORTED_TRAVERSALS = ['manual', 'upnp', 'holepunching']
1815

@@ -129,10 +126,6 @@ const uiFeatures = (c: Config): string[] => {
129126
if (configFeatures) {
130127
return configFeatures.split(',')
131128
}
132-
const lsFeaturesString = localStorageWrapper.getSettings(FEATURES)
133-
if (lsFeaturesString) {
134-
return lsFeaturesString.toString().split(',')
135-
}
136129
return []
137130
}
138131

src/redux/complex.actions.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,8 @@ import { store } from './store'
2626
import errors from '../commons/errors'
2727
import { Config } from 'mysterium-vpn-js'
2828
import termsPackageJson from '@mysteriumnetwork/terms/package.json'
29-
import localStorageWrapper from '../commons/localStorageWrapper'
30-
import { localStorageKeys } from '../constants/local-storage.keys'
3129

3230
const { api } = tequila
33-
const { FEATURES } = localStorageKeys
3431

3532
const updateTermsStoreAsync = async () => {
3633
const { dispatch } = store
@@ -61,10 +58,6 @@ const fetchIdentityAndRelativeInformationAsync = async () => {
6158
const fetchConfigAsync = async () => {
6259
const { dispatch } = store
6360
const config = await api.config()
64-
console.log('configChange')
65-
if (config.data.ui.features) {
66-
localStorageWrapper.writeSettings(FEATURES, config.data.ui.features)
67-
}
6861
dispatch(updateConfigStore(config))
6962
}
7063

@@ -128,7 +121,11 @@ const startContinuouslyUpdatingFees = async () => {
128121
setTimeout(() => startContinuouslyUpdatingFees(), SECOND * 10)
129122
}
130123
}
131-
124+
const loadUIFeaturesBeforeAuthentificationAsync = async () => {
125+
await tequila.getUIFeatures().then((r) => {
126+
store.dispatch(updateConfigStore({ data: { ui: { features: r } } }))
127+
})
128+
}
132129
const refreshStoreConfig = async (): Promise<Config> => {
133130
return await api.config().then((config) => {
134131
store.dispatch(updateConfigStore(config))
@@ -184,6 +181,7 @@ const setUserConfig = async (data: any): Promise<Config> => {
184181
const setChatOpened = (b: boolean) => store.dispatch(updateChatOpenedStore(b))
185182

186183
const complexActions = {
184+
loadUIFeaturesBeforeAuthentificationAsync,
187185
loadAppStateAfterAuthenticationAsync,
188186
setTrafficShaping,
189187
setUserConfig,

0 commit comments

Comments
 (0)