Skip to content
This repository has been archived by the owner on Dec 13, 2019. It is now read-only.

Commit

Permalink
Feature detection mechanism cuba-platform/cuba-rest-js#20
Browse files Browse the repository at this point in the history
  • Loading branch information
vyacheslav-pushkin committed Nov 27, 2019
1 parent f26e3b6 commit 62030ea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cuba-platform/react",
"version": "0.3.1-dev.7",
"version": "0.3.1-dev.8",
"description": "CUBA Platform utilities and components for React",
"main": "dist/index.js",
"module": "dist/index.esm.js",
Expand All @@ -17,7 +17,7 @@
"react-intl": "^3.3.2"
},
"devDependencies": {
"@cuba-platform/rest": "0.7.0-dev.2",
"@cuba-platform/rest": "0.7.0-dev.3",
"@types/jest": "^24.0.18",
"@types/moment-timezone": "^0.5.12",
"@types/react": "^16.7.18",
Expand Down
10 changes: 8 additions & 2 deletions src/app/MainStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,14 @@ export class MainStore {
};

setSessionLocale = () => {
// noinspection JSIgnoredPromiseFromCall
this.cubaREST.setSessionLocale();
this.cubaREST.setSessionLocale().catch((reason) => {
if (reason === CubaApp.NOT_SUPPORTED_BY_API_VERSION) {
throw new Error('Relogin is required in order for bean validation messages to use correct locale. ' +
'Upgrade to REST API 7.2.0 or higher to be able to change locale without relogin.');
} else {
throw new Error('Failed to determine REST API version');
}
});
};

@computed get loginRequired(): boolean {
Expand Down

0 comments on commit 62030ea

Please sign in to comment.