aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores/GlobalErrorStore.js
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2017-10-13 12:29:40 +0200
committerLibravatar Stefan Malzner <stefan@adlk.io>2017-10-13 12:29:40 +0200
commit58cda9cc7fb79ca9df6746de7f9662bc08dc156a (patch)
tree1211600c2a5d3b5f81c435c6896618111a611720 /src/stores/GlobalErrorStore.js
downloadferdium-app-58cda9cc7fb79ca9df6746de7f9662bc08dc156a.tar.gz
ferdium-app-58cda9cc7fb79ca9df6746de7f9662bc08dc156a.tar.zst
ferdium-app-58cda9cc7fb79ca9df6746de7f9662bc08dc156a.zip
initial commit
Diffstat (limited to 'src/stores/GlobalErrorStore.js')
-rw-r--r--src/stores/GlobalErrorStore.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/stores/GlobalErrorStore.js b/src/stores/GlobalErrorStore.js
new file mode 100644
index 000000000..f4b9d7838
--- /dev/null
+++ b/src/stores/GlobalErrorStore.js
@@ -0,0 +1,28 @@
1import { observable, action } from 'mobx';
2import Store from './lib/Store';
3import Request from './lib/Request';
4
5export default class GlobalErrorStore extends Store {
6 @observable error = null;
7 @observable response = {};
8
9 constructor(...args) {
10 super(...args);
11
12 Request.registerHook(this._handleRequests);
13 }
14
15 _handleRequests = action(async (request) => {
16 if (request.isError) {
17 this.error = request.error;
18
19 if (request.error.json) {
20 this.response = await request.error.json();
21
22 if (this.error.status === 401) {
23 this.actions.user.logout({ serverLogout: true });
24 }
25 }
26 }
27 });
28}